Skip to main content

Crate kevy_map

Crate kevy_map 

Source
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:

  1. Bucket-address API (KevyMap::prefetch_for_hash) — lets the command-batch driver prefetch the next command’s metadata group while finishing the current one.
  2. No DoS-hardening tax — single trust domain ⇒ no random seed. Hasher is kevy_hash::KevyHash (one-call inlinable).
  3. 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§

IntoIter
(K, V) iterator that consumes a KevyMap; order unspecified. Entries not yet yielded are dropped with the iterator.
Iter
(&K, &V) iterator over all live entries of a KevyMap; order unspecified.
IterMut
(&K, &mut V) iterator over all live entries of a KevyMap; 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 over KevyMap<K, ()>.
Keys
&K iterator over all live entries of a KevyMap.
RawOccupiedEntryMut
Handle to an existing entry, returned by RawEntryMut::Occupied.
RawVacantEntryMut
Handle to an absent entry, returned by RawEntryMut::Vacant.
SetIntoIter
K iterator that consumes a KevySet; order unspecified.
SetIter
&K iterator over all members of a KevySet; order unspecified.
Values
&V iterator over all live entries of a KevyMap.

Enums§

RawEntryMut
Result of KevyMap::raw_entry_mut.

Traits§

KevyHash
Single-call hashing for kevy’s per-command hot path.

Functions§

malloc_footprint
Bytes a block of size requested bytes occupies in glibc’s malloc: a chunk of 16-byte granules that carries an 8-byte size header, 32 bytes at the least. 0 for 0 — nothing is allocated.