SOLR-9592: use correct leaf reader rather than top-level reader in SolrIndexReaderm.decorateDocValues

This commit is contained in:
yonik 2016-10-05 15:15:32 -04:00
parent 3d0f942502
commit 59d83f57e1
27 changed files with 74 additions and 63 deletions

View File

@ -143,6 +143,11 @@ Optimizations
* SOLR-9446: Leader failure after creating a freshly replicated index can send nodes into recovery even if * SOLR-9446: Leader failure after creating a freshly replicated index can send nodes into recovery even if
index was not changed (Pushkar Raste, noble) 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 Other Changes
---------------------- ----------------------

View File

@ -340,7 +340,7 @@ public class LukeRequestHandler extends RequestHandlerBase
fields = new TreeSet<>(Arrays.asList(fl.split( "[,\\s]+" ))); fields = new TreeSet<>(Arrays.asList(fl.split( "[,\\s]+" )));
} }
LeafReader reader = searcher.getLeafReader(); LeafReader reader = searcher.getSlowAtomicReader();
IndexSchema schema = searcher.getSchema(); IndexSchema schema = searcher.getSchema();
// Don't be tempted to put this in the loop below, the whole point here is to alphabetize the fields! // Don't be tempted to put this in the loop below, the whole point here is to alphabetize the fields!

View File

@ -208,7 +208,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia
} }
SolrIndexSearcher searcher = req.getSearcher(); SolrIndexSearcher searcher = req.getSearcher();
LeafReader reader = searcher.getLeafReader(); LeafReader reader = searcher.getSlowAtomicReader();
FieldType fieldType = searcher.getSchema().getField(field).getType(); 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)) { if(CollapsingQParserPlugin.HINT_TOP_FC.equals(hint)) {
Map<String, UninvertingReader.Type> mapping = new HashMap(); Map<String, UninvertingReader.Type> mapping = new HashMap();
mapping.put(field, UninvertingReader.Type.SORTED); 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); values = uninvertingReader.getSortedDocValues(field);
} else { } else {
values = DocValues.getSorted(reader, field); values = DocValues.getSorted(reader, field);

View File

@ -64,7 +64,7 @@ public class FieldFacetStats {
this.facet_sf = facet_sf; this.facet_sf = facet_sf;
this.name = facet_sf.getName(); this.name = facet_sf.getName();
topLevelReader = searcher.getLeafReader(); topLevelReader = searcher.getSlowAtomicReader();
valueSource = facet_sf.getType().getValueSource(facet_sf, null); valueSource = facet_sf.getType().getValueSource(facet_sf, null);
facetStatsValues = new HashMap<>(); facetStatsValues = new HashMap<>();

View File

@ -136,7 +136,7 @@ public class TermsComponent extends SearchComponent {
boolean raw = params.getBool(TermsParams.TERMS_RAW, false); 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(); Fields lfields = indexReader.fields();
for (String field : fields) { for (String field : fields) {

View File

@ -220,7 +220,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
try { try {
// It'd be nice to know if payloads are on the tokenStream but the presence of the attribute isn't a good // It'd be nice to know if payloads are on the tokenStream but the presence of the attribute isn't a good
// indicator. // indicator.
final Terms terms = request.getSearcher().getLeafReader().fields().terms(fieldName); final Terms terms = request.getSearcher().getSlowAtomicReader().fields().terms(fieldName);
if (terms != null) { if (terms != null) {
defaultPayloads = terms.hasPayloads(); 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 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 // Highlight each document
NamedList fragments = new SimpleOrderedMap(); NamedList fragments = new SimpleOrderedMap();

View File

@ -69,12 +69,12 @@ public class DocValuesFacets {
final SortedSetDocValues si; // for term lookups only final SortedSetDocValues si; // for term lookups only
OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones
if (multiValued) { if (multiValued) {
si = searcher.getLeafReader().getSortedSetDocValues(fieldName); si = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName);
if (si instanceof MultiSortedSetDocValues) { if (si instanceof MultiSortedSetDocValues) {
ordinalMap = ((MultiSortedSetDocValues)si).mapping; ordinalMap = ((MultiSortedSetDocValues)si).mapping;
} }
} else { } else {
SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName);
si = single == null ? null : DocValues.singleton(single); si = single == null ? null : DocValues.singleton(single);
if (single instanceof MultiSortedDocValues) { if (single instanceof MultiSortedDocValues) {
ordinalMap = ((MultiSortedDocValues)single).mapping; ordinalMap = ((MultiSortedDocValues)single).mapping;

View File

@ -83,13 +83,13 @@ public class DocValuesStats {
SortedSetDocValues si; // for term lookups only SortedSetDocValues si; // for term lookups only
OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones OrdinalMap ordinalMap = null; // for mapping per-segment ords to global ones
if (multiValued) { if (multiValued) {
si = searcher.getLeafReader().getSortedSetDocValues(fieldName); si = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName);
if (si instanceof MultiSortedSetDocValues) { if (si instanceof MultiSortedSetDocValues) {
ordinalMap = ((MultiSortedSetDocValues)si).mapping; ordinalMap = ((MultiSortedSetDocValues)si).mapping;
} }
} else { } else {
SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName);
si = single == null ? null : DocValues.singleton(single); si = single == null ? null : DocValues.singleton(single);
if (single instanceof MultiSortedDocValues) { if (single instanceof MultiSortedDocValues) {
ordinalMap = ((MultiSortedDocValues)single).mapping; ordinalMap = ((MultiSortedDocValues)single).mapping;

View File

@ -266,7 +266,7 @@ final class NumericFacets {
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
alreadySeen.add(result.getName(i)); alreadySeen.add(result.getName(i));
} }
final Terms terms = searcher.getLeafReader().terms(fieldName); final Terms terms = searcher.getSlowAtomicReader().terms(fieldName);
if (terms != null) { if (terms != null) {
final String prefixStr = TrieField.getMainValuePrefix(ft); final String prefixStr = TrieField.getMainValuePrefix(ft);
final BytesRef prefix; final BytesRef prefix;
@ -319,7 +319,7 @@ final class NumericFacets {
final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx)); final FunctionValues values = vs.getValues(Collections.emptyMap(), leaves.get(readerIdx));
counts.put(values.strVal(entry.docID - leaves.get(readerIdx).docBase), entry.count); 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) { if (terms != null) {
final String prefixStr = TrieField.getMainValuePrefix(ft); final String prefixStr = TrieField.getMainValuePrefix(ft);
final BytesRef prefix; final BytesRef prefix;

View File

@ -859,7 +859,7 @@ public class SimpleFacets {
IndexSchema schema = searcher.getSchema(); IndexSchema schema = searcher.getSchema();
LeafReader r = searcher.getLeafReader(); LeafReader r = searcher.getSlowAtomicReader();
FieldType ft = schema.getFieldType(field); FieldType ft = schema.getFieldType(field);
boolean sortByCount = sort.equals("count") || sort.equals("true"); boolean sortByCount = sort.equals("count") || sort.equals("true");

View File

@ -381,7 +381,7 @@ public class SortingResponseWriter implements QueryResponseWriter {
sortValues[i] = new LongValue(field, new LongAsc()); sortValues[i] = new LongValue(field, new LongAsc());
} }
} else if(ft instanceof StrField) { } else if(ft instanceof StrField) {
LeafReader reader = searcher.getLeafReader(); LeafReader reader = searcher.getSlowAtomicReader();
SortedDocValues vals = reader.getSortedDocValues(field); SortedDocValues vals = reader.getSortedDocValues(field);
if(reverse) { if(reverse) {
sortValues[i] = new StringValue(vals, field, new IntDesc()); 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 // 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) // _and_ since "F" happens to sort before "T" (thus false sorts "less" than true)
// we can just use the existing StringValue here. // we can just use the existing StringValue here.
LeafReader reader = searcher.getLeafReader(); LeafReader reader = searcher.getSlowAtomicReader();
SortedDocValues vals = reader.getSortedDocValues(field); SortedDocValues vals = reader.getSortedDocValues(field);
if(reverse) { if(reverse) {
sortValues[i] = new StringValue(vals, field, new IntDesc()); sortValues[i] = new StringValue(vals, field, new IntDesc());

View File

@ -1182,10 +1182,10 @@ public class CollapsingQParserPlugin extends QParserPlugin {
Map<String, UninvertingReader.Type> mapping = new HashMap(); Map<String, UninvertingReader.Type> mapping = new HashMap();
mapping.put(collapseField, UninvertingReader.Type.SORTED); 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); docValues = uninvertingReader.getSortedDocValues(collapseField);
} else { } else {
docValues = DocValues.getSorted(searcher.getLeafReader(), collapseField); docValues = DocValues.getSorted(searcher.getSlowAtomicReader(), collapseField);
} }
} else { } else {
if(HINT_TOP_FC.equals(hint)) { if(HINT_TOP_FC.equals(hint)) {

View File

@ -299,8 +299,8 @@ class JoinQuery extends Query {
fastForRandomSet = new HashDocSet(sset.getDocs(), 0, sset.size()); fastForRandomSet = new HashDocSet(sset.getDocs(), 0, sset.size());
} }
Fields fromFields = fromSearcher.getLeafReader().fields(); Fields fromFields = fromSearcher.getSlowAtomicReader().fields();
Fields toFields = fromSearcher==toSearcher ? fromFields : toSearcher.getLeafReader().fields(); Fields toFields = fromSearcher==toSearcher ? fromFields : toSearcher.getSlowAtomicReader().fields();
if (fromFields == null) return DocSet.EMPTY; if (fromFields == null) return DocSet.EMPTY;
Terms terms = fromFields.terms(fromField); Terms terms = fromFields.terms(fromField);
Terms toTerms = toFields.terms(toField); Terms toTerms = toFields.terms(toField);
@ -322,8 +322,8 @@ class JoinQuery extends Query {
} }
} }
Bits fromLiveDocs = fromSearcher.getLeafReader().getLiveDocs(); Bits fromLiveDocs = fromSearcher.getSlowAtomicReader().getLiveDocs();
Bits toLiveDocs = fromSearcher == toSearcher ? fromLiveDocs : toSearcher.getLeafReader().getLiveDocs(); Bits toLiveDocs = fromSearcher == toSearcher ? fromLiveDocs : toSearcher.getSlowAtomicReader().getLiveDocs();
fromDeState = new SolrIndexSearcher.DocsEnumState(); fromDeState = new SolrIndexSearcher.DocsEnumState();
fromDeState.fieldName = fromField; fromDeState.fieldName = fromField;

View File

@ -404,7 +404,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
return reader.docFreq(term); 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; return leafReader;
} }
@ -745,7 +749,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
*/ */
public void decorateDocValueFields(@SuppressWarnings("rawtypes") SolrDocumentBase doc, int docid, Set<String> fields) public void decorateDocValueFields(@SuppressWarnings("rawtypes") SolrDocumentBase doc, int docid, Set<String> fields)
throws IOException { 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) { for (String fieldName : fields) {
final SchemaField schemaField = schema.getFieldOrNull(fieldName); final SchemaField schemaField = schema.getFieldOrNull(fieldName);
if (schemaField == null || !schemaField.hasDocValues() || doc.containsKey(fieldName)) { if (schemaField == null || !schemaField.hasDocValues() || doc.containsKey(fieldName)) {
@ -753,14 +759,14 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
continue; continue;
} }
if (!DocValues.getDocsWithField(leafReader, fieldName).get(docid)) { if (!DocValues.getDocsWithField(leafReader, fieldName).get(localId)) {
continue; continue;
} }
if (schemaField.multiValued()) { if (schemaField.multiValued()) {
final SortedSetDocValues values = reader.getSortedSetDocValues(fieldName); final SortedSetDocValues values = leafReader.getSortedSetDocValues(fieldName);
if (values != null && values.getValueCount() > 0) { if (values != null && values.getValueCount() > 0) {
values.setDocument(docid); values.setDocument(localId);
final List<Object> outValues = new LinkedList<Object>(); final List<Object> outValues = new LinkedList<Object>();
for (long ord = values.nextOrd(); ord != SortedSetDocValues.NO_MORE_ORDS; ord = values.nextOrd()) { for (long ord = values.nextOrd(); ord != SortedSetDocValues.NO_MORE_ORDS; ord = values.nextOrd()) {
final BytesRef value = values.lookupOrd(ord); final BytesRef value = values.lookupOrd(ord);
@ -773,7 +779,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
switch (dvType) { switch (dvType) {
case NUMERIC: case NUMERIC:
final NumericDocValues ndv = leafReader.getNumericDocValues(fieldName); final NumericDocValues ndv = leafReader.getNumericDocValues(fieldName);
Long val = ndv.get(docid); Long val = ndv.get(localId);
Object newVal = val; Object newVal = val;
if (schemaField.getType() instanceof TrieIntField) { if (schemaField.getType() instanceof TrieIntField) {
newVal = val.intValue(); newVal = val.intValue();
@ -790,18 +796,18 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
break; break;
case BINARY: case BINARY:
BinaryDocValues bdv = leafReader.getBinaryDocValues(fieldName); BinaryDocValues bdv = leafReader.getBinaryDocValues(fieldName);
doc.addField(fieldName, bdv.get(docid)); doc.addField(fieldName, bdv.get(localId));
break; break;
case SORTED: case SORTED:
SortedDocValues sdv = leafReader.getSortedDocValues(fieldName); SortedDocValues sdv = leafReader.getSortedDocValues(fieldName);
int ord = sdv.getOrd(docid); int ord = sdv.getOrd(localId);
if (ord >= 0) { if (ord >= 0) {
// Special handling for Boolean fields since they're stored as 'T' and 'F'. // Special handling for Boolean fields since they're stored as 'T' and 'F'.
if (schemaField.getType() instanceof BoolField) { if (schemaField.getType() instanceof BoolField) {
final BytesRef bRef = sdv.lookupOrd(ord); final BytesRef bRef = sdv.lookupOrd(ord);
doc.addField(fieldName, schemaField.getType().toObject(schemaField, bRef)); doc.addField(fieldName, schemaField.getType().toObject(schemaField, bRef));
} else { } else {
doc.addField(fieldName, sdv.get(docid).utf8ToString()); doc.addField(fieldName, sdv.get(localId).utf8ToString());
} }
} }
break; break;

View File

@ -37,7 +37,7 @@ class FacetFieldProcessorByArrayUIF extends FacetFieldProcessorByArray {
@Override @Override
protected void findStartAndEndOrds() throws IOException { protected void findStartAndEndOrds() throws IOException {
uif = UnInvertedField.getUnInvertedField(freq.field, fcontext.searcher); 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; startTermIndex = 0;
endTermIndex = uif.numTerms(); // one past the end endTermIndex = uif.numTerms(); // one past the end

View File

@ -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()); Terms terms = fields == null ? null : fields.terms(sf.getName());
termsEnum = null; termsEnum = null;
@ -224,7 +224,7 @@ class FacetFieldProcessorByEnumTermsStream extends FacetFieldProcessor implement
if (deState == null) { if (deState == null) {
deState = new SolrIndexSearcher.DocsEnumState(); deState = new SolrIndexSearcher.DocsEnumState();
deState.fieldName = sf.getName(); deState.fieldName = sf.getName();
deState.liveDocs = fcontext.searcher.getLeafReader().getLiveDocs(); deState.liveDocs = fcontext.searcher.getSlowAtomicReader().getLiveDocs();
deState.termsEnum = termsEnum; deState.termsEnum = termsEnum;
deState.postingsEnum = postingsEnum; deState.postingsEnum = postingsEnum;
deState.minSetSizeCached = minDfFilterCache; deState.minSetSizeCached = minDfFilterCache;

View File

@ -198,7 +198,7 @@ class FacetFieldProcessorByHashDV extends FacetFieldProcessor {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
getClass()+" doesn't support prefix"); // yet, but it could 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 && if (fieldInfo != null &&
fieldInfo.getDocValuesType() != DocValuesType.NUMERIC && fieldInfo.getDocValuesType() != DocValuesType.NUMERIC &&
fieldInfo.getDocValuesType() != DocValuesType.SORTED) { fieldInfo.getDocValuesType() != DocValuesType.SORTED) {

View File

@ -40,7 +40,7 @@ public class FieldUtil {
public static SortedDocValues getSortedDocValues(QueryContext context, SchemaField field, QParser qparser) throws IOException { 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)) { // 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 { 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; return si == null ? DocValues.emptySortedSet() : si;
} }

View File

@ -136,7 +136,7 @@ public class UnInvertedField extends DocTermOrds {
if (deState == null) { if (deState == null) {
deState = new SolrIndexSearcher.DocsEnumState(); deState = new SolrIndexSearcher.DocsEnumState();
deState.fieldName = field; 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.termsEnum = te; // TODO: check for MultiTermsEnum in SolrIndexSearcher could now fail?
deState.postingsEnum = postingsEnum; deState.postingsEnum = postingsEnum;
deState.minSetSizeCached = maxTermDocFreq; deState.minSetSizeCached = maxTermDocFreq;
@ -239,7 +239,7 @@ public class UnInvertedField extends DocTermOrds {
public TermsEnum getTermsEnum() throws IOException { public TermsEnum getTermsEnum() throws IOException {
if (te == null) { if (te == null) {
te = getOrdTermsEnum(searcher.getLeafReader()); te = getOrdTermsEnum(searcher.getSlowAtomicReader());
} }
return te; return te;
} }

View File

@ -88,7 +88,7 @@ public class OrdFieldSource extends ValueSource {
r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves)); r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves));
} else { } else {
// reuse ordinalmap // reuse ordinalmap
r = ((SolrIndexSearcher)o).getLeafReader(); r = ((SolrIndexSearcher)o).getSlowAtomicReader();
} }
} else { } else {
IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader(); IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();

View File

@ -88,7 +88,7 @@ public class ReverseOrdFieldSource extends ValueSource {
r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves)); r = SlowCompositeReaderWrapper.wrap(new MultiReader(insaneLeaves));
} else { } else {
// reuse ordinalmap // reuse ordinalmap
r = ((SolrIndexSearcher)o).getLeafReader(); r = ((SolrIndexSearcher)o).getSlowAtomicReader();
} }
} else { } else {
IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader(); IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();

View File

@ -60,12 +60,12 @@ class BlockJoinFieldFacetAccumulator {
fieldType = schemaField.getType(); fieldType = schemaField.getType();
ordinalMap = null; ordinalMap = null;
if (schemaField.multiValued()) { if (schemaField.multiValued()) {
topSSDV = searcher.getLeafReader().getSortedSetDocValues(fieldName); topSSDV = searcher.getSlowAtomicReader().getSortedSetDocValues(fieldName);
if (topSSDV instanceof MultiDocValues.MultiSortedSetDocValues) { if (topSSDV instanceof MultiDocValues.MultiSortedSetDocValues) {
ordinalMap = ((MultiDocValues.MultiSortedSetDocValues) topSSDV).mapping; ordinalMap = ((MultiDocValues.MultiSortedSetDocValues) topSSDV).mapping;
} }
} else { } else {
SortedDocValues single = searcher.getLeafReader().getSortedDocValues(fieldName); SortedDocValues single = searcher.getSlowAtomicReader().getSortedDocValues(fieldName);
topSSDV = single == null ? null : DocValues.singleton(single);// npe friendly code topSSDV = single == null ? null : DocValues.singleton(single);// npe friendly code
if (single instanceof MultiDocValues.MultiSortedDocValues) { if (single instanceof MultiDocValues.MultiSortedDocValues) {
ordinalMap = ((MultiDocValues.MultiSortedDocValues) single).mapping; ordinalMap = ((MultiDocValues.MultiSortedDocValues) single).mapping;

View File

@ -109,7 +109,7 @@ public class ClassificationUpdateProcessorFactory extends UpdateRequestProcessor
@Override @Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) { public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
IndexSchema schema = req.getSchema(); 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); return new ClassificationUpdateProcessor(inputFieldNames, classFieldName, minDf, minTf, k, algorithm, next, leafReader, schema);
} }

View File

@ -82,7 +82,7 @@ public class TestFaceting extends SolrTestCaseJ4 {
createIndex(size); createIndex(size);
req = lrf.makeRequest("q","*:*"); 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()); assertEquals(size, dv.getValueCount());
@ -712,16 +712,16 @@ public class TestFaceting extends SolrTestCaseJ4 {
RefCounted<SolrIndexSearcher> currentSearcherRef = h.getCore().getSearcher(); RefCounted<SolrIndexSearcher> currentSearcherRef = h.getCore().getSearcher();
try { try {
SolrIndexSearcher currentSearcher = currentSearcherRef.get(); SolrIndexSearcher currentSearcher = currentSearcherRef.get();
SortedSetDocValues ui0 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f0_ws"); SortedSetDocValues ui0 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f0_ws");
SortedSetDocValues ui1 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f1_ws"); SortedSetDocValues ui1 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f1_ws");
SortedSetDocValues ui2 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f2_ws"); SortedSetDocValues ui2 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f2_ws");
SortedSetDocValues ui3 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f3_ws"); SortedSetDocValues ui3 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f3_ws");
SortedSetDocValues ui4 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f4_ws"); SortedSetDocValues ui4 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f4_ws");
SortedSetDocValues ui5 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f5_ws"); SortedSetDocValues ui5 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f5_ws");
SortedSetDocValues ui6 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f6_ws"); SortedSetDocValues ui6 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f6_ws");
SortedSetDocValues ui7 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f7_ws"); SortedSetDocValues ui7 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f7_ws");
SortedSetDocValues ui8 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f8_ws"); SortedSetDocValues ui8 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f8_ws");
SortedSetDocValues ui9 = DocValues.getSortedSet(currentSearcher.getLeafReader(), "f9_ws"); SortedSetDocValues ui9 = DocValues.getSortedSet(currentSearcher.getSlowAtomicReader(), "f9_ws");
assertQ("check threading, more threads than fields", assertQ("check threading, more threads than fields",
req(methodParam req(methodParam

View File

@ -63,7 +63,7 @@ public class DocValuesMultiTest extends SolrTestCaseJ4 {
final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true); final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
final SolrIndexSearcher searcher = searcherRef.get(); final SolrIndexSearcher searcher = searcherRef.get();
try { try {
final LeafReader reader = searcher.getLeafReader(); final LeafReader reader = searcher.getSlowAtomicReader();
assertEquals(1, reader.numDocs()); assertEquals(1, reader.numDocs());
final FieldInfos infos = reader.getFieldInfos(); final FieldInfos infos = reader.getFieldInfos();
assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("stringdv").getDocValuesType()); assertEquals(DocValuesType.SORTED_SET, infos.fieldInfo("stringdv").getDocValuesType());

View File

@ -74,7 +74,7 @@ public class DocValuesTest extends SolrTestCaseJ4 {
final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true); final RefCounted<SolrIndexSearcher> searcherRef = core.openNewSearcher(true, true);
final SolrIndexSearcher searcher = searcherRef.get(); final SolrIndexSearcher searcher = searcherRef.get();
try { try {
final LeafReader reader = searcher.getLeafReader(); final LeafReader reader = searcher.getSlowAtomicReader();
assertEquals(1, reader.numDocs()); assertEquals(1, reader.numDocs());
final FieldInfos infos = reader.getFieldInfos(); final FieldInfos infos = reader.getFieldInfos();
assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("floatdv").getDocValuesType()); assertEquals(DocValuesType.NUMERIC, infos.fieldInfo("floatdv").getDocValuesType());
@ -98,20 +98,20 @@ public class DocValuesTest extends SolrTestCaseJ4 {
final SchemaField longDv = schema.getField("longdv"); final SchemaField longDv = schema.getField("longdv");
final SchemaField boolDv = schema.getField("booldv"); 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.floatVal(0), 0f);
assertEquals(1f, values.objectVal(0)); 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.intVal(0));
assertEquals(2, values.objectVal(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.doubleVal(0), 0d);
assertEquals(3d, values.objectVal(0)); 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.longVal(0));
assertEquals(4L, values.objectVal(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.strVal(0));
assertEquals(true, values.objectVal(0)); assertEquals(true, values.objectVal(0));

View File

@ -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"); 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())); 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); assertTrue(luceneQ instanceof BoostQuery);
float boost = ((BoostQuery) luceneQ).getBoost(); float boost = ((BoostQuery) luceneQ).getBoost();
assertEquals("" + luceneQ, Float.floatToIntBits(200), Float.floatToIntBits(boost)); assertEquals("" + luceneQ, Float.floatToIntBits(200), Float.floatToIntBits(boost));