diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 6cd0b19e445..45d5be021ec 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -47,6 +47,9 @@ API Changes leaves() (LUCENE-4152), which lists AtomicReaderContexts including the doc base of each leaf. (Uwe Schindler, Robert Muir) +* LUCENE-4307: Renamed IndexReader.getTopReaderContext to + IndexReader.getContext. (Robert Muir) + Bug Fixes * LUCENE-4297: BooleanScorer2 would multiply the coord() factor diff --git a/lucene/MIGRATE.txt b/lucene/MIGRATE.txt index 1d1ebf9446b..68a9b96b703 100644 --- a/lucene/MIGRATE.txt +++ b/lucene/MIGRATE.txt @@ -322,7 +322,7 @@ CompositeReader itsself to build its reader tree. To get all atomic leaves of a reader, use IndexReader#leaves(), which also provides the doc base of each leave. Readers that are already atomic return itsself as leaf with doc base 0. To emulate Lucene 3.x getSequentialSubReaders(), -use getTopReaderContext().children(). +use getContext().children(). ## LUCENE-2413,LUCENE-3396: Analyzer package changes diff --git a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java index 94ef1760df8..a2ef5efbb73 100644 --- a/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/AtomicReader.java @@ -54,7 +54,7 @@ public abstract class AtomicReader extends IndexReader { } @Override - public final AtomicReaderContext getTopReaderContext() { + public final AtomicReaderContext getContext() { ensureOpen(); return readerContext; } diff --git a/lucene/core/src/java/org/apache/lucene/index/BufferedDeletesStream.java b/lucene/core/src/java/org/apache/lucene/index/BufferedDeletesStream.java index b4bb4deaac3..5c0a85630c5 100644 --- a/lucene/core/src/java/org/apache/lucene/index/BufferedDeletesStream.java +++ b/lucene/core/src/java/org/apache/lucene/index/BufferedDeletesStream.java @@ -439,7 +439,7 @@ class BufferedDeletesStream { // Delete by query private static long applyQueryDeletes(Iterable queriesIter, ReadersAndLiveDocs rld, final SegmentReader reader) throws IOException { long delCount = 0; - final AtomicReaderContext readerContext = reader.getTopReaderContext(); + final AtomicReaderContext readerContext = reader.getContext(); boolean any = false; for (QueryAndLimit ent : queriesIter) { Query query = ent.query; diff --git a/lucene/core/src/java/org/apache/lucene/index/CompositeReader.java b/lucene/core/src/java/org/apache/lucene/index/CompositeReader.java index 4de38f0cad2..e33195a6577 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CompositeReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/CompositeReader.java @@ -90,7 +90,7 @@ public abstract class CompositeReader extends IndexReader { protected abstract List getSequentialSubReaders(); @Override - public final CompositeReaderContext getTopReaderContext() { + public final CompositeReaderContext getContext() { ensureOpen(); // lazy init without thread safety for perf reasons: Building the readerContext twice does not hurt! if (readerContext == null) { diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexReader.java b/lucene/core/src/java/org/apache/lucene/index/IndexReader.java index 3fe1c659dbe..eec1f3e1580 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexReader.java @@ -378,9 +378,11 @@ public abstract class IndexReader implements Closeable { protected abstract void doClose() throws IOException; /** - * Expert: Returns a the root {@link IndexReaderContext} for this - * {@link IndexReader}'s sub-reader tree. Iff this reader is composed of sub - * readers ,ie. this reader being a composite reader, this method returns a + * Expert: Returns the root {@link IndexReaderContext} for this + * {@link IndexReader}'s sub-reader tree. + *

+ * Iff this reader is composed of sub + * readers, i.e. this reader being a composite reader, this method returns a * {@link CompositeReaderContext} holding the reader's direct children as well as a * view of the reader tree's atomic leaf contexts. All sub- * {@link IndexReaderContext} instances referenced from this readers top-level @@ -396,13 +398,13 @@ public abstract class IndexReader implements Closeable { * * @lucene.experimental */ - public abstract IndexReaderContext getTopReaderContext(); + public abstract IndexReaderContext getContext(); /** * Returns the reader's leaves, or itself if this reader is Atomic. */ public final List leaves() { - return getTopReaderContext().leaves(); + return getContext().leaves(); } /** Expert: Returns a key for this IndexReader, so FieldCache/CachingWrapperFilter can find diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java index 50d4cda6284..abfc979c0dd 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java +++ b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java @@ -36,7 +36,7 @@ import org.apache.lucene.util.packed.PackedInts.Reader; * *

NOTE: for multi readers, you'll get better * performance by gathering the sub readers using - * {@link IndexReader#getTopReaderContext()} to get the + * {@link IndexReader#getContext()} to get the * atomic leaves and then operate per-AtomicReader, * instead of using this class. * diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java index e1afebf87fe..0e44b58623b 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java +++ b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java @@ -38,7 +38,7 @@ import org.apache.lucene.util.BytesRef; * *

NOTE: for composite readers, you'll get better * performance by gathering the sub readers using - * {@link IndexReader#getTopReaderContext()} to get the + * {@link IndexReader#getContext()} to get the * atomic leaves and then operate per-AtomicReader, * instead of using this class. * diff --git a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java index a616661f34d..b7883afc9c9 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java +++ b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.MultiReader; // javadoc *

NOTE: this class almost always results in a * performance hit. If this is important to your use case, * you'll get better performance by gathering the sub readers using - * {@link IndexReader#getTopReaderContext()} to get the + * {@link IndexReader#getContext()} to get the * atomic leaves and then operate per-AtomicReader, * instead of using this class. */ diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java index 9ca8548ee5b..389bf3f9abf 100644 --- a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java +++ b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java @@ -122,7 +122,7 @@ public class IndexSearcher { * * @lucene.experimental */ public IndexSearcher(IndexReader r, ExecutorService executor) { - this(r.getTopReaderContext(), executor); + this(r.getContext(), executor); } /** @@ -138,7 +138,7 @@ public class IndexSearcher { * href="https://issues.apache.org/jira/browse/LUCENE-2239">LUCENE-2239). * * @see IndexReaderContext - * @see IndexReader#getTopReaderContext() + * @see IndexReader#getContext() * @lucene.experimental */ public IndexSearcher(IndexReaderContext context, ExecutorService executor) { @@ -154,7 +154,7 @@ public class IndexSearcher { * Creates a searcher searching the provided top-level {@link IndexReaderContext}. * * @see IndexReaderContext - * @see IndexReader#getTopReaderContext() + * @see IndexReader#getContext() * @lucene.experimental */ public IndexSearcher(IndexReaderContext context) { @@ -639,7 +639,7 @@ public class IndexSearcher { /** * Returns this searchers the top-level {@link IndexReaderContext}. - * @see IndexReader#getTopReaderContext() + * @see IndexReader#getContext() */ /* sugar for #getReader().getTopReaderContext() */ public IndexReaderContext getTopReaderContext() { diff --git a/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java b/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java index 65ff2545cfb..441733e33cc 100644 --- a/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java +++ b/lucene/core/src/java/org/apache/lucene/search/QueryWrapperFilter.java @@ -50,7 +50,7 @@ public class QueryWrapperFilter extends Filter { @Override public DocIdSet getDocIdSet(final AtomicReaderContext context, final Bits acceptDocs) throws IOException { // get a private context that is used to rewrite, createWeight and score eventually - final AtomicReaderContext privateContext = context.reader().getTopReaderContext(); + final AtomicReaderContext privateContext = context.reader().getContext(); final Weight weight = new IndexSearcher(privateContext).createNormalizedWeight(query); return new DocIdSet() { @Override diff --git a/lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java b/lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java index a237d07147f..a0534111e9e 100644 --- a/lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java +++ b/lucene/core/src/java/org/apache/lucene/search/TermCollectingRewrite.java @@ -46,7 +46,7 @@ abstract class TermCollectingRewrite extends MultiTermQuery.Rew final void collectTerms(IndexReader reader, MultiTermQuery query, TermCollector collector) throws IOException { - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); Comparator lastTermComp = null; for (AtomicReaderContext context : topReaderContext.leaves()) { final Fields fields = context.reader().fields(); diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java b/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java index 6bae19b7347..b8ab5d31d07 100644 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java +++ b/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java @@ -60,7 +60,7 @@ public class PayloadSpanUtil { * @param context * that contains doc with payloads to extract * - * @see IndexReader#getTopReaderContext() + * @see IndexReader#getContext() */ public PayloadSpanUtil(IndexReaderContext context) { this.context = context; diff --git a/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java b/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java index fe2d4e15cb6..5e27861b285 100644 --- a/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java +++ b/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java @@ -286,7 +286,7 @@ public final class FieldCacheSanityChecker { if (obj instanceof IndexReader) { try { final List childs = - ((IndexReader) obj).getTopReaderContext().children(); + ((IndexReader) obj).getContext().children(); if (childs != null) { // it is composite reader for (final IndexReaderContext ctx : childs) { all.add(ctx.reader().getCoreCacheKey()); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java b/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java index 3eaaa1389aa..d5036157058 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java @@ -143,7 +143,7 @@ public class TestCustomNorms extends LuceneTestCase { IndexReader reader = writer.getReader(); writer.close(); assertEquals(numAdded, reader.numDocs()); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); for (final AtomicReaderContext ctx : topReaderContext.leaves()) { AtomicReader atomicReader = ctx.reader(); Source source = random().nextBoolean() ? atomicReader.normValues("foo").getSource() : atomicReader.normValues("foo").getDirectSource(); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java b/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java index ddc5e293848..0f92f0bf020 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java @@ -63,7 +63,7 @@ public class TestDocsAndPositions extends LuceneTestCase { int num = atLeast(13); for (int i = 0; i < num; i++) { BytesRef bytes = new BytesRef("1"); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); for (AtomicReaderContext atomicReaderContext : topReaderContext.leaves()) { DocsAndPositionsEnum docsAndPosEnum = getDocsAndPositions( atomicReaderContext.reader(), bytes, null); @@ -138,7 +138,7 @@ public class TestDocsAndPositions extends LuceneTestCase { int num = atLeast(13); for (int i = 0; i < num; i++) { BytesRef bytes = new BytesRef("" + term); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); for (AtomicReaderContext atomicReaderContext : topReaderContext.leaves()) { DocsAndPositionsEnum docsAndPosEnum = getDocsAndPositions( atomicReaderContext.reader(), bytes, null); @@ -214,7 +214,7 @@ public class TestDocsAndPositions extends LuceneTestCase { int num = atLeast(13); for (int i = 0; i < num; i++) { BytesRef bytes = new BytesRef("" + term); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); for (AtomicReaderContext context : topReaderContext.leaves()) { int maxDoc = context.reader().maxDoc(); DocsEnum docsEnum = _TestUtil.docs(random(), context.reader(), fieldName, bytes, null, null, DocsEnum.FLAG_FREQS); @@ -292,7 +292,7 @@ public class TestDocsAndPositions extends LuceneTestCase { for (int i = 0; i < num; i++) { BytesRef bytes = new BytesRef("even"); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); for (AtomicReaderContext atomicReaderContext : topReaderContext.leaves()) { DocsAndPositionsEnum docsAndPosEnum = getDocsAndPositions( atomicReaderContext.reader(), bytes, null); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java index 461d7ad98c1..499b0cb12fe 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java @@ -339,13 +339,13 @@ public class TestParallelCompositeReader extends LuceneTestCase { if (compositeComposite) { rd1 = new MultiReader(DirectoryReader.open(dir1), DirectoryReader.open(dir1)); rd2 = new MultiReader(DirectoryReader.open(dir2), DirectoryReader.open(dir2)); - assertEquals(2, rd1.getTopReaderContext().children().size()); - assertEquals(2, rd2.getTopReaderContext().children().size()); + assertEquals(2, rd1.getContext().children().size()); + assertEquals(2, rd2.getContext().children().size()); } else { rd1 = DirectoryReader.open(dir1); rd2 = DirectoryReader.open(dir2); - assertEquals(3, rd1.getTopReaderContext().children().size()); - assertEquals(3, rd2.getTopReaderContext().children().size()); + assertEquals(3, rd1.getContext().children().size()); + assertEquals(3, rd2.getContext().children().size()); } ParallelCompositeReader pr = new ParallelCompositeReader(rd1, rd2); return newSearcher(pr); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTypePromotion.java b/lucene/core/src/test/org/apache/lucene/index/TestTypePromotion.java index 0293cb1d286..31b9c42c430 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestTypePromotion.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestTypePromotion.java @@ -121,7 +121,7 @@ public class TestTypePromotion extends LuceneTestCase { throws IOException { DirectoryReader reader = DirectoryReader.open(dir); assertEquals(1, reader.leaves().size()); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); List leaves = topReaderContext.leaves(); assertEquals(1, leaves.size()); DocValues docValues = leaves.get(0).reader().docValues("promote"); @@ -372,7 +372,7 @@ public class TestTypePromotion extends LuceneTestCase { writer.close(); DirectoryReader reader = DirectoryReader.open(dir); assertEquals(1, reader.leaves().size()); - IndexReaderContext topReaderContext = reader.getTopReaderContext(); + IndexReaderContext topReaderContext = reader.getContext(); List leaves = topReaderContext.leaves(); DocValues docValues = leaves.get(0).reader().docValues("promote"); assertNotNull(docValues); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java b/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java index 31a88b4c9d5..e73df8362d3 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java @@ -43,7 +43,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { writer.close(); IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir)); - AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext(); + AtomicReaderContext context = (AtomicReaderContext) reader.getContext(); MockFilter filter = new MockFilter(); CachingWrapperFilter cacher = new CachingWrapperFilter(filter); @@ -69,7 +69,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { writer.close(); IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir)); - AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext(); + AtomicReaderContext context = (AtomicReaderContext) reader.getContext(); final Filter filter = new Filter() { @Override @@ -92,7 +92,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase { writer.close(); IndexReader reader = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dir)); - AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext(); + AtomicReaderContext context = (AtomicReaderContext) reader.getContext(); final Filter filter = new Filter() { @Override @@ -115,8 +115,8 @@ public class TestCachingWrapperFilter extends LuceneTestCase { } private static void assertDocIdSetCacheable(IndexReader reader, Filter filter, boolean shouldCacheable) throws IOException { - assertTrue(reader.getTopReaderContext() instanceof AtomicReaderContext); - AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext(); + assertTrue(reader.getContext() instanceof AtomicReaderContext); + AtomicReaderContext context = (AtomicReaderContext) reader.getContext(); final CachingWrapperFilter cacher = new CachingWrapperFilter(filter); final DocIdSet originalSet = filter.getDocIdSet(context, context.reader().getLiveDocs()); final DocIdSet cachedSet = cacher.getDocIdSet(context, context.reader().getLiveDocs()); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java index b5765fd9c52..cdb2503c7ea 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java @@ -197,7 +197,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { @Test public void testInverseRange() throws Exception { - AtomicReaderContext context = SlowCompositeReaderWrapper.wrap(reader).getTopReaderContext(); + AtomicReaderContext context = SlowCompositeReaderWrapper.wrap(reader).getContext(); NumericRangeFilter f = NumericRangeFilter.newIntRange("field8", 8, 1000, -1000, true, true); assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context, context.reader().getLiveDocs())); f = NumericRangeFilter.newIntRange("field8", 8, Integer.MAX_VALUE, null, false, false); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java index fb307355269..48a825125d0 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java @@ -211,7 +211,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { @Test public void testInverseRange() throws Exception { - AtomicReaderContext context = SlowCompositeReaderWrapper.wrap(searcher.getIndexReader()).getTopReaderContext(); + AtomicReaderContext context = SlowCompositeReaderWrapper.wrap(searcher.getIndexReader()).getContext(); NumericRangeFilter f = NumericRangeFilter.newLongRange("field8", 8, 1000L, -1000L, true, true); assertSame("A inverse range should return the EMPTY_DOCIDSET instance", DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(context, context.reader().getLiveDocs())); diff --git a/lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java b/lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java index 353ffd3590b..40172ba3244 100644 --- a/lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java +++ b/lucene/core/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java @@ -67,12 +67,12 @@ public class TestPayloadSpans extends LuceneTestCase { SpanTermQuery stq; Spans spans; stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "seventy")); - spans = MultiSpansWrapper.wrap(indexReader.getTopReaderContext(), stq); + spans = MultiSpansWrapper.wrap(indexReader.getContext(), stq); assertTrue("spans is null and it shouldn't be", spans != null); checkSpans(spans, 100, 1, 1, 1); stq = new SpanTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "seventy")); - spans = MultiSpansWrapper.wrap(indexReader.getTopReaderContext(), stq); + spans = MultiSpansWrapper.wrap(indexReader.getContext(), stq); assertTrue("spans is null and it shouldn't be", spans != null); checkSpans(spans, 100, 0, 0, 0); } @@ -83,7 +83,7 @@ public class TestPayloadSpans extends LuceneTestCase { SpanFirstQuery sfq; match = new SpanTermQuery(new Term(PayloadHelper.FIELD, "one")); sfq = new SpanFirstQuery(match, 2); - Spans spans = MultiSpansWrapper.wrap(indexReader.getTopReaderContext(), sfq); + Spans spans = MultiSpansWrapper.wrap(indexReader.getContext(), sfq); checkSpans(spans, 109, 1, 1, 1); //Test more complicated subclause SpanQuery[] clauses = new SpanQuery[2]; @@ -91,11 +91,11 @@ public class TestPayloadSpans extends LuceneTestCase { clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "hundred")); match = new SpanNearQuery(clauses, 0, true); sfq = new SpanFirstQuery(match, 2); - checkSpans(MultiSpansWrapper.wrap(indexReader.getTopReaderContext(), sfq), 100, 2, 1, 1); + checkSpans(MultiSpansWrapper.wrap(indexReader.getContext(), sfq), 100, 2, 1, 1); match = new SpanNearQuery(clauses, 0, false); sfq = new SpanFirstQuery(match, 2); - checkSpans(MultiSpansWrapper.wrap(indexReader.getTopReaderContext(), sfq), 100, 2, 1, 1); + checkSpans(MultiSpansWrapper.wrap(indexReader.getContext(), sfq), 100, 2, 1, 1); } @@ -119,7 +119,7 @@ public class TestPayloadSpans extends LuceneTestCase { writer.close(); - checkSpans(MultiSpansWrapper.wrap(reader.getTopReaderContext(), snq), 1,new int[]{2}); + checkSpans(MultiSpansWrapper.wrap(reader.getContext(), snq), 1,new int[]{2}); reader.close(); directory.close(); } diff --git a/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java b/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java index b5d48227bb3..976a18d7745 100644 --- a/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/BooleanFilterTest.java @@ -132,7 +132,7 @@ public class BooleanFilterTest extends LuceneTestCase { private void tstFilterCard(String mes, int expected, Filter filt) throws Exception { // BooleanFilter never returns null DIS or null DISI! - DocIdSetIterator disi = filt.getDocIdSet(reader.getTopReaderContext(), reader.getLiveDocs()).iterator(); + DocIdSetIterator disi = filt.getDocIdSet(reader.getContext(), reader.getLiveDocs()).iterator(); int actual = 0; while (disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { actual++; diff --git a/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java b/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java index fc3b37a9d0d..1403b229bab 100644 --- a/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java @@ -62,8 +62,8 @@ public class TermsFilterTest extends LuceneTestCase { w.addDocument(doc); } IndexReader reader = new SlowCompositeReaderWrapper(w.getReader()); - assertTrue(reader.getTopReaderContext() instanceof AtomicReaderContext); - AtomicReaderContext context = (AtomicReaderContext) reader.getTopReaderContext(); + assertTrue(reader.getContext() instanceof AtomicReaderContext); + AtomicReaderContext context = (AtomicReaderContext) reader.getContext(); w.close(); TermsFilter tf = new TermsFilter(); diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java index 1b7b7aa427e..4cbc37d9b07 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java @@ -66,7 +66,7 @@ public class TestNumericRangeFilterBuilder extends LuceneTestCase { try { AtomicReader reader = new SlowCompositeReaderWrapper(DirectoryReader.open(ramDir)); try { - assertNull(filter.getDocIdSet(reader.getTopReaderContext(), reader.getLiveDocs())); + assertNull(filter.getDocIdSet(reader.getContext(), reader.getLiveDocs())); } finally { reader.close(); diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java b/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java index 914297858a1..ff03f6e62a5 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java +++ b/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java @@ -353,7 +353,7 @@ public class QueryUtils { IndexSearcher indexSearcher = LuceneTestCase.newSearcher(previousReader, false); indexSearcher.setSimilarity(s.getSimilarity()); Weight w = indexSearcher.createNormalizedWeight(q); - AtomicReaderContext ctx = previousReader.getTopReaderContext(); + AtomicReaderContext ctx = previousReader.getContext(); Scorer scorer = w.scorer(ctx, true, false, ctx.reader().getLiveDocs()); if (scorer != null) { boolean more = scorer.advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS; diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java b/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java index 158980b8a91..fc98095728f 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/search/ShardSearchingTestBase.java @@ -179,7 +179,7 @@ public abstract class ShardSearchingTestBase extends LuceneTestCase { } try { for(Term term : terms) { - final TermContext termContext = TermContext.build(s.getIndexReader().getTopReaderContext(), term, false); + final TermContext termContext = TermContext.build(s.getIndexReader().getContext(), term, false); stats.put(term, s.termStatistics(term, termContext)); } } finally { diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index 45142cab0d5..276bad9903b 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -1168,7 +1168,7 @@ public abstract class LuceneTestCase extends Assert { if (maybeWrap) { r = maybeWrapReader(r); } - IndexSearcher ret = random.nextBoolean() ? new AssertingIndexSearcher(random, r) : new AssertingIndexSearcher(random, r.getTopReaderContext()); + IndexSearcher ret = random.nextBoolean() ? new AssertingIndexSearcher(random, r) : new AssertingIndexSearcher(random, r.getContext()); ret.setSimilarity(classEnvRule.similarity); return ret; } else { @@ -1197,7 +1197,7 @@ public abstract class LuceneTestCase extends Assert { } IndexSearcher ret = random.nextBoolean() ? new AssertingIndexSearcher(random, r, ex) - : new AssertingIndexSearcher(random, r.getTopReaderContext(), ex); + : new AssertingIndexSearcher(random, r.getContext(), ex); ret.setSimilarity(classEnvRule.similarity); return ret; } diff --git a/solr/core/src/test/org/apache/solr/search/TestDocSet.java b/solr/core/src/test/org/apache/solr/search/TestDocSet.java index b96c341472a..4cbc51203c1 100644 --- a/solr/core/src/test/org/apache/solr/search/TestDocSet.java +++ b/solr/core/src/test/org/apache/solr/search/TestDocSet.java @@ -455,7 +455,7 @@ public class TestDocSet extends LuceneTestCase { } public void doFilterTest(IndexReader reader) throws IOException { - IndexReaderContext topLevelContext = reader.getTopReaderContext(); + IndexReaderContext topLevelContext = reader.getContext(); OpenBitSet bs = getRandomSet(reader.maxDoc(), rand.nextInt(reader.maxDoc()+1)); DocSet a = new BitDocSet(bs); DocSet b = getIntDocSet(bs);