Add ReturnFieldsRetriever: concurrent scatter/gather utility for per-hit return fields - #16572
Open
zihanx wants to merge 4 commits into
Open
Add ReturnFieldsRetriever: concurrent scatter/gather utility for per-hit return fields#16572zihanx wants to merge 4 commits into
zihanx wants to merge 4 commits into
Conversation
added 2 commits
August 27, 2026 15:13
…-hit return fields, plus a DoubleValuesSource specialization (DoubleValuesRetriever).
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.
Description
Adds a reusable utility for fetching "return fields" — one value per hit for a set of
global doc IDs — concurrently across leaves, returning results 1:1 in the caller's input
order. This is the follow-up to the
ReaderUtil.partitionByLeafscatter/gather API#16496; it builds the retriever the ordinal tracking was designed for.
Motivation
Fetching field values for a page of hits (in ranking order) is a common need, and getting
the leaf partitioning + concurrency + input-order reassembly right is tricky and easy to
get subtly wrong. Today callers hand-roll this. This packages it once.
What's included
Two classes:
ReturnFieldsRetriever— the generic engine. Owns only the reusable machinery:scatter doc IDs to leaves via
ReaderUtil.partitionByLeaf, run each leaf as anindependent task on a supplied
Executor(viaTaskExecutor), and gather per-leafresults back into input order. It is agnostic about what is produced per hit: the
caller supplies a
LeafVisitorFactory<T>that turns a document into a value of typeT.DoubleValuesRetriever— a thinDoubleValuesSource-specific specialization builton the engine. Adapts each source to a
LeafVisitor<double[]>:Design notes
newLeafVisitoris called once perleaf and must return a fresh, single-threaded visitor. Each leaf writes disjoint slots of the result array,
so no synchronization is needed.
result[i]is the value forglobalDocIds[i]. The inputarray is not mutated.