cwperks commented on code in PR #15120:
URL: https://github.com/apache/lucene/pull/15120#discussion_r2298967850


##########
lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java:
##########
@@ -461,4 +461,33 @@ public void run() {
 
     directory.close();
   }
+
+  public void testAddEstimatedBytesToMerge() throws IOException {
+    Directory dir = newDirectory();
+    IndexWriter writer =
+        new IndexWriter(
+            dir,
+            newIndexWriterConfig(new MockAnalyzer(random()))
+                .setMergePolicy(NoMergePolicy.INSTANCE));
+
+    Document doc = new Document();
+    doc.add(newTextField("field", "content", Field.Store.YES));
+    for (int i = 0; i < 10; i++) {
+      writer.addDocument(doc);
+    }
+    writer.flush();
+
+    // Create a merge with the segments
+    SegmentInfos segmentInfos = writer.cloneSegmentInfos();
+    MergePolicy.OneMerge merge = new 
MergePolicy.OneMerge(segmentInfos.asList());
+
+    writer.addEstimatedBytesToMerge(merge);
+
+    assertTrue(merge.estimatedMergeBytes > 0);
+    assertTrue(merge.totalMergeBytes > 0);
+    assertTrue(merge.estimatedMergeBytes <= merge.totalMergeBytes);
+
+    writer.close();
+    dir.close();

Review Comment:
   Changed to try-with-resources here.
   
   Do you think we should create a mechanism to enforce this pattern repo wide? 
I see a number of tests cases (included ones in this suite) that do not follow 
the try-with-resources pattern.



-- 
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: issues-unsubscr...@lucene.apache.org

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

Reply via email to