romseygeek commented on code in PR #16086:
URL: https://github.com/apache/lucene/pull/16086#discussion_r3267603146


##########
lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:
##########
@@ -5284,6 +5293,14 @@ public int length() {
         }
       }
 
+      final MergePolicy.AbortChecker mergeAbortChecker;

Review Comment:
   Maybe add a factory method that takes a OneMerge and a check interval and 
returns NO_OP if the interval is 0?



##########
lucene/core/src/java/org/apache/lucene/index/MergePolicy.java:
##########
@@ -570,6 +570,37 @@ public MergeException(Throwable exc) {
     }
   }
 
+  /**
+   * Interface for checking whether a merge has been aborted. Implementations 
should throw {@link
+   * MergeAbortedException} if the merge should stop.
+   *
+   * @lucene.experimental
+   */
+  public static final class AbortChecker {
+
+    /** A no-op checker */
+    public static final AbortChecker NO_OP = new AbortChecker(null, 0);
+
+    private final OneMerge oneMerge;
+    private final int abortCheckIntervalBytes;
+
+    public AbortChecker(OneMerge oneMerge, int abortCheckIntervalBytes) {
+      assert oneMerge != null || abortCheckIntervalBytes == 0 : 
abortCheckIntervalBytes;
+      this.oneMerge = oneMerge;
+      this.abortCheckIntervalBytes = abortCheckIntervalBytes;
+    }
+
+    /** Checks if the merge should be aborted, throwing MergeAbortedException 
if so. */
+    public void checkAborted() throws MergeAbortedException {
+      oneMerge.checkAborted();

Review Comment:
   This will throw an NPE if it's called on NO_OP which I think is trappy.



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