| From 3dfbf78b5e7c12b7ef0564dc9de9f8c10aa270fb Mon Sep 17 00:00:00 2001 |
| From: Atri Sharma <atri@apache.org> |
| Date: Tue, 14 May 2019 23:31:43 +0530 |
| Subject: [PATCH] LUCENE-8799: Add Method For Force Committing in |
| RandomIndexWriter |
| |
| A method to force a commit on inline IndexWriter instance will allow |
| easier avenues for writing a variety of tests, notably ones which |
| require accurate number and sizes of segments |
| --- |
| .../java/org/apache/lucene/index/RandomIndexWriter.java | 7 +++++++ |
| 1 file changed, 7 insertions(+) |
| |
| diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java b/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java |
| index 00350339cc..2bdea9b904 100644 |
| --- a/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java |
| +++ b/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java |
| @@ -232,6 +232,13 @@ public class RandomIndexWriter implements Closeable { |
| } |
| } |
| } |
| + |
| + public void forceCommit() throws IOException { |
| + if (LuceneTestCase.VERBOSE) { |
| + System.out.println("RIW.forceCommit: now doing a commit at docCount=" + docCount); |
| + } |
| + w.commit(); |
| + } |
| |
| public long addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs) throws IOException { |
| LuceneTestCase.maybeChangeLiveIndexWriterConfig(r, w.getConfig()); |
| -- |
| 2.17.2 (Apple Git-113) |
| |