Expand description
kevy-map — a purpose-built open-addressing hashtable for kevy’s keyspace.
Per-shard, single-threaded, single-trust-domain. Trades std::HashMap’s
generality for three kevy-specific wins:
- Bucket-address API (
KevyMap::prefetch_for_hash) — lets the command-batch driver prefetch the next command’s metadata group while finishing the current one. - No DoS-hardening tax — single trust domain ⇒ no random seed.
Hasher is
kevy_hash::KevyHash(one-call inlinable). - Cache-conscious layout — Swiss-style metadata bytes scanned 16 at a time (SSE2 / NEON, scalar elsewhere); slots AoS so the post-match key+value read hits one cache line.
use kevy_map::{KevyMap, KevySet};
let mut m: KevyMap<Vec<u8>, u64> = KevyMap::new();
m.insert(b"user:1".to_vec(), 7);
// borrowed lookup: a byte slice finds a Vec<u8> key without allocating
assert_eq!(m.get(b"user:1".as_slice()), Some(&7));
let s: KevySet<u64> = [3, 1, 3].into_iter().collect();
assert_eq!(s.len(), 2);See the crate README for the design rationale.
Constraints: pure Rust, no crates.io deps; unsafe is allowed here (scoped
to this crate) so kevy-store keeps forbid(unsafe_code).
Structs§
- Into
Iter (K, V)iterator that consumes aKevyMap; order unspecified. Entries not yet yielded are dropped with the iterator.- Iter
(&K, &V)iterator over all live entries of aKevyMap; order unspecified.- IterMut
(&K, &mut V)iterator over all live entries of aKevyMap; order unspecified. Keys stay shared — mutating a key would corrupt its bucket.- KevyMap
- An open-addressing Swiss-style hashtable keyed by
KevyHash. - KevySet
HashSet-shaped wrapper overKevyMap<K, ()>.- Keys
&Kiterator over all live entries of aKevyMap.- RawOccupied
Entry Mut - Handle to an existing entry, returned by
RawEntryMut::Occupied. - RawVacant
Entry Mut - Handle to an absent entry, returned by
RawEntryMut::Vacant. - SetInto
Iter Kiterator that consumes aKevySet; order unspecified.- SetIter
&Kiterator over all members of aKevySet; order unspecified.- Values
&Viterator over all live entries of aKevyMap.
Enums§
- RawEntry
Mut - Result of
KevyMap::raw_entry_mut.
Traits§
- Kevy
Hash - Single-call hashing for kevy’s per-command hot path.
Functions§
- malloc_
footprint - Bytes a block of
sizerequested bytes occupies in glibc’smalloc: a chunk of 16-byte granules that carries an 8-byte size header, 32 bytes at the least. 0 for 0 — nothing is allocated.