Skip to content

roaring64: document BSI width and MaxValue/MinValue, test Add past int64 - #611

Merged
lemire merged 3 commits into
masterfrom
bsi64-add-docs-tests
Dec 5, 2026
Merged

lemire merged 3 commits into
masterfrom
bsi64-add-docs-tests

Conversation

@lemire

@lemire lemire commented Dec 4, 2026

Copy link
Copy Markdown
Member

Follow-up to #609. This PR only changes doc comments and tests. It is independent of #610 and merges cleanly with it; the suite passes on the merge.

Docs

  • Add / Increment: the sum is exact and signed. The BSI is widened as needed, even past 64 bits: GetBigValue then returns the sum, while GetValue panics. The width never shrinks, even if the values later get smaller. A column missing on one side counts as zero, and Increment gives the value 1 to a column in foundSet that has no value.
  • MaxValue / MinValue: they record the bounds given to NewBSI. They choose the initial width and whether SetValue may widen the BSI (it may only when both are zero). No query reads them, and Add/Increment do not update them.
  • NewBSI: the old comment said CompareValue, MinMax, etc. depend on the min/max values, but no code reads them. The new comment says what they do: with non-zero bounds the width is fixed, and SetValue silently truncates a value that does not fit.

Tests

  • TestAddWidth:
    • 100 additions of 1 leave the BSI at the width the result needs.
    • The width does not shrink afterwards.
    • A fixed-width NewBSI(1000, -1000) keeps its width when the sum fits, and is widened when it does not.
    • MaxValue/MinValue are unchanged.
  • TestAddPastInt64:
    • MaxInt64 + 1, MaxInt64 + MaxInt64, MinInt64 - 1 and MinInt64 + MinInt64 give the exact GetBigValue, and GetValue panics.
    • The same holds for IncrementAll on MaxInt64.
    • Adding -1 back makes the value readable as an int64 again.

Document that Add and Increment widen the BSI as needed, even past 64
bits, and never make it narrower, and that MaxValue and MinValue only
record the bounds given to NewBSI: they choose the initial width and
whether SetValue may widen, no query reads them, and Add and Increment
do not update them. The NewBSI comment claimed that CompareValue and
MinMax depend on them, which they do not.

Add TestAddWidth and TestAddPastInt64.
Non-zero bounds choose the initial planes and stop the setters from
growing them. Values outside that width are truncated, not clamped,
and Add can still widen the BSI.
Keep the NewBSI bounds tests and the high-key add tests.
@lemire
lemire merged commit eccbd8d into master Dec 5, 2026
13 checks passed
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.

1 participant