get method

Future<Bytes?> get(
  1. Uint8List key
)

Reads key, or null. Fetches a segment object on a cache miss.

Implementation

Future<Bytes?> get(Uint8List key) async {
  final ref = _memtable.get(key);
  if (ref != null) {
    return ref.length < 0
        ? null
        : _arena.view(ref.chunk, ref.offset, ref.length);
  }
  for (var i = _segmentInfos.length - 1; i >= 0; i--) {
    final reader = await _readerAt(i);
    final hit = reader.lookup(key);
    if (hit == null) continue;
    return hit.tombstone ? null : hit.document?.toBytes();
  }
  return null;
}