From 59d83f57e12f72ff8db503a0c01b77cb5df354fd Mon Sep 17 00:00:00 2001 From: yonik Date: Wed, 5 Oct 2016 15:15:32 -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 | 4 ++-- .../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 | 24 ++++++++++++------- .../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 ++-- .../ClassificationUpdateProcessorFactory.java | 2 +- .../org/apache/solr/request/TestFaceting.java | 22 ++++++++--------- .../solr/schema/DocValuesMultiTest.java | 2 +- .../org/apache/solr/schema/DocValuesTest.java | 12 +++++----- .../search/join/TestScoreJoinQPScore.java | 2 +- 27 files changed, 74 insertions(+), 63 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index a32bb587a84..e6a14917ed6 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -143,6 +143,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 eb22d90ccfb..736a3a83d02 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); 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 6df92c0f6c7..9026eb34480 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 9b281a9a6b0..77cc90e0297 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 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 MultiSortedDocValues) { ordinalMap = ((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 4001f5a5d63..a4626c7dd55 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 = ((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 MultiSortedDocValues) { ordinalMap = ((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 1034947ca9f..9c93c029a82 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 b3752a87f08..5f9844a7834 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 56cde8f179c..7c88fad4dcf 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -1182,10 +1182,10 @@ 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); docValues = uninvertingReader.getSortedDocValues(collapseField); } else { - docValues = DocValues.getSorted(searcher.getLeafReader(), collapseField); + docValues = DocValues.getSorted(searcher.getSlowAtomicReader(), collapseField); } } else { if(HINT_TOP_FC.equals(hint)) { 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 56cae5a3323..7e16b4b2a33 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 9e0fcd00674..f0b5d6eac48 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -404,7 +404,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; } @@ -745,7 +749,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)) { @@ -753,14 +759,14 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI continue; } - if (!DocValues.getDocsWithField(leafReader, fieldName).get(docid)) { + if (!DocValues.getDocsWithField(leafReader, fieldName).get(localId)) { continue; } if (schemaField.multiValued()) { - final SortedSetDocValues values = reader.getSortedSetDocValues(fieldName); + final SortedSetDocValues values = leafReader.getSortedSetDocValues(fieldName); if (values != null && values.getValueCount() > 0) { - values.setDocument(docid); + values.setDocument(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); @@ -773,7 +779,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI switch (dvType) { case NUMERIC: final NumericDocValues ndv = leafReader.getNumericDocValues(fieldName); - Long val = ndv.get(docid); + Long val = ndv.get(localId); Object newVal = val; if (schemaField.getType() instanceof TrieIntField) { newVal = val.intValue(); @@ -790,18 +796,18 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI break; case BINARY: BinaryDocValues bdv = leafReader.getBinaryDocValues(fieldName); - doc.addField(fieldName, bdv.get(docid)); + doc.addField(fieldName, bdv.get(localId)); break; case SORTED: SortedDocValues sdv = leafReader.getSortedDocValues(fieldName); - int ord = sdv.getOrd(docid); + int ord = sdv.getOrd(localId); if (ord >= 0) { // Special handling for Boolean fields since they're stored as 'T' and 'F'. if (schemaField.getType() instanceof BoolField) { final BytesRef bRef = sdv.lookupOrd(ord); doc.addField(fieldName, schemaField.getType().toObject(schemaField, bRef)); } else { - doc.addField(fieldName, sdv.get(docid).utf8ToString()); + doc.addField(fieldName, sdv.get(localId).utf8ToString()); } } break; 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 fb9341708d6..a17c7abf54d 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 @@ -198,7 +198,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 3b63bd99cb9..7c945261a2b 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 abc9f95426a..ffcf57f9eb0 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 286cd45b308..1174d9b3210 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); topSSDV = single == null ? null : DocValues.singleton(single);// npe friendly code if (single instanceof MultiDocValues.MultiSortedDocValues) { ordinalMap = ((MultiDocValues.MultiSortedDocValues) single).mapping; diff --git a/solr/core/src/java/org/apache/solr/update/processor/ClassificationUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/ClassificationUpdateProcessorFactory.java index f16b42b0386..a54075b7731 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/ClassificationUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/ClassificationUpdateProcessorFactory.java @@ -109,7 +109,7 @@ public class ClassificationUpdateProcessorFactory extends UpdateRequestProcessor @Override public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) { IndexSchema schema = req.getSchema(); - LeafReader leafReader = req.getSearcher().getLeafReader(); + LeafReader leafReader = req.getSearcher().getSlowAtomicReader(); return new ClassificationUpdateProcessor(inputFieldNames, classFieldName, minDf, minTf, k, algorithm, next, leafReader, schema); } 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 90c8b7363ff..4aa137c7d8c 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 d59d3267843..d8a551a4516 100644 --- a/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java +++ b/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java @@ -74,7 +74,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()); @@ -98,20 +98,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));