mirror of https://github.com/apache/lucene.git
LUCENE-6836: Fix reader context management with block-join sorting.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1708209 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5409ecb3d9
commit
1a68f4b67c
|
@ -20,6 +20,7 @@ package org.apache.lucene.search;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
|
import org.apache.lucene.index.ReaderUtil;
|
||||||
import org.apache.lucene.index.SortingMergePolicy;
|
import org.apache.lucene.index.SortingMergePolicy;
|
||||||
import org.apache.lucene.util.BitSet;
|
import org.apache.lucene.util.BitSet;
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ public class BlockJoinComparatorSource extends FieldComparatorSource {
|
||||||
if (parentBits != null) {
|
if (parentBits != null) {
|
||||||
throw new IllegalStateException("This comparator can only be used on a single segment");
|
throw new IllegalStateException("This comparator can only be used on a single segment");
|
||||||
}
|
}
|
||||||
IndexSearcher searcher = new IndexSearcher(context.reader());
|
IndexSearcher searcher = new IndexSearcher(ReaderUtil.getTopLevelContext(context));
|
||||||
searcher.setQueryCache(null);
|
searcher.setQueryCache(null);
|
||||||
final Weight weight = searcher.createNormalizedWeight(parentsFilter, false);
|
final Weight weight = searcher.createNormalizedWeight(parentsFilter, false);
|
||||||
final DocIdSetIterator parents = weight.scorer(context);
|
final DocIdSetIterator parents = weight.scorer(context);
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.junit.Ignore;
|
||||||
|
|
||||||
public class TestBlockJoinSorter extends LuceneTestCase {
|
public class TestBlockJoinSorter extends LuceneTestCase {
|
||||||
|
|
||||||
@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-6836")
|
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
final int numParents = atLeast(200);
|
final int numParents = atLeast(200);
|
||||||
IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
|
IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||||
|
@ -65,14 +64,17 @@ public class TestBlockJoinSorter extends LuceneTestCase {
|
||||||
writer.addDocuments(documents);
|
writer.addDocuments(documents);
|
||||||
}
|
}
|
||||||
writer.forceMerge(1);
|
writer.forceMerge(1);
|
||||||
final DirectoryReader indexReader = writer.getReader();
|
IndexReader indexReader = writer.getReader();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
final LeafReader reader = getOnlySegmentReader(indexReader);
|
IndexSearcher searcher = newSearcher(indexReader);
|
||||||
|
indexReader = searcher.getIndexReader(); // newSearcher may have wrapped it
|
||||||
|
assertEquals(1, indexReader.leaves().size());
|
||||||
|
final LeafReader reader = indexReader.leaves().get(0).reader();
|
||||||
final Query parentsFilter = new TermQuery(new Term("parent", "true"));
|
final Query parentsFilter = new TermQuery(new Term("parent", "true"));
|
||||||
IndexSearcher searcher = newSearcher(reader);
|
|
||||||
final Weight weight = searcher.createNormalizedWeight(parentsFilter, false);
|
final Weight weight = searcher.createNormalizedWeight(parentsFilter, false);
|
||||||
final DocIdSetIterator parents = weight.scorer(reader.getContext());
|
final DocIdSetIterator parents = weight.scorer(indexReader.leaves().get(0));
|
||||||
final BitSet parentBits = BitSet.of(parents, reader.maxDoc());
|
final BitSet parentBits = BitSet.of(parents, reader.maxDoc());
|
||||||
final NumericDocValues parentValues = reader.getNumericDocValues("parent_val");
|
final NumericDocValues parentValues = reader.getNumericDocValues("parent_val");
|
||||||
final NumericDocValues childValues = reader.getNumericDocValues("child_val");
|
final NumericDocValues childValues = reader.getNumericDocValues("child_val");
|
||||||
|
|
Loading…
Reference in New Issue