Struct tantivy_columnar::column_index::OptionalIndex

source ·
pub struct OptionalIndex { /* private fields */ }
Expand description

This codec is inspired by roaring bitmaps. In the dense blocks, however, in order to accelerate select we interleave an offset over two bytes. (more on this lower)

The lower 16 bits of doc ids are stored as u16 while the upper 16 bits are given by the block id. Each block contains 1<<16 docids.

§Serialized Data Layout

The data starts with the block data. Each block is either dense or sparse encoded, depending on the number of values in the block. A block is sparse when it contains less than DENSE_BLOCK_THRESHOLD (6144) values. [Sparse data block | dense data block, .. #repeat*; Desc: Either a sparse or dense encoded block]

§Sparse block data

[u16 LE, .. #repeat*; Desc: Positions with values in a block]

§Dense block data

[Dense codec for the whole block; Desc: Similar to a bitvec(0..ELEMENTS_PER_BLOCK) + Metadata for faster lookups. See dense.rs]

The data is followed by block metadata, to know which area of the raw block data belongs to which block. Only metadata for blocks with elements is recorded to keep the overhead low for scenarios with many very sparse columns. The block metadata consists of the block index and the number of values in the block. Since we don’t store empty blocks num_vals is incremented by 1, e.g. 0 means 1 value.

The last u16 is storing the number of metadata blocks. [u16 LE, .. #repeat*; Desc: Positions with values in a block][(u16 LE, u16 LE), .. #repeat*; Desc: (Block Id u16, Num Elements u16)][u16 LE; Desc: num blocks with values u16]

§Opening

When opening the data layout, the data is expanded to Vec<SparseCodecBlockVariant>, where the index is the block index. For each block byte_start and offset is computed.

Implementations§

source§

impl OptionalIndex

source

pub fn for_test(num_rows: RowId, row_ids: &[RowId]) -> OptionalIndex

source

pub fn num_docs(&self) -> RowId

source

pub fn num_non_nulls(&self) -> RowId

source

pub fn iter_rows(&self) -> impl Iterator<Item = RowId> + '_

source

pub fn select_batch(&self, ranks: &mut [RowId])

Trait Implementations§

source§

impl Clone for OptionalIndex

source§

fn clone(&self) -> OptionalIndex

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for OptionalIndex

source§

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

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

impl From<OptionalIndex> for ColumnIndex

source§

fn from(optional_index: OptionalIndex) -> ColumnIndex

Converts to this type from the input type.
source§

impl Set<u32> for OptionalIndex

source§

fn rank(&self, doc_id: DocId) -> RowId

Any value doc_id is allowed. In particular, doc_id = num_rows.

source§

fn rank_if_exists(&self, doc_id: DocId) -> Option<RowId>

Any value doc_id is allowed. In particular, doc_id = num_rows.

§

type SelectCursor<'b> = OptionalIndexSelectCursor<'b> where Self: 'b

source§

fn contains(&self, row_id: RowId) -> bool

Returns true if the elements is contained in the Set
source§

fn select(&self, rank: RowId) -> RowId

Return the rank-th value stored in this bitmap. Read more
source§

fn select_cursor(&self) -> OptionalIndexSelectCursor<'_>

Creates a brand new select cursor.

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> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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,

§

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>,

§

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>,

§

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.