Skip to content

Account for per-leaf codec overhead exactly - #28

Merged
venkat1701 merged 3 commits into
mainfrom
fix/exact-leaf-accounting
Oct 4, 2026
Merged

venkat1701 merged 3 commits into
mainfrom
fix/exact-leaf-accounting

Conversation

@venkat1701

Copy link
Copy Markdown
Collaborator

Closes #14

IncidenceCodec.maxSize charged one byte per entry to cover the flags byte and the column bitmaps. For leaves under 8 entries that came up short by up to 7 bytes, and it only worked because Layout keeps a 32-byte reserve.

ValueCodec now has a leafOverhead(entries) hook (0 by default). IncidenceCodec returns 1 + columns * ceil(n / 8) and no longer adds a byte per entry. Leaf.bytes() and BulkBuilder include the overhead when deciding splits. The reserve is still there, but nothing relies on it anymore.

For large leaves the new bound is a bit tighter than before (1 + 6 * ceil(n/8) instead of n), so leaves can hold slightly more entries. The on-disk encoding doesn't change.

IncidenceCodecTest:

  • Encodes random leaves of 1 to 300 entries, with random column presence, for both codec variants, and checks the encoded size never exceeds the accounted size.
  • With every column present, checks the two are exactly equal.

Full ./mvnw install passes locally, including the crash matrix.

IncidenceCodec charged one byte per entry for its flags byte and column
bitmaps, which undercounted leaves under 8 entries and only worked because
of the layout reserve. Codecs can now declare a per-leaf overhead, and
leaf sizes and bulk building include it.
@venkat1701
venkat1701 force-pushed the fix/exact-leaf-accounting branch from abf109a to b6b94d9 Compare October 4, 2026 08:29
@venkat1701
venkat1701 merged commit 8db0e04 into main Oct 4, 2026
@venkat1701
venkat1701 deleted the fix/exact-leaf-accounting branch October 6, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make incidence leaf size accounting exact

1 participant