MemTable class final
In-memory table of key -> value reference.
Open addressing with linear probing, one fixed arena for keys and parallel
32-bit arrays for the entries. Measured ~2.2x faster than
HashMap<Key, int> for both inserts and lookups, mostly because it avoids
allocating a key wrapper per operation.
The table does not compare values and does not keep keys ordered: flushing sorts entries once, and the segment index does the ordering afterwards.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyBytes → int
-
Bytes currently used by keys (values live elsewhere).
no setter
- length → int
-
Number of live entries, tombstones included.
no setter
- memoryBytes → int
-
Rough heap footprint of the table itself.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Drops every entry while keeping the allocated capacity.
-
contains(
Uint8List key) → bool -
Whether
keyis present (tombstones count as present). -
forEachRange(
Uint8List? lower, Uint8List? upper, void visit(Uint8List key, int chunk, int offset, int length), {bool includeLower = true, bool includeUpper = false}) → void -
Visits entries whose key is in
[lower, upper)in ascending key order. -
forEachSorted(
void visit(Uint8List key, int chunk, int offset, int length)) → void - Visits every entry in ascending key order.
-
get(
Uint8List key) → MemRef? -
Looks
keyup, returningnullwhen absent. -
keyAt(
int index) → Uint8List -
A zero-copy view of the key at entry
index(insertion order). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
Uint8List key, int chunk, int offset, int length) → void -
Inserts or replaces
keywith a reference tochunk/offset/length. -
putTombstone(
Uint8List key) → void -
Records that
keywas deleted. -
refAt(
int index) → MemRef -
Reference of entry
index(insertion order). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited