MrFlap commented on code in PR #15952:
URL: https://github.com/apache/lucene/pull/15952#discussion_r3095254794


##########
lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java:
##########
@@ -96,18 +107,22 @@ public final void merge(MergeState mergeState) throws 
IOException {
       }
     }
 
-    for (FieldInfo fieldInfo : mergeState.mergeFieldInfos) {
-      if (fieldInfo.hasVectorValues()) {
-        if (mergeState.infoStream.isEnabled("VV")) {
-          mergeState.infoStream.message("VV", "merging " + 
mergeState.segmentInfo);
-        }
+    try {
+      for (FieldInfo fieldInfo : mergeState.mergeFieldInfos) {
+        if (fieldInfo.hasVectorValues()) {
+          if (mergeState.infoStream.isEnabled("VV")) {
+            mergeState.infoStream.message("VV", "merging " + 
mergeState.segmentInfo);
+          }
 
-        mergeOneField(fieldInfo, mergeState);
+          mergeOneField(fieldInfo, mergeState);
 
-        if (mergeState.infoStream.isEnabled("VV")) {
-          mergeState.infoStream.message("VV", "merge done " + 
mergeState.segmentInfo);
+          if (mergeState.infoStream.isEnabled("VV")) {
+            mergeState.infoStream.message("VV", "merge done " + 
mergeState.segmentInfo);
+          }
         }
       }
+    } finally {
+      afterMerge();
     }
     finish();

Review Comment:
   We would like to manage the threads in `PerFieldKnnVectorsFormat`, which 
doesn't get a callback once `KnnVectorsWriter.finish()` happens. Also, the 
suggested `afterMerge()` runs in a finally block, so we can be sure to close 
out the threads even on exception.



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