U64Segment

Enum U64Segment 

Source
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 in the worst case.

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

§range: Range<u64>
§holes: EncodedU64Array

Bitmap 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

Fields

§range: Range<u64>
§bitmap: Bitmap
§

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

Source

pub fn from_slice(slice: &[u64]) -> Self

Source§

impl U64Segment

Source

pub fn iter(&self) -> Box<dyn DoubleEndedIterator<Item = u64> + '_>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn range(&self) -> Option<RangeInclusive<u64>>

Get the min and max value of the segment, excluding tombstones.

Source

pub fn slice(&self, offset: usize, len: usize) -> Self

Source

pub fn position(&self, val: u64) -> Option<usize>

Source

pub fn get(&self, i: usize) -> Option<u64>

Source

pub fn contains(&self, val: u64) -> bool

Check if a value is contained in the segment

Source

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

Source

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.

Source

pub fn mask(&mut self, positions: &[u32])

Trait Implementations§

Source§

impl Clone for U64Segment

Source§

fn clone(&self) -> U64Segment

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for U64Segment

Source§

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

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

impl DeepSizeOf for U64Segment

Source§

fn deep_size_of_children(&self, context: &mut Context) -> usize

Returns an estimation of the heap-managed storage of this object. This does not include the size of the object itself. Read more
Source§

fn deep_size_of(&self) -> usize

Returns an estimation of a total size of memory owned by the object, including heap-managed storage. Read more
Source§

impl From<U64Segment> for U64Segment

Source§

fn from(segment: U64Segment) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<u64> for U64Segment

Source§

fn from_iter<T: IntoIterator<Item = u64>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for U64Segment

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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 TryFrom<U64Segment> for U64Segment

Source§

type Error = Error

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

fn try_from(pb: U64Segment) -> Result<Self>

Performs the conversion.
Source§

impl Eq for U64Segment

Source§

impl StructuralPartialEq for U64Segment

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,