verifyBlockFor method
Whether the block containing docOffset has passed its CRC check.
The first access to a block computes its CRC; every later access is one bitmap lookup. Compaction goes through the same path, so a corrupt block is reported instead of being rewritten with a fresh checksum.
Implementation
void verifyBlockFor(int docOffset) {
final verified = _verifiedBlocks;
if (verified == null) return;
final index = _blockIndexFor(docOffset);
if (index < 0) {
throw VxsFormatException(
'document offset $docOffset is outside every block',
offset: docOffset,
);
}
if (verified[index >> 3] & (1 << (index & 7)) != 0) return;
final blockStart = start + VxsLe.u32(buffer, tableOffset + index * 4);
final blockEnd = index + 1 < blockCount
? start + VxsLe.u32(buffer, tableOffset + (index + 1) * 4)
: tableOffset;
// Throws VxsFormatException when the block CRC does not match.
BlockReader(buffer, offset: blockStart, length: blockEnd - blockStart);
verified[index >> 3] |= 1 << (index & 7);
}