iverase commented on code in PR #16696:
URL: https://github.com/apache/lucene/pull/16696#discussion_r4069097525


##########
lucene/core/src/java/org/apache/lucene/codecs/hnsw/FlatVectorsWriter.java:
##########
@@ -63,4 +66,65 @@ public final IORunnable mergeOneField(FieldInfo fieldInfo, 
MergeState mergeState
 
   public abstract void mergeOneFlatVectorField(FieldInfo fieldInfo, MergeState 
mergeState)
       throws IOException;
+
+  /**
+   * Merges one field and, while writing the merged vectors, optionally 
prepares what a merge scorer
+   * needs, so that the merged float vectors need not be read back.
+   *
+   * <p>A wrapping writer should forward this method along with {@link 
#mergeOneFlatVectorField}.
+   * Forwarding only the latter stays correct, but the wrapped writer then 
prepares nothing.
+   * Forwarding helps only when the wrapping format opens the wrapped writer's 
own reader over the
+   * merged segment. Otherwise {@link MergeScorerData#scorerSupplier} rejects 
the prepared data and
+   * the merge uses its fallback.
+   *
+   * @param fieldInfo field to merge
+   * @param mergeState merge state
+   * @param needsMergeScorer whether to prepare scorer data for a vector 
count. The writer tests
+   *     this predicate against the count before deletions, which can exceed 
the number of vectors
+   *     written.
+   * @return prepared data that the caller must close, or {@code null} if none 
was prepared, which
+   *     is what the default implementation returns and what any writer 
returns for a field it
+   *     cannot prepare for. The caller then builds the scorer itself.
+   * @throws IOException if an I/O error occurs
+   */
+  public MergeScorerData mergeOneFlatVectorFieldForMergeScorer(

Review Comment:
   I agree, this pattern is very common in Lucene APIs so for me it is ok 
having nullable return types



-- 
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