LUCENE-2831: pre-migrate to atomic context

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1056337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-01-07 14:31:09 +00:00
parent 4dca51491c
commit f70b9571a9
3 changed files with 15 additions and 16 deletions

View File

@ -248,17 +248,14 @@ abstract class DocSetBase implements DocSet {
return new Filter() {
@Override
public DocIdSet getDocIdSet(ReaderContext ctx) throws IOException {
int offset = 0;
IndexReader.AtomicReaderContext context = (IndexReader.AtomicReaderContext)ctx; // TODO: remove after lucene migration
IndexReader reader = ctx.reader;
SolrIndexReader r = (SolrIndexReader)reader;
while (r.getParent() != null) {
offset += r.getBase();
r = r.getParent();
if (context.isTopLevel) {
return bs;
}
if (r==reader) return bs;
final int base = offset;
final int base = context.docBase;
final int maxDoc = reader.maxDoc();
final int max = base + maxDoc; // one past the max doc in this segment.

View File

@ -23,6 +23,7 @@ import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Filter;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.ReaderContext;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import java.io.IOException;
@ -552,15 +553,11 @@ public class SortedIntDocSet extends DocSetBase {
int lastEndIdx = 0;
@Override
public DocIdSet getDocIdSet(ReaderContext context) throws IOException {
int offset = 0;
public DocIdSet getDocIdSet(ReaderContext contextX) throws IOException {
AtomicReaderContext context = (AtomicReaderContext)contextX; // TODO: remove after lucene migration
IndexReader reader = context.reader;
SolrIndexReader r = (SolrIndexReader)reader;
while (r.getParent() != null) {
offset += r.getBase();
r = r.getParent();
}
final int base = offset;
final int base = context.docBase;
final int maxDoc = reader.maxDoc();
final int max = base + maxDoc; // one past the max doc in this segment.
int sidx = Math.max(0,lastEndIdx);

View File

@ -413,10 +413,15 @@ public class TestDocSet extends LuceneTestCase {
Filter fa = a.getTopFilter();
Filter fb = b.getTopFilter();
/*** top level filters are no longer supported
// test top-level
DocIdSet da = fa.getDocIdSet(topLevelContext);
DocIdSet db = fb.getDocIdSet(topLevelContext);
doTestIteratorEqual(da, db);
***/
DocIdSet da;
DocIdSet db;
// first test in-sequence sub readers
for (ReaderContext readerInfo : topLevelContext.leaves()) {