LUCENE-2831: fix isTopLevel

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1055695 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-01-06 01:03:00 +00:00
parent 5e009c8a17
commit 4140f73774
2 changed files with 7 additions and 15 deletions

View File

@ -1471,13 +1471,13 @@ public abstract class IndexReader implements Cloneable,Closeable {
public final int ordInParent; public final int ordInParent;
ReaderContext(ReaderContext parent, IndexReader reader, ReaderContext(ReaderContext parent, IndexReader reader,
boolean isAtomic, boolean isTopLevel, int ordInParent, int docBaseInParent) { boolean isAtomic, int ordInParent, int docBaseInParent) {
this.parent = parent; this.parent = parent;
this.reader = reader; this.reader = reader;
this.isAtomic = isAtomic; this.isAtomic = isAtomic;
this.docBaseInParent = docBaseInParent; this.docBaseInParent = docBaseInParent;
this.ordInParent = ordInParent; this.ordInParent = ordInParent;
this.isTopLevel = isTopLevel; this.isTopLevel = parent==null;
} }
/** /**
@ -1533,7 +1533,7 @@ public abstract class IndexReader implements Cloneable,Closeable {
private CompositeReaderContext(ReaderContext parent, IndexReader reader, private CompositeReaderContext(ReaderContext parent, IndexReader reader,
int ordInParent, int docbaseInParent, ReaderContext[] children, int ordInParent, int docbaseInParent, ReaderContext[] children,
AtomicReaderContext[] leaves) { AtomicReaderContext[] leaves) {
super(parent, reader, false, leaves != null, ordInParent, docbaseInParent); super(parent, reader, false, ordInParent, docbaseInParent);
this.children = children; this.children = children;
this.leaves = leaves; this.leaves = leaves;
} }
@ -1564,12 +1564,7 @@ public abstract class IndexReader implements Cloneable,Closeable {
*/ */
public AtomicReaderContext(ReaderContext parent, IndexReader reader, public AtomicReaderContext(ReaderContext parent, IndexReader reader,
int ord, int docBase, int leafOrd, int leafDocBase) { int ord, int docBase, int leafOrd, int leafDocBase) {
this(parent, reader, ord, docBase, leafOrd, leafDocBase, false); super(parent, reader, true, ord, docBase);
}
private AtomicReaderContext(ReaderContext parent, IndexReader reader,
int ord, int docBase, int leafOrd, int leafDocBase, boolean topLevel) {
super(parent, reader, true, topLevel, ord, docBase);
assert reader.getSequentialSubReaders() == null : "Atomic readers must not have subreaders"; assert reader.getSequentialSubReaders() == null : "Atomic readers must not have subreaders";
this.ord = leafOrd; this.ord = leafOrd;
this.docBase = leafDocBase; this.docBase = leafDocBase;
@ -1580,7 +1575,7 @@ public abstract class IndexReader implements Cloneable,Closeable {
* parent. * parent.
*/ */
public AtomicReaderContext(IndexReader atomicReader) { public AtomicReaderContext(IndexReader atomicReader) {
this(null, atomicReader, 0, 0, 0, 0, true); // toplevel!! this(null, atomicReader, 0, 0, 0, 0);
} }
} }
} }

View File

@ -153,10 +153,7 @@ public class IndexSearcher {
} }
private IndexSearcher(ReaderContext context, boolean closeReader, ExecutorService executor) { private IndexSearcher(ReaderContext context, boolean closeReader, ExecutorService executor) {
// TODO: eable this assert once SolrIndexReader and friends are refactored to use ReaderContext assert context.isTopLevel: "IndexSearcher's ReaderContext must be topLevel for reader" + context.reader;
// We can't assert this here since SolrIndexReader will fail in some contexts - once solr is consistent we should be fine here
// Lucene instead passes all tests even with this assert!
// assert context.isTopLevel: "IndexSearcher's ReaderContext must be topLevel for reader" + context.reader;
reader = context.reader; reader = context.reader;
this.executor = executor; this.executor = executor;
this.closeReader = closeReader; this.closeReader = closeReader;