Skip to content

Make array Validate require strictly increasing values - #545

Merged
lemire merged 2 commits into
masterfrom
fix-validate-strictly-increasing
Aug 11, 2026
Merged

Make array Validate require strictly increasing values#545
lemire merged 2 commits into
masterfrom
fix-validate-strictly-increasing

Conversation

@lemire

@lemire lemire commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Array container validate() previously checked previous > next, which allowed adjacent duplicate values.
  • CRoaring, Java, and Rust all require strictly increasing values and reject with previous >= next.
  • This aligns Go's Validate with the other implementations and adds unit/deserialization tests that construct adjacent duplicates and expect ErrArrayIncorrectSort.

Context

Reported while working on another kernel: Go's validator was the outlier for array containers. Keys in roaringarray already used previous >= next; only array content used the looser comparison.

Test plan

  • go test -count=1 -run 'TestArrayContainerValidation|TestBitMapValidationFromDeserialization' .
  • go test -count=1 ./...
  • New case: adjacent duplicates in arrayContainer.validate() return ErrArrayIncorrectSort
  • New deserialization corruption case: duplicate array values rejected by Validate / MustReadFrom

lemire added 2 commits August 11, 2026 11:21
Array container validation previously used previous > next, which
allowed adjacent duplicates. CRoaring, Java, and Rust all require
strictly increasing values (previous >= next). Align Go with them and
add tests covering adjacent-duplicate rejection.
@lemire
lemire merged commit 4088a42 into master Aug 11, 2026
14 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