You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2011/12/05 00:52:51 UTC
svn commit: r1210283 - in
/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index:
DirectoryReader.java IndexReader.java SegmentReader.java
Author: uschindler
Date: Sun Dec 4 23:52:51 2011
New Revision: 1210283
URL: http://svn.apache.org/viewvc?rev=1210283&view=rev
Log:
LUCENE-3606: Remove IR.openIfChanged(readOnly) and corresponding impls
Modified:
lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexReader.java
lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1210283&r1=1210282&r2=1210283&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/DirectoryReader.java Sun Dec 4 23:52:51 2011
@@ -305,7 +305,7 @@ class DirectoryReader extends IndexReade
@Override
public final synchronized Object clone() {
try {
- DirectoryReader newReader = doOpenIfChanged((SegmentInfos) segmentInfos.clone(), true, true);
+ DirectoryReader newReader = doOpenIfChanged((SegmentInfos) segmentInfos.clone(), true);
newReader.writer = writer;
newReader.hasDeletions = hasDeletions;
assert newReader.readerFinishedListeners != null;
@@ -317,31 +317,34 @@ class DirectoryReader extends IndexReade
@Override
protected final IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
- return doOpenIfChanged(true, null);
- }
-
- @Override
- protected final IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
- return doOpenIfChanged(openReadOnly, null);
+ return doOpenIfChanged(null);
}
@Override
protected final IndexReader doOpenIfChanged(final IndexCommit commit) throws CorruptIndexException, IOException {
- return doOpenIfChanged(true, commit);
+ ensureOpen();
+
+ // If we were obtained by writer.getReader(), re-ask the
+ // writer to get a new reader.
+ if (writer != null) {
+ return doOpenFromWriter(commit);
+ } else {
+ return doOpenNoWriter(commit);
+ }
}
@Override
protected final IndexReader doOpenIfChanged(IndexWriter writer, boolean applyAllDeletes) throws CorruptIndexException, IOException {
+ ensureOpen();
if (writer == this.writer && applyAllDeletes == this.applyAllDeletes) {
- return doOpenIfChanged();
- } else {
+ return doOpenFromWriter(null);
+ } else {
+ // fail by calling supers impl throwing UOE
return super.doOpenIfChanged(writer, applyAllDeletes);
}
}
- private final IndexReader doOpenFromWriter(boolean openReadOnly, IndexCommit commit) throws CorruptIndexException, IOException {
- assert openReadOnly;
-
+ private final IndexReader doOpenFromWriter(IndexCommit commit) throws CorruptIndexException, IOException {
if (commit != null) {
throw new IllegalArgumentException("a reader obtained from IndexWriter.getReader() cannot currently accept a commit");
}
@@ -362,21 +365,7 @@ class DirectoryReader extends IndexReade
return reader;
}
- private IndexReader doOpenIfChanged(final boolean openReadOnly, IndexCommit commit) throws CorruptIndexException, IOException {
- ensureOpen();
-
- assert openReadOnly;
-
- // If we were obtained by writer.getReader(), re-ask the
- // writer to get a new reader.
- if (writer != null) {
- return doOpenFromWriter(openReadOnly, commit);
- } else {
- return doOpenNoWriter(openReadOnly, commit);
- }
- }
-
- private synchronized IndexReader doOpenNoWriter(final boolean openReadOnly, IndexCommit commit) throws CorruptIndexException, IOException {
+ private synchronized IndexReader doOpenNoWriter(IndexCommit commit) throws CorruptIndexException, IOException {
if (commit == null) {
if (isCurrent()) {
@@ -396,13 +385,12 @@ class DirectoryReader extends IndexReade
protected Object doBody(String segmentFileName) throws CorruptIndexException, IOException {
final SegmentInfos infos = new SegmentInfos();
infos.read(directory, segmentFileName);
- return doOpenIfChanged(infos, false, openReadOnly);
+ return doOpenIfChanged(infos, false);
}
}.run(commit);
}
- private synchronized DirectoryReader doOpenIfChanged(SegmentInfos infos, boolean doClone, boolean openReadOnly) throws CorruptIndexException, IOException {
- assert openReadOnly;
+ private synchronized DirectoryReader doOpenIfChanged(SegmentInfos infos, boolean doClone) throws CorruptIndexException, IOException {
return new DirectoryReader(directory, infos, subReaders, doClone, termInfosIndexDivisor, readerFinishedListeners);
}
Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexReader.java?rev=1210283&r1=1210282&r2=1210283&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/IndexReader.java Sun Dec 4 23:52:51 2011
@@ -497,20 +497,6 @@ public abstract class IndexReader implem
}
/**
- * If the index has changed since the provided reader was
- * opened, open and return a new reader, with the
- * specified <code>readOnly</code>; else, return
- * null.
- *
- * @see #openIfChanged(IndexReader)
- */
- public static IndexReader openIfChanged(IndexReader oldReader, boolean readOnly) throws IOException {
- final IndexReader newReader = oldReader.doOpenIfChanged(readOnly);
- assert newReader != oldReader;
- return newReader;
- }
-
- /**
* If the IndexCommit differs from what the
* provided reader is searching, or the provided reader is
* not already read-only, open and return a new
@@ -606,16 +592,6 @@ public abstract class IndexReader implem
* If the index has changed since it was opened, open and return a new reader;
* else, return {@code null}.
*
- * @see #openIfChanged(IndexReader, boolean)
- */
- protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
- throw new UnsupportedOperationException("This reader does not support reopen().");
- }
-
- /**
- * If the index has changed since it was opened, open and return a new reader;
- * else, return {@code null}.
- *
* @see #openIfChanged(IndexReader, IndexCommit)
*/
protected IndexReader doOpenIfChanged(final IndexCommit commit) throws CorruptIndexException, IOException {
Modified: lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java?rev=1210283&r1=1210282&r2=1210283&view=diff
==============================================================================
--- lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/dev/branches/lucene3606/lucene/src/java/org/apache/lucene/index/SegmentReader.java Sun Dec 4 23:52:51 2011
@@ -193,17 +193,10 @@ public class SegmentReader extends Index
}
@Override
- protected synchronized IndexReader doOpenIfChanged()
- throws CorruptIndexException, IOException {
+ protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
return reopenSegment(si, false, readOnly);
}
- @Override
- protected synchronized IndexReader doOpenIfChanged(boolean openReadOnly)
- throws CorruptIndexException, IOException {
- return reopenSegment(si, false, openReadOnly);
- }
-
synchronized SegmentReader reopenSegment(SegmentInfo si, boolean doClone, boolean openReadOnly) throws CorruptIndexException, IOException {
ensureOpen();
boolean deletionsUpToDate = (this.si.hasDeletions() == si.hasDeletions())