Skip to content

Commit 00ee8ae

Browse files
committed
fix: off-by-one in runContainer16.getCardinalityInRange for intra-container gaps
When the query range falls entirely in a gap between two run intervals within the same container, the early-return guard "lastIdx < firstIdx-1" misses the case where lastIdx == firstIdx-1, causing the next interval (outside the query range) to be counted. Fix: change the condition to "lastIdx < firstIdx".
1 parent fcd24ee commit 00ee8ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

runcontainer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ func (rc *runContainer16) getCardinalityInRange(start, end uint) int {
25432543
if firstIdx >= len(rc.iv) {
25442544
return 0
25452545
}
2546-
if lastIdx < 0 || lastIdx < firstIdx-1 {
2546+
if lastIdx < 0 || lastIdx < firstIdx {
25472547
return 0
25482548
}
25492549

0 commit comments

Comments
 (0)