Skip to content

Apache Lucene open-source search software

LUCENE-2559: add SegmentReader.reopen

Michael McCandless317b9399497e
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index f967e75aa9c..ffea4834b0b 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -193,6 +193,9 @@ New features
SegmentInfosReader to allow customization of SegmentInfos data.
(Andrzej Bialecki)
+* LUCENE-2559: Added SegmentReader.reopen methods (John Wang via Mike
+ McCandless)
+
Optimizations
* LUCENE-2410: ~20% speedup on exact (slop=0) PhraseQuery matching.
diff --git a/lucene/src/java/org/apache/lucene/index/SegmentReader.java b/lucene/src/java/org/apache/lucene/index/SegmentReader.java
index b216cd976e9..601de789562 100644
--- a/lucene/src/java/org/apache/lucene/index/SegmentReader.java
+++ b/lucene/src/java/org/apache/lucene/index/SegmentReader.java
@@ -611,6 +611,18 @@ public class SegmentReader extends IndexReader implements Cloneable {
return reopenSegment(si, true, openReadOnly);
}
+ @Override
+ public synchronized IndexReader reopen()
+ throws CorruptIndexException, IOException {
+ return reopenSegment(si, false, readOnly);
+ }
+
+ @Override
+ public synchronized IndexReader reopen(boolean openReadOnly)
+ throws CorruptIndexException, IOException {
+ return reopenSegment(si, false, openReadOnly);
+ }
+
synchronized SegmentReader reopenSegment(SegmentInfo si, boolean doClone, boolean openReadOnly) throws CorruptIndexException, IOException {
boolean deletionsUpToDate = (this.si.hasDeletions() == si.hasDeletions())
&& (!si.hasDeletions() || this.si.getDelFileName().equals(si.getDelFileName()));