From cae6b49a065bfbc5789d8bdcf3706c158c0fc10d Mon Sep 17 00:00:00 2001 From: yonik Date: Wed, 5 Oct 2016 15:10:22 -0400 Subject: [PATCH] SOLR-9592: use correct leaf reader rather than top-level reader in SolrIndexReaderm.decorateDocValues --- solr/CHANGES.txt | 5 ++++ .../handler/admin/LukeRequestHandler.java | 2 +- .../handler/component/ExpandComponent.java | 6 ++-- .../handler/component/FieldFacetStats.java | 2 +- .../handler/component/TermsComponent.java | 2 +- .../highlight/DefaultSolrHighlighter.java | 4 +-- .../apache/solr/request/DocValuesFacets.java | 4 +-- .../apache/solr/request/DocValuesStats.java | 4 +-- .../apache/solr/request/NumericFacets.java | 4 +-- .../org/apache/solr/request/SimpleFacets.java | 2 +- .../solr/response/SortingResponseWriter.java | 4 +-- .../solr/search/CollapsingQParserPlugin.java | 4 +-- .../apache/solr/search/JoinQParserPlugin.java | 8 ++--- .../apache/solr/search/SolrIndexSearcher.java | 29 ++++++++++++++----- .../facet/FacetFieldProcessorByArrayUIF.java | 2 +- .../FacetFieldProcessorByEnumTermsStream.java | 4 +-- .../facet/FacetFieldProcessorByHashDV.java | 2 +- .../apache/solr/search/facet/FieldUtil.java | 4 +-- .../solr/search/facet/UnInvertedField.java | 4 +-- .../solr/search/function/OrdFieldSource.java | 2 +- .../function/ReverseOrdFieldSource.java | 2 +- .../join/BlockJoinFieldFacetAccumulator.java | 4 +-- .../org/apache/solr/request/TestFaceting.java | 22 +++++++------- .../solr/schema/DocValuesMultiTest.java | 2 +- .../org/apache/solr/schema/DocValuesTest.java | 12 ++++---- .../search/join/TestScoreJoinQPScore.java | 2 +- 26 files changed, 81 insertions(+), 61 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index a8a65168fc3..aeb39b85604 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -177,6 +177,11 @@ Optimizations * SOLR-9446: Leader failure after creating a freshly replicated index can send nodes into recovery even if index was not changed (Pushkar Raste, noble) +* SOLR-9592: retrieving docValues as stored values was sped up by using the proper leaf + reader rather than ask for a global view. In extreme cases, this leads to a 100x speedup. + (Takahiro Ishikawa, yonik) + + Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java index 450a5052d1a..a5fc36c3019 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java @@ -340,7 +340,7 @@ public class LukeRequestHandler extends RequestHandlerBase fields = new TreeSet<>(Arrays.asList(fl.split( "[,\\s]+" ))); } - LeafReader reader = searcher.getLeafReader(); + LeafReader reader = searcher.getSlowAtomicReader(); IndexSchema schema = searcher.getSchema(); // Don't be tempted to put this in the loop below, the whole point here is to alphabetize the fields! diff --git a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java index e307e705cbf..8274d68aebd 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java @@ -208,7 +208,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia } SolrIndexSearcher searcher = req.getSearcher(); - LeafReader reader = searcher.getLeafReader(); + LeafReader reader = searcher.getSlowAtomicReader(); FieldType fieldType = searcher.getSchema().getField(field).getType(); @@ -220,7 +220,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia if(CollapsingQParserPlugin.HINT_TOP_FC.equals(hint)) { Map mapping = new HashMap(); mapping.put(field, UninvertingReader.Type.SORTED); - UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getLeafReader(), field), mapping); + UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getSlowAtomicReader(), field), mapping); values = uninvertingReader.getSortedDocValues(field); } else { values = DocValues.getSorted(reader, field); @@ -380,7 +380,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia if(CollapsingQParserPlugin.HINT_TOP_FC.equals(hint)) { Map mapping = new HashMap(); mapping.put(field, UninvertingReader.Type.SORTED); - UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getLeafReader(), field), mapping); + UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getSlowAtomicReader(), field), mapping); values = uninvertingReader.getSortedDocValues(field); } else { values = DocValues.getSorted(reader, field); diff --git a/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java b/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java index 5a8f544f764..2b8373a2020 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java +++ b/solr/core/src/java/org/apache/solr/handler/component/FieldFacetStats.java @@ -64,7 +64,7 @@ public class FieldFacetStats { this.facet_sf = facet_sf; this.name = facet_sf.getName(); - topLevelReader = searcher.getLeafReader(); + topLevelReader = searcher.getSlowAtomicReader(); valueSource = facet_sf.getType().getValueSource(facet_sf, null); facetStatsValues = new HashMap<>(); diff --git a/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java b/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java index 076c4eb1575..918efa03f21 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/TermsComponent.java @@ -136,7 +136,7 @@ public class TermsComponent extends SearchComponent { boolean raw = params.getBool(TermsParams.TERMS_RAW, false); - final LeafReader indexReader = rb.req.getSearcher().getLeafReader(); + final LeafReader indexReader = rb.req.getSearcher().getSlowAtomicReader(); Fields lfields = indexReader.fields(); for (String field : fields) { diff --git a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java index 43decc3338d..2e31d7db6d0 100644 --- a/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java +++ b/solr/core/src/java/org/apache/solr/highlight/DefaultSolrHighlighter.java @@ -220,7 +220,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf try { // It'd be nice to know if payloads are on the tokenStream but the presence of the attribute isn't a good // indicator. - final Terms terms = request.getSearcher().getLeafReader().fields().terms(fieldName); + final Terms terms = request.getSearcher().getSlowAtomicReader().fields().terms(fieldName); if (terms != null) { defaultPayloads = terms.hasPayloads(); } @@ -391,7 +391,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf FvhContainer fvhContainer = new FvhContainer(null, null); // Lazy container for fvh and fieldQuery - IndexReader reader = new TermVectorReusingLeafReader(req.getSearcher().getLeafReader()); // SOLR-5855 + IndexReader reader = new TermVectorReusingLeafReader(req.getSearcher().getSlowAtomicReader()); // SOLR-5855 // Highlight each document NamedList fragments = new SimpleOrderedMap(); diff --git a/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java b/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java index b21764d65c9..09ad8368bca 100644 --- a/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java +++ b/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java @@ -69,12 +69,12 @@ public class DocValuesFacets { final SortedSetDocValues si; // for term lookups only OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones if (multiValued) { - si = searcher.getLeafReader().getSortedSetDocValues(fieldName); + si = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName); if (si instanceof MultiDocValues.MultiSortedSetDocValues) { ordinalMap = ((MultiSortedSetDocValues)si).mapping; } } else { - SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); + SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName); si = single == null ? null : DocValues.singleton(single); if (single instanceof MultiDocValues.MultiSortedDocValues) { ordinalMap = ((MultiDocValues.MultiSortedDocValues)single).mapping; diff --git a/solr/core/src/java/org/apache/solr/request/DocValuesStats.java b/solr/core/src/java/org/apache/solr/request/DocValuesStats.java index efc5cf78e55..4b1fe84c637 100644 --- a/solr/core/src/java/org/apache/solr/request/DocValuesStats.java +++ b/solr/core/src/java/org/apache/solr/request/DocValuesStats.java @@ -83,13 +83,13 @@ public class DocValuesStats { SortedSetDocValues si; // for term lookups only OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones if (multiValued) { - si = searcher.getLeafReader().getSortedSetDocValues(fieldName); + si = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName); if (si instanceof MultiSortedSetDocValues) { ordinalMap = ((MultiDocValues.MultiSortedSetDocValues)si).mapping; } } else { - SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); + SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName); si = single == null ? null : DocValues.singleton(single); if (single instanceof MultiDocValues.MultiSortedDocValues) { ordinalMap = ((MultiDocValues.MultiSortedDocValues)single).mapping; diff --git a/solr/core/src/java/org/apache/solr/request/NumericFacets.java b/solr/core/src/java/org/apache/solr/request/NumericFacets.java index 5c5a7103619..2ff2f8c7ae2 100644 --- a/solr/core/src/java/org/apache/solr/request/NumericFacets.java +++ b/solr/core/src/java/org/apache/solr/request/NumericFacets.java @@ -266,7 +266,7 @@ final class NumericFacets { for (int i = 0; i < result.size(); ++i) { alreadySeen.add(result.getName(i)); } - final Terms terms = searcher.getLeafReader().terms(fieldName); + final Terms terms = searcher.getSlowAtomicReader().terms(fieldName); if (terms != null) { final String prefixStr = TrieField.getMainValuePrefix(ft); final BytesRef prefix; @@ -319,7 +319,7 @@ final class NumericFacets { final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx)); counts.put(values.strVal(entry.docID - leaves.get(readerIdx).docBase), entry.count); } - final Terms terms = searcher.getLeafReader().terms(fieldName); + final Terms terms = searcher.getSlowAtomicReader().terms(fieldName); if (terms != null) { final String prefixStr = TrieField.getMainValuePrefix(ft); final BytesRef prefix; diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java index 52c2129a99e..93ca4fa906e 100644 --- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java +++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java @@ -859,7 +859,7 @@ public class SimpleFacets { IndexSchema schema = searcher.getSchema(); - LeafReader r = searcher.getLeafReader(); + LeafReader r = searcher.getSlowAtomicReader(); FieldType ft = schema.getFieldType(field); boolean sortByCount = sort.equals("count") || sort.equals("true"); diff --git a/solr/core/src/java/org/apache/solr/response/SortingResponseWriter.java b/solr/core/src/java/org/apache/solr/response/SortingResponseWriter.java index 23a17cf4c9e..d99d3dc1cc0 100644 --- a/solr/core/src/java/org/apache/solr/response/SortingResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/SortingResponseWriter.java @@ -381,7 +381,7 @@ public class SortingResponseWriter implements QueryResponseWriter { sortValues[i] = new LongValue(field, new LongAsc()); } } else if(ft instanceof StrField) { - LeafReader reader = searcher.getLeafReader(); + LeafReader reader = searcher.getSlowAtomicReader(); SortedDocValues vals = reader.getSortedDocValues(field); if(reverse) { sortValues[i] = new StringValue(vals, field, new IntDesc()); @@ -398,7 +398,7 @@ public class SortingResponseWriter implements QueryResponseWriter { // This is a bit of a hack, but since the boolean field stores ByteRefs, just like Strings // _and_ since "F" happens to sort before "T" (thus false sorts "less" than true) // we can just use the existing StringValue here. - LeafReader reader = searcher.getLeafReader(); + LeafReader reader = searcher.getSlowAtomicReader(); SortedDocValues vals = reader.getSortedDocValues(field); if(reverse) { sortValues[i] = new StringValue(vals, field, new IntDesc()); diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java index 4858d1c4451..f6bc18e1008 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -1274,7 +1274,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { Map mapping = new HashMap(); mapping.put(collapseField, UninvertingReader.Type.SORTED); - UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getLeafReader(), collapseField), mapping); + UninvertingReader uninvertingReader = new UninvertingReader(new ReaderWrapper(searcher.getSlowAtomicReader(), collapseField), mapping); docValuesProducer = new EmptyDocValuesProducer() { @Override public SortedDocValues getSorted(FieldInfo ignored) throws IOException { @@ -1285,7 +1285,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { docValuesProducer = new EmptyDocValuesProducer() { @Override public SortedDocValues getSorted(FieldInfo ignored) throws IOException { - return DocValues.getSorted(searcher.getLeafReader(), collapseField); + return DocValues.getSorted(searcher.getSlowAtomicReader(), collapseField); } }; } diff --git a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java index e0bb09bf518..24dd8b45f09 100644 --- a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java @@ -299,8 +299,8 @@ class JoinQuery extends Query { fastForRandomSet = new HashDocSet(sset.getDocs(), 0, sset.size()); } - Fields fromFields = fromSearcher.getLeafReader().fields(); - Fields toFields = fromSearcher==toSearcher ? fromFields : toSearcher.getLeafReader().fields(); + Fields fromFields = fromSearcher.getSlowAtomicReader().fields(); + Fields toFields = fromSearcher==toSearcher ? fromFields : toSearcher.getSlowAtomicReader().fields(); if (fromFields == null) return DocSet.EMPTY; Terms terms = fromFields.terms(fromField); Terms toTerms = toFields.terms(toField); @@ -322,8 +322,8 @@ class JoinQuery extends Query { } } - Bits fromLiveDocs = fromSearcher.getLeafReader().getLiveDocs(); - Bits toLiveDocs = fromSearcher == toSearcher ? fromLiveDocs : toSearcher.getLeafReader().getLiveDocs(); + Bits fromLiveDocs = fromSearcher.getSlowAtomicReader().getLiveDocs(); + Bits toLiveDocs = fromSearcher == toSearcher ? fromLiveDocs : toSearcher.getSlowAtomicReader().getLiveDocs(); fromDeState = new SolrIndexSearcher.DocsEnumState(); fromDeState.fieldName = fromField; diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index 93572b58d30..933477b1ac1 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -406,7 +406,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI return reader.docFreq(term); } - public final LeafReader getLeafReader() { + /** + * Not recommended to call this method unless there is some particular reason due to internally calling {@link SlowCompositeReaderWrapper}. + * Use {@link IndexSearcher#leafContexts} to get the sub readers instead of using this method. + */ + public final LeafReader getSlowAtomicReader() { return leafReader; } @@ -759,7 +763,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI */ public void decorateDocValueFields(@SuppressWarnings("rawtypes") SolrDocumentBase doc, int docid, Set fields) throws IOException { - final LeafReader reader = getLeafReader(); + final int subIndex = ReaderUtil.subIndex(docid, leafContexts); + final int localId = docid - leafContexts.get(subIndex).docBase; + final LeafReader leafReader = leafContexts.get(subIndex).reader(); for (String fieldName : fields) { final SchemaField schemaField = schema.getFieldOrNull(fieldName); if (schemaField == null || !schemaField.hasDocValues() || doc.containsKey(fieldName)) { @@ -768,9 +774,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI } if (schemaField.multiValued()) { - final SortedSetDocValues values = reader.getSortedSetDocValues(fieldName); + final SortedSetDocValues values = leafReader.getSortedSetDocValues(fieldName); if (values != null && values.getValueCount() > 0) { - if (values.advance(docid) == docid) { + if (values.advance(localId) == localId) { final List outValues = new LinkedList(); for (long ord = values.nextOrd(); ord != SortedSetDocValues.NO_MORE_ORDS; ord = values.nextOrd()) { final BytesRef value = values.lookupOrd(ord); @@ -785,8 +791,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI switch (dvType) { case NUMERIC: final NumericDocValues ndv = leafReader.getNumericDocValues(fieldName); + if (ndv == null) { + continue; + } Long val; - if (ndv.advance(docid) == docid) { + if (ndv.advance(localId) == localId) { val = ndv.longValue(); } else { continue; @@ -807,8 +816,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI break; case BINARY: BinaryDocValues bdv = leafReader.getBinaryDocValues(fieldName); + if (bdv == null) { + continue; + } BytesRef value; - if (bdv.advance(docid) == docid) { + if (bdv.advance(localId) == localId) { value = BytesRef.deepCopyOf(bdv.binaryValue()); } else { continue; @@ -817,7 +829,10 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI break; case SORTED: SortedDocValues sdv = leafReader.getSortedDocValues(fieldName); - if (sdv.advance(docid) == docid) { + if (sdv == null) { + continue; + } + if (sdv.advance(localId) == localId) { final BytesRef bRef = sdv.binaryValue(); // Special handling for Boolean fields since they're stored as 'T' and 'F'. if (schemaField.getType() instanceof BoolField) { diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByArrayUIF.java b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByArrayUIF.java index dfee257cb9e..d5cceef1aee 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByArrayUIF.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByArrayUIF.java @@ -37,7 +37,7 @@ class FacetFieldProcessorByArrayUIF extends FacetFieldProcessorByArray { @Override protected void findStartAndEndOrds() throws IOException { uif = UnInvertedField.getUnInvertedField(freq.field, fcontext.searcher); - te = uif.getOrdTermsEnum( fcontext.searcher.getLeafReader() ); // "te" can be null + te = uif.getOrdTermsEnum( fcontext.searcher.getSlowAtomicReader() ); // "te" can be null startTermIndex = 0; endTermIndex = uif.numTerms(); // one past the end diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByEnumTermsStream.java b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByEnumTermsStream.java index 005f4d1f174..2ab47132331 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByEnumTermsStream.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByEnumTermsStream.java @@ -156,7 +156,7 @@ class FacetFieldProcessorByEnumTermsStream extends FacetFieldProcessor implement } } - Fields fields = fcontext.searcher.getLeafReader().fields(); + Fields fields = fcontext.searcher.getSlowAtomicReader().fields(); Terms terms = fields == null ? null : fields.terms(sf.getName()); termsEnum = null; @@ -224,7 +224,7 @@ class FacetFieldProcessorByEnumTermsStream extends FacetFieldProcessor implement if (deState == null) { deState = new SolrIndexSearcher.DocsEnumState(); deState.fieldName = sf.getName(); - deState.liveDocs = fcontext.searcher.getLeafReader().getLiveDocs(); + deState.liveDocs = fcontext.searcher.getSlowAtomicReader().getLiveDocs(); deState.termsEnum = termsEnum; deState.postingsEnum = postingsEnum; deState.minSetSizeCached = minDfFilterCache; diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByHashDV.java b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByHashDV.java index ffed5f4635a..f1b5333a231 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByHashDV.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByHashDV.java @@ -197,7 +197,7 @@ class FacetFieldProcessorByHashDV extends FacetFieldProcessor { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, getClass()+" doesn't support prefix"); // yet, but it could } - FieldInfo fieldInfo = fcontext.searcher.getLeafReader().getFieldInfos().fieldInfo(sf.getName()); + FieldInfo fieldInfo = fcontext.searcher.getSlowAtomicReader().getFieldInfos().fieldInfo(sf.getName()); if (fieldInfo != null && fieldInfo.getDocValuesType() != DocValuesType.NUMERIC && fieldInfo.getDocValuesType() != DocValuesType.SORTED) { diff --git a/solr/core/src/java/org/apache/solr/search/facet/FieldUtil.java b/solr/core/src/java/org/apache/solr/search/facet/FieldUtil.java index cd37dc03101..84255b9f9df 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FieldUtil.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FieldUtil.java @@ -40,7 +40,7 @@ public class FieldUtil { public static SortedDocValues getSortedDocValues(QueryContext context, SchemaField field, QParser qparser) throws IOException { - SortedDocValues si = context.searcher().getLeafReader().getSortedDocValues( field.getName() ); + SortedDocValues si = context.searcher().getSlowAtomicReader().getSortedDocValues( field.getName() ); // if (!field.hasDocValues() && (field.getType() instanceof StrField || field.getType() instanceof TextField)) { // } @@ -48,7 +48,7 @@ public class FieldUtil { } public static SortedSetDocValues getSortedSetDocValues(QueryContext context, SchemaField field, QParser qparser) throws IOException { - SortedSetDocValues si = context.searcher().getLeafReader().getSortedSetDocValues(field.getName()); + SortedSetDocValues si = context.searcher().getSlowAtomicReader().getSortedSetDocValues(field.getName()); return si == null ? DocValues.emptySortedSet() : si; } diff --git a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java index ad3baf01bc9..d9a62202d22 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java +++ b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java @@ -136,7 +136,7 @@ public class UnInvertedField extends DocTermOrds { if (deState == null) { deState = new SolrIndexSearcher.DocsEnumState(); deState.fieldName = field; - deState.liveDocs = searcher.getLeafReader().getLiveDocs(); + deState.liveDocs = searcher.getSlowAtomicReader().getLiveDocs(); deState.termsEnum = te; // TODO: check for MultiTermsEnum in SolrIndexSearcher could now fail? deState.postingsEnum = postingsEnum; deState.minSetSizeCached = maxTermDocFreq; @@ -239,7 +239,7 @@ public class UnInvertedField extends DocTermOrds { public TermsEnum getTermsEnum() throws IOException { if (te == null) { - te = getOrdTermsEnum(searcher.getLeafReader()); + te = getOrdTermsEnum(searcher.getSlowAtomicReader()); } return te; } diff --git a/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java b/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java index 40d9948b4f9..756a1a69058 100644 --- a/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java +++ b/solr/core/src/java/org/apache/solr/search/function/OrdFieldSource.java @@ -88,7 +88,7 @@ public class OrdFieldSource extends ValueSource { r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves)); } else { // reuse ordinalmap - r = ((SolrIndexSearcher)o).getLeafReader(); + r = ((SolrIndexSearcher)o).getSlowAtomicReader(); } } else { IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader(); diff --git a/solr/core/src/java/org/apache/solr/search/function/ReverseOrdFieldSource.java b/solr/core/src/java/org/apache/solr/search/function/ReverseOrdFieldSource.java index 44170007511..3ed13f032f5 100644 --- a/solr/core/src/java/org/apache/solr/search/function/ReverseOrdFieldSource.java +++ b/solr/core/src/java/org/apache/solr/search/function/ReverseOrdFieldSource.java @@ -88,7 +88,7 @@ public class ReverseOrdFieldSource extends ValueSource { r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves)); } else { // reuse ordinalmap - r = ((SolrIndexSearcher)o).getLeafReader(); + r = ((SolrIndexSearcher)o).getSlowAtomicReader(); } } else { IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader(); diff --git a/solr/core/src/java/org/apache/solr/search/join/BlockJoinFieldFacetAccumulator.java b/solr/core/src/java/org/apache/solr/search/join/BlockJoinFieldFacetAccumulator.java index dee1f60ecd8..fb4a30cfe00 100644 --- a/solr/core/src/java/org/apache/solr/search/join/BlockJoinFieldFacetAccumulator.java +++ b/solr/core/src/java/org/apache/solr/search/join/BlockJoinFieldFacetAccumulator.java @@ -60,12 +60,12 @@ class BlockJoinFieldFacetAccumulator { fieldType = schemaField.getType(); ordinalMap = null; if (schemaField.multiValued()) { - topSSDV = searcher.getLeafReader().getSortedSetDocValues(fieldName); + topSSDV = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName); if (topSSDV instanceof MultiDocValues.MultiSortedSetDocValues) { ordinalMap = ((MultiDocValues.MultiSortedSetDocValues) topSSDV).mapping; } } else { - SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); + SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName); if (single instanceof MultiDocValues.MultiSortedDocValues) { ordinalMap = ((MultiDocValues.MultiSortedDocValues) single).mapping; } diff --git a/solr/core/src/test/org/apache/solr/request/TestFaceting.java b/solr/core/src/test/org/apache/solr/request/TestFaceting.java index 8fdac58b507..a80669a7c33 100644 --- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java +++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java @@ -82,7 +82,7 @@ public class TestFaceting extends SolrTestCaseJ4 { createIndex(size); req = lrf.makeRequest("q","*:*"); - SortedSetDocValues dv = DocValues.getSortedSet(req.getSearcher().getLeafReader(), proto.field()); + SortedSetDocValues dv = DocValues.getSortedSet(req.getSearcher().getSlowAtomicReader(), proto.field()); assertEquals(size, dv.getValueCount()); @@ -712,16 +712,16 @@ public class TestFaceting extends SolrTestCaseJ4 { RefCounted currentSearcherRef = h.getCore().getSearcher(); try { SolrIndexSearcher currentSearcher = currentSearcherRef.get(); - SortedSetDocValues ui0 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f0_ws"); - SortedSetDocValues ui1 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f1_ws"); - SortedSetDocValues ui2 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f2_ws"); - SortedSetDocValues ui3 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f3_ws"); - SortedSetDocValues ui4 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f4_ws"); - SortedSetDocValues ui5 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f5_ws"); - SortedSetDocValues ui6 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f6_ws"); - SortedSetDocValues ui7 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f7_ws"); - SortedSetDocValues ui8 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f8_ws"); - SortedSetDocValues ui9 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f9_ws"); + SortedSetDocValues ui0 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f0_ws"); + SortedSetDocValues ui1 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f1_ws"); + SortedSetDocValues ui2 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f2_ws"); + SortedSetDocValues ui3 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f3_ws"); + SortedSetDocValues ui4 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f4_ws"); + SortedSetDocValues ui5 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f5_ws"); + SortedSetDocValues ui6 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f6_ws"); + SortedSetDocValues ui7 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f7_ws"); + SortedSetDocValues ui8 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f8_ws"); + SortedSetDocValues ui9 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f9_ws"); assertQ("check threading, more threads than fields", req(methodParam diff --git a/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java b/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java index d31fc5cd38b..30dea854f84 100644 --- a/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java +++ b/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java @@ -63,7 +63,7 @@ public class DocValuesMultiTest extends SolrTestCaseJ4 { final RefCounted searcherRef = core.openNewSearcher(true, true); final SolrIndexSearcher searcher = searcherRef.get(); try { - final LeafReader reader = searcher.getLeafReader(); + final LeafReader reader = searcher.getSlowAtomicReader(); assertEquals(1, reader.numDocs()); final FieldInfos infos = reader.getFieldInfos(); assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("stringdv").getDocValuesType()); diff --git a/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java b/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java index 43eefaa60b5..cc3486e7793 100644 --- a/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java +++ b/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java @@ -76,7 +76,7 @@ public class DocValuesTest extends SolrTestCaseJ4 { final RefCounted searcherRef = core.openNewSearcher(true, true); final SolrIndexSearcher searcher = searcherRef.get(); try { - final LeafReader reader = searcher.getLeafReader(); + final LeafReader reader = searcher.getSlowAtomicReader(); assertEquals(1, reader.numDocs()); final FieldInfos infos = reader.getFieldInfos(); assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("floatdv").getDocValuesType()); @@ -112,20 +112,20 @@ public class DocValuesTest extends SolrTestCaseJ4 { final SchemaField longDv = schema.getField("longdv"); final SchemaField boolDv = schema.getField("booldv"); - FunctionValues values = floatDv.getType().getValueSource(floatDv, null).getValues(null, searcher.getLeafReader().leaves().get(0)); + FunctionValues values = floatDv.getType().getValueSource(floatDv, null).getValues(null, searcher.getSlowAtomicReader().leaves().get(0)); assertEquals(1f, values.floatVal(0), 0f); assertEquals(1f, values.objectVal(0)); - values = intDv.getType().getValueSource(intDv, null).getValues(null, searcher.getLeafReader().leaves().get(0)); + values = intDv.getType().getValueSource(intDv, null).getValues(null, searcher.getSlowAtomicReader().leaves().get(0)); assertEquals(2, values.intVal(0)); assertEquals(2, values.objectVal(0)); - values = doubleDv.getType().getValueSource(doubleDv, null).getValues(null, searcher.getLeafReader().leaves().get(0)); + values = doubleDv.getType().getValueSource(doubleDv, null).getValues(null, searcher.getSlowAtomicReader().leaves().get(0)); assertEquals(3d, values.doubleVal(0), 0d); assertEquals(3d, values.objectVal(0)); - values = longDv.getType().getValueSource(longDv, null).getValues(null, searcher.getLeafReader().leaves().get(0)); + values = longDv.getType().getValueSource(longDv, null).getValues(null, searcher.getSlowAtomicReader().leaves().get(0)); assertEquals(4L, values.longVal(0)); assertEquals(4L, values.objectVal(0)); - values = boolDv.getType().getValueSource(boolDv, null).getValues(null, searcher.getLeafReader().leaves().get(0)); + values = boolDv.getType().getValueSource(boolDv, null).getValues(null, searcher.getSlowAtomicReader().leaves().get(0)); assertEquals("true", values.strVal(0)); assertEquals(true, values.objectVal(0)); diff --git a/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPScore.java b/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPScore.java index 51039d64127..17abf7834f1 100644 --- a/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPScore.java +++ b/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPScore.java @@ -187,7 +187,7 @@ public class TestScoreJoinQPScore extends SolrTestCaseJ4 { final SolrQueryRequest req = req("q", "{!join from=movieId_s to=id score=" + score + " b=200}title:movie", "fl", "id,score", "omitHeader", "true"); SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, new SolrQueryResponse())); - final Query luceneQ = QParser.getParser(req.getParams().get("q"), req).getQuery().rewrite(req.getSearcher().getLeafReader()); + final Query luceneQ = QParser.getParser(req.getParams().get("q"), req).getQuery().rewrite(req.getSearcher().getSlowAtomicReader()); assertTrue(luceneQ instanceof BoostQuery); float boost = ((BoostQuery) luceneQ).getBoost(); assertEquals("" + luceneQ, Float.floatToIntBits(200), Float.floatToIntBits(boost));