Skip to main content

EwahBitmap

Struct EwahBitmap 

Source
pub struct EwahBitmap {
    pub bit_size: u32,
    pub words: Vec<u64>,
    pub rlw_position: u32,
}

Fields§

§bit_size: u32§words: Vec<u64>§rlw_position: u32

Implementations§

Source§

impl EwahBitmap

Source

pub fn from_words(bit_size: u32, words: &[u64]) -> Result<Self>

Constructs an EwahBitmap in git’s canonical EWAH compressed form from a slice of raw uncompressed 64-bit words.

Within each word bit i corresponds to position word_index * 64 + i, matching git’s on-disk convention. bit_size records the number of logical bits the bitmap spans; it must not exceed words.len() * 64.

This mirrors libgit’s ewah_add/ewah_add_empty_words incremental encoder: consecutive all-zero or all-one words collapse into a run, and any other word is stored verbatim as a literal. Only the first bit_size.div_ceil(64) words back the declared bits; any extra trailing words supplied by the caller are ignored, just as git encodes a bitmap sized to its highest set bit.

Source

pub fn from_positions(bit_size: u32, positions: &[u32]) -> Result<Self>

Constructs an EwahBitmap from a set of bit positions.

bit_size is the number of logical bits (typically the pack object count). Every position in positions must be strictly less than bit_size. Positions may be given in any order and may repeat.

Source

pub fn empty() -> Self

An empty EWAH bitmap (no bits, no words). This is what git writes for an all-zero type bitmap (e.g. when a pack has no tags).

Source

pub fn to_words(&self) -> Result<Vec<u64>>

Decodes the compressed EWAH back into raw 64-bit words, LSB-first within each word. The returned vector has bit_size.div_ceil(64) entries.

This is the inverse of EwahBitmap::from_words for the bits the bitmap actually covers and is primarily used to validate roundtrips.

Source

pub fn to_positions(&self) -> Result<Vec<u32>>

Returns the sorted set bit positions covered by this bitmap.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialises the bitmap to git’s on-disk EWAH byte layout: bit_size (u32 BE), word count (u32 BE), each compressed word (u64 BE), then the running-length-word position (u32 BE).

Trait Implementations§

Source§

impl Clone for EwahBitmap

Source§

fn clone(&self) -> EwahBitmap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EwahBitmap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for EwahBitmap

Source§

impl PartialEq for EwahBitmap

Source§

fn eq(&self, other: &EwahBitmap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EwahBitmap

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.