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§
Trait Implementations§
source§impl Clone for OptionalIndex
impl Clone for OptionalIndex
source§fn clone(&self) -> OptionalIndex
fn clone(&self) -> OptionalIndex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OptionalIndex
impl Debug for OptionalIndex
source§impl From<OptionalIndex> for ColumnIndex
impl From<OptionalIndex> for ColumnIndex
source§fn from(optional_index: OptionalIndex) -> ColumnIndex
fn from(optional_index: OptionalIndex) -> ColumnIndex
source§impl Set<u32> for OptionalIndex
impl Set<u32> for OptionalIndex
source§fn rank(&self, doc_id: DocId) -> RowId
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>
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
fn contains(&self, row_id: RowId) -> bool
source§fn select(&self, rank: RowId) -> RowId
fn select(&self, rank: RowId) -> RowId
source§fn select_cursor(&self) -> OptionalIndexSelectCursor<'_>
fn select_cursor(&self) -> OptionalIndexSelectCursor<'_>
Auto Trait Implementations§
impl Freeze for OptionalIndex
impl !RefUnwindSafe for OptionalIndex
impl Send for OptionalIndex
impl Sync for OptionalIndex
impl Unpin for OptionalIndex
impl !UnwindSafe for OptionalIndex
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.