Repository navigation
roaring64: document BSI width and MaxValue/MinValue, test Add past int64 - #611
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:GetBigValuethen returns the sum, whileGetValuepanics. The width never shrinks, even if the values later get smaller. A column missing on one side counts as zero, andIncrementgives the value 1 to a column infoundSetthat has no value.MaxValue/MinValue: they record the bounds given toNewBSI. They choose the initial width and whetherSetValuemay widen the BSI (it may only when both are zero). No query reads them, andAdd/Incrementdo not update them.NewBSI: the old comment saidCompareValue,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, andSetValuesilently truncates a value that does not fit.Tests
TestAddWidth:NewBSI(1000, -1000)keeps its width when the sum fits, and is widened when it does not.MaxValue/MinValueare unchanged.TestAddPastInt64:MaxInt64 + 1,MaxInt64 + MaxInt64,MinInt64 - 1andMinInt64 + MinInt64give the exactGetBigValue, andGetValuepanics.IncrementAllonMaxInt64.-1back makes the value readable as an int64 again.