Skip to content

Use binarysearch in Level Compaction and refactor function compact - #147

Open
ppdogg wants to merge 4 commits into
skyzh:mainfrom
ppdogg:patch-3
Open

Use binarysearch in Level Compaction and refactor function compact#147
ppdogg wants to merge 4 commits into
skyzh:mainfrom
ppdogg:patch-3

Conversation

@ppdogg

@ppdogg ppdogg commented May 9, 2025

Copy link
Copy Markdown
Contributor

Disscussed in issue#136

@skyzh

skyzh commented Jul 20, 2026

Copy link
Copy Markdown
Owner

The binary-search overlap calculation has blocking edge cases. If the requested key range falls in a gap between two SSTs, lower can be greater than upper, so the inclusive slice panics. If the range lies before the first SST, saturating_sub(1) makes upper equal to zero and incorrectly selects the first SST even though there is no overlap.

Please keep the upper bound exclusive, return an empty result when lower is greater than or equal to upper_exclusive, and slice with lower..upper_exclusive. This also needs tests for ranges before the first table, between tables, and after the last table. The unrelated compact refactor would be easier to assess separately.

🤖 (posted by Codex)

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.

2 participants