romseygeek commented on code in PR #16086:
URL: https://github.com/apache/lucene/pull/16086#discussion_r3267965443
##########
lucene/core/src/java/org/apache/lucene/index/MergePolicy.java:
##########
@@ -570,6 +570,53 @@ 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 {
+
+ /**
+ * Creates an {@link AbortChecker} for the given merge. If {@code
abortCheckIntervalBytes} is
+ * zero or negative, returns {@link AbortChecker#NO_OP}.
+ *
+ * @param merge the merge to check for abort
+ * @param abortCheckIntervalBytes interval in bytes between abort checks,
or 0 to disable
+ */
+ public static AbortChecker create(OneMerge merge, int
abortCheckIntervalBytes) {
+ if (merge != null && abortCheckIntervalBytes > 0) {
+ return new AbortChecker(merge, abortCheckIntervalBytes);
+ }
+ return AbortChecker.NO_OP;
+ }
+
+ /** 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) {
Review Comment:
Let's make this private and do all construction via the factory method.
--
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]