Add FlatFieldVectorsWriter#asKnnVectorValues#16062
Open
ldematte wants to merge 5 commits into
Open
Conversation
ChrisHegarty
approved these changes
May 13, 2026
Contributor
ChrisHegarty
left a comment
There was a problem hiding this comment.
Nice! LGTM. I'm going to label this for milestone 10.5, so a changes entry can be added there for it.
benwtrent
approved these changes
May 14, 2026
Member
benwtrent
left a comment
There was a problem hiding this comment.
it seems like a natural improvement to the API, I like it.
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.
FlatFieldVectorsWriter<T>exposes its accumulated vectors viaList<T> getVectors().This is both too generic and too prescriptive:
List<T>binds the return type to specific vector representation (T = float[] / byte[]heap arrays, one vector per list element); if aFlatFieldVectorsWriterimplementation is backed by a different data structure (off-heap / paged / memory-mapped storage), it has to materialize a heap array even when the downstream consumer would be happy with a non-materialized view.KnnVectorValuesto feed the scoring / graph-building path (see e.g.Lucene99HnswVectorsWriter.FieldWriter).This PR proposes to move this step directly to
FlatFieldVectorsWriter<T>, exposing its vectors also asKnnVectorValues.Why
KnnVectorValues?KnnVectorValuesis the shape current callers (e.g. scorers) actually use. This PR updatesLucene99HnswVectorsWriterto use the new function when it callsFlatVectorsScorer.getRandomVectorScorerSupplier, which already takesKnnVectorValues.No new Lucene type is needed; an alternative would be to introduce a new Lucene interface (e.g.
FlatVectorsView). That would be very similar toKnnVectorValueswith minor variations.