Skip to content

MB-69556, MB-73584: Wand/block max - #85

Draft
capemox wants to merge 3 commits into
nextfrom
wand/block-max
Draft

capemox wants to merge 3 commits into
nextfrom
wand/block-max

Conversation

@capemox

@capemox capemox commented Sep 18, 2026

Copy link
Copy Markdown
Member

No description provided.

Mirrors the existing OptimizablePostingsIterator pattern: an optional
interface that segment implementations backed by a block-based on-disk
format (with per-block block-max metadata) can implement, and that
callers type-assert for, falling back to plain Next/Advance otherwise.

This is the API surface needed to wire zapx's bitpack-simd skip-list
block-max metadata (minNormID/maxTF, already written but unconsumed)
up into bleve's query layer for Block-Max WAND pruning.
Batch-scoring a decoded block (bleve's Block-Max WAND conjunction
path) needs a norm per candidate document; without it, scoring a
batch-decoded block would require a separate per-doc seek anyway,
defeating the point of decoding the block in one shot.
@capemox capemox self-assigned this Sep 18, 2026
The previous 5-method shape (SeekBlock/BlockMaxTF/BlockMinNormID/
NormFromID/CurrentBlock) conflated peeking a block's bound with moving
the cursor in one SeekBlock call, which forces an implementation to
invalidate its own "already positioned" fast-iteration path on every
peek -- turning every ordinary scan into a full re-seek per block, even
for blocks that were never actually skipped. It also returned
CurrentBlock's decoded arrays as iterator-owned buffers rather than
filling caller-owned ones.

Replaces it with three methods, validated by a separate, independent
implementation that measured a real 6.20x mean / 5.13x median speedup
in production: BlockMax() (a single combined peek, never moving
anything), ShallowAdvance() (the only method that moves the cursor),
and NextBlock() (a direct bulk fill of caller-supplied docNums/freqs/
norms arrays, with a globalOffset parameter so a multi-segment caller
never needs a separate translation pass).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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