You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/02/12 02:38:11 UTC

[GitHub] [lucene-solr] zacharymorn commented on a change in pull request #2342: LUCENE-9406: Add IndexWriterEventListener to track events in IndexWriter

zacharymorn commented on a change in pull request #2342:
URL: https://github.com/apache/lucene-solr/pull/2342#discussion_r574958684



##########
File path: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
##########
@@ -3518,15 +3518,30 @@ private long prepareCommitInternal() throws IOException {
       }
 
       if (pointInTimeMerges != null) {
+        MergePolicy.OneMerge nextMerge = null;
+
+        if (pendingMerges.size() > 0) {
+          // nocommit getting OneMerge instance here via mergeSource.getNextMerge() will

Review comment:
       No problem! From the context I assume you are actually meaning to pass `pointInTimeMerges` into event listener, since `pendingMerges` is of type `Deque<MergePolicy.OneMerge>`? I've pushed a commit to use `pointInTimeMerges` for now.

##########
File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java
##########
@@ -388,6 +388,69 @@ public void testMergeOnCommit() throws IOException {
     dir.close();
   }
 
+  private class TesIndexWriterEventListener implements IndexWriterEventListener {
+    private boolean beginMergeCalled = false;
+    private boolean endMergeCalled = false;
+
+    @Override
+    public void beginMergeOnFullFlush(MergePolicy.OneMerge merge) {
+      beginMergeCalled = true;
+    }
+
+    @Override
+    public void endMergeOnFullFlush(MergePolicy.OneMerge merge) {
+      endMergeCalled = true;
+    }
+
+    public boolean isEventsRecorded() {
+      return beginMergeCalled && endMergeCalled;
+    }
+  }
+
+  // Test basic semantics of merge on commit and events recording invocation
+  public void testMergeOnCommitWithEventListener() throws IOException {

Review comment:
       Makes sense. Added.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org