db/datastruct/btindex: simplify interpolation search#21799
Open
AskAlexSharov wants to merge 1 commit into
Open
db/datastruct/btindex: simplify interpolation search#21799AskAlexSharov wants to merge 1 commit into
AskAlexSharov wants to merge 1 commit into
Conversation
- break on BtInterpBudget exhaustion; binary search falls through to the existing loop below - donate kmBuf to klo/khi instead of two separate copy buffers (zero-copy bound updates) - cache b.offt.Get(m) before g.Reset to avoid double EF lookup on key match - remove redundant f<0/f>1 guards in interpMid; m-clamp at end is sufficient - u64At: delegate to common.BytesToUint64 instead of a manual loop+buffer - trim BtInterp var comment to one sentence
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.
Simplification pass on #21794.
breakonBtInterpBudgetexhaustion; the existing binary-search loop below already handles the remaining window, so them=(l+r)>>1branch inside the interp loop was dead work.kmBuftoklo/khiinstead ofappend-copying into two separatekloBuf/khiBufbuffers. Since exactly one bound is updated per probe, one scratch buffer is enough; settingkmBuf = nilafter donating lets the nextg.Nextallocate fresh without touching the donated slice.off := b.offt.Get(m)beforeg.Reset(off)to avoid a second Elias-Fano lookup on key match.f < 0 / f > 1guards ininterpMid: givenklo ≤ key ≤ khiandhi > a, the fraction is always in[0,1]; them-clamp at the end is the correct guard.u64At: delegate tocommon.BytesToUint64(k[p:])(already imported) instead of a manual loop +[8]bytebuffer.BtInterpvar comment to one sentence per style guide.