mikemccand commented on a change in pull request #1617: URL: https://github.com/apache/lucene-solr/pull/1617#discussion_r446269728
########## File path: lucene/core/src/java/org/apache/lucene/index/MergePolicy.java ########## @@ -399,6 +416,40 @@ boolean hasFinished() { Optional<Boolean> hasCompletedSuccessfully() { return Optional.ofNullable(mergeCompleted.getNow(null)); } + + + /** + * Called before the merge is committed + */ + void onMergeCommit() { + } + + /** + * Sets the merge readers for this merge. + */ + void initMergeReaders(IOUtils.IOFunction<SegmentCommitInfo, MergeReader> readerFactory) throws IOException { + assert mergeReaders.isEmpty() : "merge readers must be empty"; + assert mergeCompleted.isDone() == false : "merge is already done"; + ArrayList<MergeReader> readers = new ArrayList<>(segments.size()); + try { + for (final SegmentCommitInfo info : segments) { + // Hold onto the "live" reader; we will use this to + // commit merged deletes + readers.add(readerFactory.apply(info)); + } + } finally { + // ensure we assign this to close them in the case of an exception + this.mergeReaders = List.copyOf(readers); Review comment: Hmm is there some (sneaky) reason why we couldn't just do `this.mergeReaders = new ArrayList<>(segments.size());` above and then append to that list? Instead of appending to private `ArrayList` and then making a copy in the end? ########## File path: lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java ########## @@ -459,6 +463,27 @@ public IndexWriterConfig setCommitOnClose(boolean commitOnClose) { return this; } + /** + * Expert: sets the amount of time to wait for merges returned by MergePolicy.findFullFlushMerges(...). + * If this time is reached, we proceed with the commit based on segments merged up to that point. + * The merges are not cancelled, and will still run to completion independent of the commit + * like normal segment merges. The default is <code>{@value IndexWriterConfig#DEFAULT_MAX_COMMIT_MERGE_WAIT_MILLIS}</code>. + * + * Note: This settings has no effect unless {@link MergePolicy#findFullFlushMerges(MergeTrigger, SegmentInfos, MergePolicy.MergeContext)} + * has an implementation that actually returns merges which by default doesn't return any merges. + */ + public IndexWriterConfig setMaxCommitMergeWaitMillis(long maxCommitMergeWaitMillis) { + this.maxCommitMergeWaitMillis = maxCommitMergeWaitMillis; + return this; + } + + /** We only allow sorting on these types */ + private static final EnumSet<SortField.Type> ALLOWED_INDEX_SORT_TYPES = EnumSet.of(SortField.Type.STRING, Review comment: Hmm how did this sneak in? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org