pub struct ParcodeMapPromise<'a, K, V> { /* private fields */ }Expand description
A promise for a HashMap that supports lazy loading and efficient lookups.
This type wraps a ChunkNode representing a HashMap and provides methods to:
- Load the entire map into memory
- Perform O(1) lookups by key without loading the entire map
Implementations§
Source§impl<'a, K, V> ParcodeMapPromise<'a, K, V>
impl<'a, K, V> ParcodeMapPromise<'a, K, V>
Sourcepub fn load(&self) -> Result<HashMap<K, V>>
pub fn load(&self) -> Result<HashMap<K, V>>
Loads the full map by iterating all shards.
This reconstructs the entire HashMap in memory by:
- Reading the number of shards from the container
- Iterating over each shard and deserializing its entries
- Merging all entries into a single
HashMap
Sourcepub fn get(&self, key: &K) -> Result<Option<V>>
pub fn get(&self, key: &K) -> Result<Option<V>>
Performs a fast lookup for a single key without loading the entire map.
This method:
- Computes the hash of the key
- Determines which shard contains the key (via modulo)
- Loads only that shard
- Scans the shard’s hash array for matches
- Verifies the key on hash collision and returns the value
§Performance
- O(1) shard selection
- O(N/S) linear scan within shard (where S = number of shards)
- SIMD-optimized hash comparison on supported platforms
Source§impl<'a, K, V> ParcodeMapPromise<'a, K, V>where
K: Hash + Eq + DeserializeOwned + Send + Sync + 'static,
V: ParcodeItem + Send + Sync + ParcodeLazyRef<'a> + 'a,
impl<'a, K, V> ParcodeMapPromise<'a, K, V>where
K: Hash + Eq + DeserializeOwned + Send + Sync + 'static,
V: ParcodeItem + Send + Sync + ParcodeLazyRef<'a> + 'a,
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, V> Freeze for ParcodeMapPromise<'a, K, V>
impl<'a, K, V> !RefUnwindSafe for ParcodeMapPromise<'a, K, V>
impl<'a, K, V> Send for ParcodeMapPromise<'a, K, V>
impl<'a, K, V> Sync for ParcodeMapPromise<'a, K, V>
impl<'a, K, V> Unpin for ParcodeMapPromise<'a, K, V>
impl<'a, K, V> !UnwindSafe for ParcodeMapPromise<'a, K, V>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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