pub struct DiskHashMap<K, V, BS, S = FxBuildHasher>{ /* private fields */ }Expand description
This is an open address hash map implementation with trait-based encoding/decoding.
It takes any types that implement BytesEncode/BytesDecode as key and value.
It is designed to be used with a backing store that implements ByteStore trait,
allowing for flexible storage options (in-memory with VecStore or persistent with MMapFile).
The ByteStore is not used directly; instead we rely on Buffers
which is technically a Vec<Box<[u8]>> but backed by a ByteStore trait.
Implementations§
Source§impl<K, V, BS, S> DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> DiskHashMap<K, V, BS, S>
Sourcepub fn with_stores(entry_store: BS, keys_store: BS, values_store: BS) -> Self
pub fn with_stores(entry_store: BS, keys_store: BS, values_store: BS) -> Self
Creates a new HashMap with the given backing stores
Sourcepub fn load_factor(&self) -> f64
pub fn load_factor(&self) -> f64
Returns the load factor of the map (size / capacity)
pub fn stats(&self) -> (u64, u64, u64)
Source§impl<K: for<'a> BytesEncode<'a>, V: for<'a> BytesEncode<'a> + for<'a> BytesDecode<'a>, BS: ByteStore, S: BuildHasher + Default> DiskHashMap<K, V, BS, S>
impl<K: for<'a> BytesEncode<'a>, V: for<'a> BytesEncode<'a> + for<'a> BytesDecode<'a>, BS: ByteStore, S: BuildHasher + Default> DiskHashMap<K, V, BS, S>
Sourcepub fn insert<'a>(
&'a mut self,
key: &'a <K as BytesEncode<'a>>::EItem,
value: &'a <V as BytesEncode<'a>>::EItem,
) -> Result<Option<<V as BytesDecode<'a>>::DItem>, Box<dyn Error + Sync + Send>>
pub fn insert<'a>( &'a mut self, key: &'a <K as BytesEncode<'a>>::EItem, value: &'a <V as BytesEncode<'a>>::EItem, ) -> Result<Option<<V as BytesDecode<'a>>::DItem>, Box<dyn Error + Sync + Send>>
Insert a key-value pair into the map using the trait-based API
Sourcepub fn get<'a>(
&self,
key: &'a <K as BytesEncode<'a>>::EItem,
) -> Result<Option<<V as BytesDecode<'_>>::DItem>, Box<dyn Error + Sync + Send>>
pub fn get<'a>( &self, key: &'a <K as BytesEncode<'a>>::EItem, ) -> Result<Option<<V as BytesDecode<'_>>::DItem>, Box<dyn Error + Sync + Send>>
Get a value by key using the trait-based API
Sourcepub fn entry<'a>(
&'a mut self,
key: &'a <K as BytesEncode<'a>>::EItem,
) -> Result<MapEntry<'a, K, V, BS, S>, Box<dyn Error + Sync + Send>>where
for<'b> K: BytesEncode<'b>,
for<'b> V: BytesDecode<'b>,
pub fn entry<'a>(
&'a mut self,
key: &'a <K as BytesEncode<'a>>::EItem,
) -> Result<MapEntry<'a, K, V, BS, S>, Box<dyn Error + Sync + Send>>where
for<'b> K: BytesEncode<'b>,
for<'b> V: BytesDecode<'b>,
Get an entry for the given key using trait-based API
Source§impl<K, V> DiskHashMap<K, V, VecStore, FxBuildHasher>
impl<K, V> DiskHashMap<K, V, VecStore, FxBuildHasher>
Source§impl<K, V, S> DiskHashMap<K, V, MMapFile, S>where
S: BuildHasher + Default,
impl<K, V, S> DiskHashMap<K, V, MMapFile, S>where
S: BuildHasher + Default,
pub fn new_in(path: &Path) -> Result<Self>
Sourcepub fn with_capacity(
path: impl AsRef<Path>,
num_entries: usize,
keys_bytes: usize,
values_bytes: usize,
) -> Result<Self>
pub fn with_capacity( path: impl AsRef<Path>, num_entries: usize, keys_bytes: usize, values_bytes: usize, ) -> Result<Self>
Creates a new HashMap with specified capacities, rounding up to nearest power of 2
pub fn load_from(path: &Path) -> Result<Self>
Trait Implementations§
Source§impl<K, V> Default for DiskHashMap<K, V, VecStore, FxBuildHasher>
impl<K, V> Default for DiskHashMap<K, V, VecStore, FxBuildHasher>
Auto Trait Implementations§
impl<K, V, BS, S> Freeze for DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> RefUnwindSafe for DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> Send for DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> Sync for DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> Unpin for DiskHashMap<K, V, BS, S>
impl<K, V, BS, S> UnwindSafe for DiskHashMap<K, V, BS, S>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.