[ 
https://issues.apache.org/jira/browse/LUCENE-9583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17222399#comment-17222399
 ] 

Michael Sokolov commented on LUCENE-9583:
-----------------------------------------

Thanks Jim, I think that approach could be workable. But it does overlook that 
the random access API now in 9.0  is defined in terms of dense *ordinals* not 
(possibly sparse) *docIds*. And I do think that there will have been some 
non-negligible savings from a simple call of {{vectorValue(int ordinal)}} as 
oppose to: {{advance(int docID)}} {{vectorValue()}} (and occasionally 
{{reset()}}, especially given that advancing by docID will have to at some 
point make use of the docID/ordinal mapping. (Aside: if we impose this 
forward-only-iterator constraint, we could very well stick with 
{{BinaryDocValues}} and dispense with this format altogether, as my original 
patch had done (when I got the opposite comment - that we should add a new 
format that supports random access :).

Still, maybe the savings is not so great? Maybe encoding docID in the graph is 
workable and we don't pay too much lookup cost switching back and forth between 
docIDs and ordinals? Maybe we benefit from not using random access in some way 
that I don't fully grok? Having said that, I think it would be clearer if we 
could get the graph implementation committed; then we could assess the impact 
more clearly, rather than trying to determine it in a theoretical vein. So I 
would propose revisiting this once LUCENE-9004 lands.

> How should we expose VectorValues.RandomAccess?
> -----------------------------------------------
>
>                 Key: LUCENE-9583
>                 URL: https://issues.apache.org/jira/browse/LUCENE-9583
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Michael Sokolov
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> In the newly-added {{VectorValues}} API, we have a {{RandomAccess}} 
> sub-interface. [~jtibshirani] pointed out this is not needed by some 
> vector-indexing strategies which can operate solely using a forward-iterator 
> (it is needed by HNSW), and so in the interest of simplifying the public API 
> we should not expose this internal detail (which by the way surfaces internal 
> ordinals that are somewhat uninteresting outside the random access API).
> I looked into how to move this inside the HNSW-specific code and remembered 
> that we do also currently make use of the RA API when merging vector fields 
> over sorted indexes. Without it, we would need to load all vectors into RAM  
> while flushing/merging, as we currently do in 
> {{BinaryDocValuesWriter.BinaryDVs}}. I wonder if it's worth paying this cost 
> for the simpler API.
> Another thing I noticed while reviewing this is that I moved the KNN 
> {{search(float[] target, int topK, int fanout)}} method from {{VectorValues}} 
>  to {{VectorValues.RandomAccess}}. This I think we could move back, and 
> handle the HNSW requirements for search elsewhere. I wonder if that would 
> alleviate the major concern here? 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to