Skip to main content

Crate blazinterner

Crate blazinterner 

Source
Expand description

This crate offers an efficient and concurrent interning API over generic data.

Here are its main features.

  • Generic: You can intern any data type that implements Hash and Eq, not just strings. The interned type doesn’t even have to be Sized (for example str), as long as you provide a Sized storage type (such as Box<str>) that can be borrowed as the interned type.
  • Efficient: Each Interned value contains only a 32-bit index. The corresponding Arena stores each value directly in an AppendVec, plus the 32-bit index in a raw hash table (DashTable). To intern a value of type T using storage type S, you can pass any type that implements Borrow<T> and Into<S>, which allows avoiding unnecessary copies. For example, in an Arena<str, Box<str>> you can intern many string types: &str, String, Box<str>, Cow<'_, str>, etc.
  • Concurrent: The Arena is Sync, and allows simultaneous reads and writes. More specifically, retrieving values via Arena::lookup() and Arena::lookup_ref() is always wait-free, even when a write happens concurrently! This is thanks to the underlying AppendVec implementation. However, only one write (using Arena::intern()) can happen at a time on a given arena, due to an exclusive write lock.

Structs§

Arena
Interning arena for values of type T, storing them with the given Storage type (that needs to be Sized).
ArenaSlice
Interning arena for slices of type T.
ArenaStr
Interning arena for strings.
DeltaEncodingdelta
Wrapper around an Arena or ArenaSlice that uses the given Accumulator to serialize it with delta encoding.
ExtendArenaserde
Wrapper to extend an Arena incrementally, typically by deserializing a sequence of serialized SnapshotDiff.
ExtendArenaSliceserde
Wrapper to extend an ArenaSlice incrementally, typically by deserializing a sequence of serialized SnapshotSliceDiff.
ExtendArenaStrserde
Wrapper to extend an ArenaStr incrementally, typically by deserializing a sequence of serialized SnapshotStrDiff.
ForwardMapping
A mapping to re-order items in an Arena, ArenaSlice or ArenaStr.
Interned
A handle to an interned value in an Arena.
InternedSlice
A handle to an interned value in an ArenaSlice.
InternedStr
A handle to an interned value in an ArenaStr.
Mapping
A mapping to re-order items in an Arena, ArenaSlice or ArenaStr.
RetainBuilderretain
A builder to select items to retain in an Arena.
RetainSliceBuilderretain
A builder to select items to retain in an ArenaSlice.
RetainStrBuilderretain
A builder to select items to retain in an ArenaStr.
ReverseMapping
A mapping to re-order items in an Arena, ArenaSlice or ArenaStr.
Snapshot
Snapshot of an Arena.
SnapshotDiffserde
Difference between two snapshots of an Arena.
SnapshotMark
A mark indicates the position of a Snapshot in an Arena.
SnapshotSlice
Snapshot of an ArenaSlice.
SnapshotSliceDiffserde
Difference between two snapshots of an ArenaSlice.
SnapshotSliceMark
A mark indicates the position of a SnapshotSlice in an ArenaSlice.
SnapshotStr
Snapshot of an ArenaStr.
SnapshotStrDiffserde
Difference between two snapshots of an ArenaStr.
SnapshotStrMark
A mark indicates the position of a SnapshotStr in an ArenaStr.
U16
A 16-bit index (2 bytes). Contrary to u16, this type has an alignment of 1.
U24
A 24-bit index (3 bytes).
U32
A 32-bit index (4 bytes). Contrary to u32, this type has an alignment of 1.
U40
A 40-bit index (5 bytes).
U48
A 48-bit index (6 bytes).
U56
A 56-bit index (7 bytes).
U64
A 64-bit index (8 bytes). Contrary to u64, this type has an alignment of 1.

Traits§

Accumulatordelta
Helper trait for delta-encoding of interned values.
Index
Interface to index values in an arena.

Type Aliases§

DefaultBuildHasherstd
The default BuildHasher used in this crate.
HashbrownBuildHasher
The default BuildHasher from the hashbrown crate.
StdBuildHasherstd
The default BuildHasher from the standard library.