pub struct TwoLevelIndex {
pub fence_pointers: Vec<FencePointer>,
pub total_blocks: u32,
pub block_index_offset: u64,
pub block_index_length: u64,
}Expand description
Two-level index for efficient lookups with minimal memory usage
The top-level fence pointers are always in memory (~1KB per GB of data). Block index entries are loaded on-demand.
Fields§
§fence_pointers: Vec<FencePointer>Top-level fence pointers (always in memory)
total_blocks: u32Total number of blocks in the SSTable
block_index_offset: u64Offset of the block index section in the file
block_index_length: u64Length of the block index section
Implementations§
Source§impl TwoLevelIndex
impl TwoLevelIndex
Sourcepub fn build(blocks: &[BlockIndexEntry], block_index_offset: u64) -> Self
pub fn build(blocks: &[BlockIndexEntry], block_index_offset: u64) -> Self
Create a new two-level index from block entries
This is called during SSTable creation to build the index structure.
Sourcepub fn find_fence_range(&self, key: &TemporalKey) -> (u64, u64)
pub fn find_fence_range(&self, key: &TemporalKey) -> (u64, u64)
Find the fence pointer range that may contain the target key
Returns (start_offset, end_offset) within the block index section.
Sourcepub fn find_fence_range_for_timestamps(
&self,
start_ts: u64,
end_ts: u64,
) -> (u64, u64)
pub fn find_fence_range_for_timestamps( &self, start_ts: u64, end_ts: u64, ) -> (u64, u64)
Find fence pointer range for a timestamp range query
Returns (start_offset, end_offset) within the block index section.
Sourcepub fn fence_pointers_to_bytes(&self) -> Vec<u8> ⓘ
pub fn fence_pointers_to_bytes(&self) -> Vec<u8> ⓘ
Serialize the fence pointers to bytes (stored in footer)
Sourcepub fn fence_pointers_from_bytes(
bytes: &[u8],
block_index_offset: u64,
block_index_length: u64,
) -> Result<Self>
pub fn fence_pointers_from_bytes( bytes: &[u8], block_index_offset: u64, block_index_length: u64, ) -> Result<Self>
Deserialize fence pointers from bytes
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimate memory usage of this index in bytes
Sourcepub fn fence_count(&self) -> usize
pub fn fence_count(&self) -> usize
Get the number of fence pointers
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TwoLevelIndex
impl RefUnwindSafe for TwoLevelIndex
impl Send for TwoLevelIndex
impl Sync for TwoLevelIndex
impl Unpin for TwoLevelIndex
impl UnsafeUnpin for TwoLevelIndex
impl UnwindSafe for TwoLevelIndex
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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