get method

MemRef? get(
  1. Uint8List key
)

Looks key up, returning null when absent.

A record with a negative length is a tombstone.

Implementation

MemRef? get(Uint8List key) {
  final hash = VxsCrc32c.compute(key);
  var slot = hash & (_slots.length - 1);
  while (true) {
    final entry = _slots[slot];
    if (entry == 0) return null;
    final index = entry - 1;
    if (_hashes[index] == hash &&
        _keyLengths[index] == key.length &&
        _keyEquals(index, key)) {
      return (
        chunk: _valueChunks[index],
        offset: _valueOffsets[index],
        length: _valueLengths[index],
      );
    }
    slot = (slot + 1) & (_slots.length - 1);
  }
}