pub struct SecondaryBlockIndex { /* private fields */ }Expand description
Secondary index for fast block lookups by codec, tag, size range, and creation-tick range.
Maintains inverted indices from codec and tag to CID lists so that lookups by those dimensions are O(bucket-size) instead of O(n). Size-range and tick-range queries use linear filtering over the primary entry map.
Implementations§
Source§impl SecondaryBlockIndex
impl SecondaryBlockIndex
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty SecondaryBlockIndex.
Sourcepub fn insert(&mut self, entry: BlockIndexEntry)
pub fn insert(&mut self, entry: BlockIndexEntry)
Insert a BlockIndexEntry into the index.
If an entry with the same CID already exists it is removed first so that all inverted indices stay consistent.
Sourcepub fn remove(&mut self, cid: &str) -> Option<BlockIndexEntry>
pub fn remove(&mut self, cid: &str) -> Option<BlockIndexEntry>
Remove an entry by CID from all indices.
Returns Some(entry) if found, None otherwise.
Sourcepub fn get(&self, cid: &str) -> Option<&BlockIndexEntry>
pub fn get(&self, cid: &str) -> Option<&BlockIndexEntry>
Look up an entry by CID.
Sourcepub fn find_by_codec(&self, codec: &str) -> Vec<&BlockIndexEntry>
pub fn find_by_codec(&self, codec: &str) -> Vec<&BlockIndexEntry>
Return all entries that use the given codec, sorted by CID for deterministic ordering.
Sourcepub fn find_by_tag(&self, tag: &str) -> Vec<&BlockIndexEntry>
pub fn find_by_tag(&self, tag: &str) -> Vec<&BlockIndexEntry>
Return all entries that carry the given tag, sorted by CID.
Sourcepub fn find_by_size_range(&self, min: u64, max: u64) -> Vec<&BlockIndexEntry>
pub fn find_by_size_range(&self, min: u64, max: u64) -> Vec<&BlockIndexEntry>
Return all entries whose size_bytes is within [min, max]
(inclusive), sorted by CID.
Sourcepub fn find_by_created_range(
&self,
min_tick: u64,
max_tick: u64,
) -> Vec<&BlockIndexEntry>
pub fn find_by_created_range( &self, min_tick: u64, max_tick: u64, ) -> Vec<&BlockIndexEntry>
Return all entries whose created_tick is within [min_tick, max_tick]
(inclusive), sorted by CID.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of entries currently in the index.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Cumulative size in bytes of all indexed blocks.
Sourcepub fn unique_codecs(&self) -> Vec<String>
pub fn unique_codecs(&self) -> Vec<String>
Return all distinct codec strings, sorted alphabetically.
Return all distinct tag strings, sorted alphabetically.
Sourcepub fn stats(&self) -> BlockIndexStats
pub fn stats(&self) -> BlockIndexStats
Compute aggregate statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecondaryBlockIndex
impl RefUnwindSafe for SecondaryBlockIndex
impl Send for SecondaryBlockIndex
impl Sync for SecondaryBlockIndex
impl Unpin for SecondaryBlockIndex
impl UnsafeUnpin for SecondaryBlockIndex
impl UnwindSafe for SecondaryBlockIndex
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