SOLR-9772: reuse comparator when deriving fieldSortValues

This commit is contained in:
yonik 2016-11-17 10:56:37 -05:00
parent f9a0693bf9
commit 738198ef34
2 changed files with 8 additions and 5 deletions

View File

@ -128,6 +128,9 @@ Optimizations
* SOLR-9726: Reduce number of lookupOrd calls made by the DocValuesFacets.getCounts method. * SOLR-9726: Reduce number of lookupOrd calls made by the DocValuesFacets.getCounts method.
(Jonny Marks via Christine Poerschke) (Jonny Marks via Christine Poerschke)
* SOLR-9772: Deriving distributed sort values (fieldSortValues) should reuse
comparator and only invalidate leafComparator. (John Call via yonik)
Bug Fixes Bug Fixes
---------------------- ----------------------
* SOLR-9701: NPE in export handler when "fl" parameter is omitted. * SOLR-9701: NPE in export handler when "fl" parameter is omitted.

View File

@ -616,7 +616,7 @@ public class QueryComponent extends SearchComponent
// :TODO: would be simpler to always serialize every position of SortField[] // :TODO: would be simpler to always serialize every position of SortField[]
if (type==SortField.Type.SCORE || type==SortField.Type.DOC) continue; if (type==SortField.Type.SCORE || type==SortField.Type.DOC) continue;
FieldComparator<?> comparator = null; FieldComparator<?> comparator = sortField.getComparator(1,0);
LeafFieldComparator leafComparator = null; LeafFieldComparator leafComparator = null;
Object[] vals = new Object[nDocs]; Object[] vals = new Object[nDocs];
@ -633,13 +633,13 @@ public class QueryComponent extends SearchComponent
idx = ReaderUtil.subIndex(doc, leaves); idx = ReaderUtil.subIndex(doc, leaves);
currentLeaf = leaves.get(idx); currentLeaf = leaves.get(idx);
if (idx != lastIdx) { if (idx != lastIdx) {
// we switched segments. invalidate comparator. // we switched segments. invalidate leafComparator.
comparator = null; lastIdx = idx;
leafComparator = null;
} }
} }
if (comparator == null) { if (leafComparator == null) {
comparator = sortField.getComparator(1,0);
leafComparator = comparator.getLeafComparator(currentLeaf); leafComparator = comparator.getLeafComparator(currentLeaf);
} }