pub struct BitVector { /* private fields */ }Expand description
Implementations§
Source§impl BitVector
impl BitVector
Sourcepub fn from_raw_parts(data: Vec<u64>, len: usize) -> Self
pub fn from_raw_parts(data: Vec<u64>, len: usize) -> Self
Reconstructs from pre-packed raw parts (legacy: Vec<u64> words).
Used by section deserialization that holds words on the heap.
Phase 3c will add from_bytes_storage
for mmap-backed construction.
Sourcepub fn from_bytes_storage(data: Bytes, len: usize) -> Self
pub fn from_bytes_storage(data: Bytes, len: usize) -> Self
Constructs from pre-encoded bytes (Phase 3c entry point).
data must be ceil(len / 64) * 8 bytes of little-endian
u64 words. Used by the mmap path so a column can hold a
slice of mapped memory without copying.
Sourcepub fn from_mmap(data: Bytes, len: usize) -> Result<Self, BitVectorFormatError>
pub fn from_mmap(data: Bytes, len: usize) -> Result<Self, BitVectorFormatError>
Phase 6a: zero-copy mmap constructor.
Adopts a refcounted Bytes slice (typically produced by
Bytes::from_owner(mmap) or a sub-slice thereof) as the
backing storage without copying. The on-disk contract is
little-endian u64 words, with len total bits stored in
ceil(len / 64) * 8 bytes.
§Errors
Returns an error if the byte length doesn’t match the expected
ceil(len / 64) * 8 for the declared bit count. This guards
against truncated or oversized mmap regions.
Sourcepub fn from_bools(bools: &[bool]) -> Self
pub fn from_bools(bools: &[bool]) -> Self
Creates a bit vector from a slice of booleans.
Routes through a BitVectorBuilder internally; Phase 3b
preserves the original convenience API for callers that already
have the bools materialized.
Sourcepub fn filled(len: usize, value: bool) -> Self
pub fn filled(len: usize, value: bool) -> Self
Creates a bit vector with all bits set to the same value.
Sourcepub fn word_count(&self) -> usize
pub fn word_count(&self) -> usize
Returns the number of u64 words backing this bit vector.
Sourcepub fn word_at(&self, idx: usize) -> Option<u64>
pub fn word_at(&self, idx: usize) -> Option<u64>
Returns the word at idx, or None if out of range.
Reads via from_le_bytes; supports unaligned Bytes slices
(e.g., mmap-backed sub-slices in Phase 3c).
Sourcepub fn data_bytes(&self) -> &Bytes
pub fn data_bytes(&self) -> &Bytes
Returns the raw byte storage.
Phase 3c serializers use this to write the storage out directly (the on-disk format already matches our LE word layout).
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of bits set to true.
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Returns the number of bits set to false.
Sourcepub fn to_bools(&self) -> Vec<bool>
pub fn to_bools(&self) -> Vec<bool>
Converts back to a Vec<bool>.
§Panics
Panics if internal storage is shorter than len() bits — an
invariant violation that would indicate a bug in
from_bytes_storage caller’s
data validation.
Sourcepub fn ones_iter(&self) -> impl Iterator<Item = usize> + '_
pub fn ones_iter(&self) -> impl Iterator<Item = usize> + '_
Returns an iterator over indices where bits are true.
§Panics
Panics if internal storage is shorter than len() bits.
Sourcepub fn zeros_iter(&self) -> impl Iterator<Item = usize> + '_
pub fn zeros_iter(&self) -> impl Iterator<Item = usize> + '_
Returns an iterator over indices where bits are false.
§Panics
Panics if internal storage is shorter than len() bits.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Returns the compression ratio (original bytes / compressed bytes).
Sourcepub fn and(&self, other: &Self) -> Self
pub fn and(&self, other: &Self) -> Self
Performs bitwise AND with another bit vector. The result has the length of the shorter vector.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserializes from bytes.
§Errors
Returns Err if the byte slice is too short or contains invalid data.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BitVector
impl<'de> Deserialize<'de> for BitVector
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl FromIterator<bool> for BitVector
impl FromIterator<bool> for BitVector
impl Eq for BitVector
Auto Trait Implementations§
impl !Freeze for BitVector
impl RefUnwindSafe for BitVector
impl Send for BitVector
impl Sync for BitVector
impl Unpin for BitVector
impl UnsafeUnpin for BitVector
impl UnwindSafe for BitVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more