kaivalnp commented on code in PR #16938:
URL: https://github.com/apache/lucene/pull/16938#discussion_r4517733161


##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/codecs/dedup/DedupFlatVectorsReader.java:
##########
@@ -337,21 +366,38 @@ public Float16VectorValues getFloat16VectorValues(String 
field) throws IOExcepti
   }
 
   @Override
-  public FlatVectorsReader getMergeInstance() {
-    // TODO: Can we improve performance using sequential IO + avoiding 
read-backs? One way is to
-    //  de-duplicate only within a document, allowing for cleaner sort of 
vectors during flush +
-    //  avoid read-backs for full equality checks during merge.
-    return this;
+  public FlatVectorsReader getMergeInstance() throws IOException {
+    // vectors are stored in doc order and merged front to back, so read them 
sequentially
+    IndexInput data = original.mergeVectorData();
+    return data == vectorData ? this : new DedupFlatVectorsReader(this, 
data.clone());
   }
 
-  @Override
-  public void finishMerge() {
-    // TODO: Converse of getMergeInstance()
+  /** Returns the input for merges, opening the data file again if needed. */
+  private synchronized IndexInput mergeVectorData() throws IOException {
+    assert original == this;
+    if (closed) {

Review Comment:
   Ah nice catch, I was working on an older branch where the flat vector format 
used the `if(closed)` pattern, before it was updated to `ensureOpen()` in 
https://github.com/apache/lucene/commit/49483e82b35775c4d3df15cea736c0247fd57400.
   
   I'll try to mimic the current state in the next commit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to