pub enum U64Segment {
Range(Range<u64>),
RangeWithHoles {
range: Range<u64>,
holes: EncodedU64Array,
},
RangeWithBitmap {
range: Range<u64>,
bitmap: Bitmap,
},
SortedArray(EncodedU64Array),
Array(EncodedU64Array),
}Expand description
Different ways to represent a sequence of distinct u64s.
This is designed to be especially efficient for sequences that are sorted,
but not meaningfully larger than a Vec
The representation is chosen based on the properties of the sequence:
Sorted?───►Yes ───►Contiguous?─► Yes─► Range
│ ▼
│ No
│ ▼
│ Dense?─────► Yes─► RangeWithBitmap/RangeWithHoles
│ ▼
│ No─────────────► SortedArray
▼
No──────────────────────────────► Array
“Dense” is decided based on the estimated byte size of the representation.
Size of RangeWithBitMap for N values: 8 bytes + 8 bytes + ceil((max - min) / 8) bytes Size of SortedArray for N values (assuming u16 packed): 8 bytes + 8 bytes + 8 bytes + 2 bytes * N
Variants§
Range(Range<u64>)
A contiguous sorted range of row ids.
Total size: 16 bytes
RangeWithHoles
A sorted range of row ids, that is mostly contiguous.
Total size: 24 bytes + n_holes * 4 bytes Use when: 32 * n_holes < max - min
Fields
holes: EncodedU64ArrayBitmap of offsets from the start of the range that are holes. This is sorted, so binary search can be used. It’s typically relatively small.
RangeWithBitmap
A sorted range of row ids, that is mostly contiguous.
Bitmap is 1 when the value is present, 0 when it’s missing.
Total size: 24 bytes + ceil((max - min) / 8) bytes Use when: max - min > 16 * len
SortedArray(EncodedU64Array)
A sorted array of row ids, that is sparse.
Total size: 24 bytes + 2 * n_values bytes
Array(EncodedU64Array)
An array of row ids, that is not sorted.
Implementations§
Source§impl U64Segment
impl U64Segment
pub fn from_slice(slice: &[u64]) -> Self
Source§impl U64Segment
impl U64Segment
pub fn iter(&self) -> Box<dyn DoubleEndedIterator<Item = u64> + '_>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn range(&self) -> Option<RangeInclusive<u64>>
pub fn range(&self) -> Option<RangeInclusive<u64>>
Get the min and max value of the segment, excluding tombstones.
pub fn slice(&self, offset: usize, len: usize) -> Self
pub fn position(&self, val: u64) -> Option<usize>
pub fn get(&self, i: usize) -> Option<u64>
Sourcepub fn with_new_high(self, val: u64) -> Result<Self>
pub fn with_new_high(self, val: u64) -> Result<Self>
Produce a new segment that has [val] as the new highest value in the segment
Sourcepub fn delete(&self, vals: &[u64]) -> Self
pub fn delete(&self, vals: &[u64]) -> Self
Delete a set of row ids from the segment. The row ids are assumed to be in the segment. (within the range, not already deleted.) They are also assumed to be ordered by appearance in the segment.
pub fn mask(&mut self, positions: &[u32])
Trait Implementations§
Source§impl Clone for U64Segment
impl Clone for U64Segment
Source§fn clone(&self) -> U64Segment
fn clone(&self) -> U64Segment
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for U64Segment
impl Debug for U64Segment
Source§impl DeepSizeOf for U64Segment
impl DeepSizeOf for U64Segment
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§fn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Source§impl From<U64Segment> for U64Segment
impl From<U64Segment> for U64Segment
Source§fn from(segment: U64Segment) -> Self
fn from(segment: U64Segment) -> Self
Source§impl FromIterator<u64> for U64Segment
impl FromIterator<u64> for U64Segment
Source§impl PartialEq for U64Segment
impl PartialEq for U64Segment
Source§impl TryFrom<U64Segment> for U64Segment
impl TryFrom<U64Segment> for U64Segment
impl Eq for U64Segment
impl StructuralPartialEq for U64Segment
Auto Trait Implementations§
impl Freeze for U64Segment
impl RefUnwindSafe for U64Segment
impl Send for U64Segment
impl Sync for U64Segment
impl Unpin for U64Segment
impl UnwindSafe for U64Segment
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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