lookup method
Looks key up, returning null when absent.
A hit distinguishes a live document from a tombstone.
Implementation
({bool tombstone, DocView? document})? lookup(Uint8List key) {
if (!_bloom.mightContain(key)) return null;
var low = 0;
var high = _indexCount - 1;
while (low <= high) {
final middle = (low + high) >> 1;
final comparison = _compareEntry(middle, key);
if (comparison < 0) {
low = middle + 1;
} else if (comparison > 0) {
high = middle - 1;
} else {
final docOffset = VxsLe.u32(
buffer,
_entryStart(middle) + 2 + _keyLength(middle),
);
if (docOffset == segmentTombstone) {
return (tombstone: true, document: null);
}
verifyBlockFor(docOffset);
return (
tombstone: false,
document: DocView.parse(buffer, docOffset, end - docOffset),
);
}
}
return null;
}