pub struct OnDiskHashIndex<K: IndexKey> { /* private fields */ }Expand description
Implementations§
Source§impl<K: IndexKey + Hash + Eq> OnDiskHashIndex<K>
impl<K: IndexKey + Hash + Eq> OnDiskHashIndex<K>
Sourcepub fn new(file_name: &str) -> Self
pub fn new(file_name: &str) -> Self
Create a new on-disk hash index.
If bm is None, operates purely in-memory (L1 cache only).
The file_name is used to register the index file with the BufferManager.
Sourcepub fn rebuild_from_disk(&mut self, bm: &mut BufferManager) -> Result<()>
pub fn rebuild_from_disk(&mut self, bm: &mut BufferManager) -> Result<()>
Rebuild the L1 cache from on-disk pages.
Call this on database startup after the BufferManager is initialized.
pub fn is_empty(&self) -> bool
Sourcepub fn lookup_cached(&self, key: &K) -> Option<u64>
pub fn lookup_cached(&self, key: &K) -> Option<u64>
Look up a key in the L1 cache (fast path).
For write operations during query execution, this is always used.
Sourcepub fn lookup(&self, key: &K, bm: &mut BufferManager) -> Result<Option<u64>>
pub fn lookup(&self, key: &K, bm: &mut BufferManager) -> Result<Option<u64>>
Look up a key, potentially reading from the on-disk index.
If the key is in L1 cache, returns immediately. Otherwise, scans the on-disk bucket page.
Sourcepub fn insert(&mut self, key: K, value: u64)
pub fn insert(&mut self, key: K, value: u64)
Insert a key-value pair.
Writes to L1 cache immediately. The on-disk write happens on flush().
Sourcepub fn flush(&mut self, bm: &mut BufferManager) -> Result<()>
pub fn flush(&mut self, bm: &mut BufferManager) -> Result<()>
Flush all cached entries to the on-disk hash index.
This writes all key-value pairs from L1 cache into the BufferManager page-structured hash table. After this, the index is durably stored.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for OnDiskHashIndex<K>
impl<K> RefUnwindSafe for OnDiskHashIndex<K>
impl<K> Send for OnDiskHashIndex<K>
impl<K> Sync for OnDiskHashIndex<K>
impl<K> Unpin for OnDiskHashIndex<K>
impl<K> UnsafeUnpin for OnDiskHashIndex<K>
impl<K> UnwindSafe for OnDiskHashIndex<K>
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