pub struct AHashMapStore { /* private fields */ }Expand description
High-performance state store using AHashMap for point lookups and
BTreeMap for ordered scans.
This dual-structure design provides:
- O(1) point lookups (vs O(log n) for
InMemoryStore) - Zero-copy reads via
get_ref - Same O(log n + k) scan performance as
InMemoryStore
Trade-off: ~2x memory for keys (stored in both maps) and slightly slower writes due to dual-map maintenance.
Implementations§
Source§impl AHashMapStore
impl AHashMapStore
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new store with pre-allocated capacity for the hash map.
Trait Implementations§
Source§impl Default for AHashMapStore
impl Default for AHashMapStore
Source§impl StateStore for AHashMapStore
impl StateStore for AHashMapStore
Source§fn get_ref(&self, key: &[u8]) -> Option<&[u8]>
fn get_ref(&self, key: &[u8]) -> Option<&[u8]>
Get a zero-copy reference to a value by key. Read more
Source§fn put(&mut self, key: &[u8], value: Bytes) -> Result<(), StateError>
fn put(&mut self, key: &[u8], value: Bytes) -> Result<(), StateError>
Store a key-value pair. Read more
Source§fn prefix_scan<'a>(
&'a self,
prefix: &'a [u8],
) -> Box<dyn Iterator<Item = (Bytes, Bytes)> + 'a>
fn prefix_scan<'a>( &'a self, prefix: &'a [u8], ) -> Box<dyn Iterator<Item = (Bytes, Bytes)> + 'a>
Scan all keys with a given prefix. Read more
Source§fn range_scan<'a>(
&'a self,
range: Range<&'a [u8]>,
) -> Box<dyn Iterator<Item = (Bytes, Bytes)> + 'a>
fn range_scan<'a>( &'a self, range: Range<&'a [u8]>, ) -> Box<dyn Iterator<Item = (Bytes, Bytes)> + 'a>
Range scan between two keys (exclusive end). Read more
Source§fn size_bytes(&self) -> usize
fn size_bytes(&self) -> usize
Get approximate size in bytes. Read more
Source§fn snapshot(&self) -> StateSnapshot
fn snapshot(&self) -> StateSnapshot
Create a snapshot for checkpointing. Read more
Source§fn restore(&mut self, snapshot: StateSnapshot)
fn restore(&mut self, snapshot: StateSnapshot)
Restore from a snapshot. Read more
Source§fn flush(&mut self) -> Result<(), StateError>
fn flush(&mut self) -> Result<(), StateError>
Flush any pending writes to durable storage. Read more
Source§fn get_or_insert(
&mut self,
key: &[u8],
default: &[u8],
) -> Result<Bytes, StateError>
fn get_or_insert( &mut self, key: &[u8], default: &[u8], ) -> Result<Bytes, StateError>
Get a value or insert a default. Read more
Auto Trait Implementations§
impl Freeze for AHashMapStore
impl RefUnwindSafe for AHashMapStore
impl Send for AHashMapStore
impl Sync for AHashMapStore
impl Unpin for AHashMapStore
impl UnsafeUnpin for AHashMapStore
impl UnwindSafe for AHashMapStore
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Scope for T
impl<T> Scope for T
Source§impl<T> StateStoreExt for Twhere
T: StateStore + ?Sized,
impl<T> StateStoreExt for Twhere
T: StateStore + ?Sized,
Source§fn get_typed<T>(&self, key: &[u8]) -> Result<Option<T>, StateError>where
T: Archive,
T::Archived: for<'a> CheckBytes<HighValidator<'a, RkyvError>> + RkyvDeserialize<T, HighDeserializer<RkyvError>>,
fn get_typed<T>(&self, key: &[u8]) -> Result<Option<T>, StateError>where
T: Archive,
T::Archived: for<'a> CheckBytes<HighValidator<'a, RkyvError>> + RkyvDeserialize<T, HighDeserializer<RkyvError>>,
Get a value and deserialize it using rkyv. Read more