add method
Adds one document under key.
Keys are capped at 65535 bytes: the segment index stores the key length in
a u16, and silently truncating it would corrupt the index.
Implementation
void add(Uint8List key, Bytes document) {
_checkKeyLength(key);
if (_block == null) {
_block = BlockWriter(targetSize: blockTargetSize);
_blockBase = _blocks.length;
}
final relative = _block!.append(document);
_keys.add(Uint8List.fromList(key));
_docOffsets.add(
segmentHeaderSize + _blockBase + blockHeaderSize + relative,
);
_docCount++;
if (_block!.isFull) {
_finishBlock();
}
}