MassMapInner

Struct MassMapInner 

Source
pub struct MassMapInner<R: MassMapReader, H: MassMapHashLoader = MassMapDefaultHashLoader> {
    pub header: MassMapHeader,
    pub meta: MassMapMeta,
    /* private fields */
}
Expand description

Immutable hash map backed by a serialized massmap file.

A MassMap is created from a MassMapReader (typically a file) and provides low-latency lookups without loading the whole dataset into memory. Keys and values are deserialized on demand using serde and MessagePack.

§Type Parameters

  • K: key type stored in the map; must implement serde::Deserialize.
  • V: value type stored in the map; must implement serde::Deserialize and Clone.
  • R: reader that satisfies MassMapReader.
  • H: hash loader used to reconstruct the BuildHasher from the persisted MassMapHashConfig.

Fields§

§header: MassMapHeader

Header serialized at the start of the massmap file.

§meta: MassMapMeta

Metadata describing the layout and hashing strategy of the backing file.

Implementations§

Source§

impl<R: MassMapReader, H: MassMapHashLoader> MassMapInner<R, H>

Source

pub fn load(reader: R) -> Result<Self>

Constructs an untyped massmap from a MassMapReader implementation.

The method validates the leading header (magic number, metadata offset and length) and deserializes MassMapMeta. Any IO or deserialization errors are forwarded to the caller.

Source

pub fn len(&self) -> u64

Returns the number of entries written into this map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no entries.

Source

pub fn info(&self) -> MassMapInfo

Returns information about the map’s structure and contents.

Source

pub fn cast<K, V>(self) -> MassMap<K, V, R, H>
where K: for<'de> Deserialize<'de> + Eq + Hash, V: for<'de> Deserialize<'de> + Clone,

Casts this untyped massmap into a typed view with the specified key and value types.

Trait Implementations§

Source§

impl<R: Debug + MassMapReader, H: Debug + MassMapHashLoader> Debug for MassMapInner<R, H>
where H::BuildHasher: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R, H> Freeze for MassMapInner<R, H>

§

impl<R, H> RefUnwindSafe for MassMapInner<R, H>

§

impl<R, H> Send for MassMapInner<R, H>

§

impl<R, H> Sync for MassMapInner<R, H>

§

impl<R, H> Unpin for MassMapInner<R, H>

§

impl<R, H> UnwindSafe for MassMapInner<R, H>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.