SOLR-12882: Eliminate excessive lambda allocation in json facet FacetFieldProcessorByHashDV.collectValFirstPhase

This commit is contained in:
Tim Underwood 2018-11-01 15:05:16 -04:00 committed by David Smiley
parent 05f72a77ef
commit cf445ba549
2 changed files with 14 additions and 4 deletions

View File

@ -252,6 +252,8 @@ Improvements
* SOLR-12892: MapWriter to use CharSequence instead of String (noble)
* SOLR-12882: Eliminate excessive lambda allocation in json facets FacetFieldProcessorByHashDV (Tim Underwood)
================== 7.5.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -430,12 +430,20 @@ class FacetFieldProcessorByHashDV extends FacetFieldProcessor {
// Our countAcc is virtual, so this is not needed:
// countAcc.incrementCount(slot, 1);
super.collectFirstPhase(segDoc, slot, slotNum -> {
Comparable value = calc.bitsToValue(val);
return new SlotContext(sf.getType().getFieldQuery(null, sf, calc.formatValue(value)));
});
super.collectFirstPhase(segDoc, slot, slotContext);
}
/**
* SlotContext to use during all {@link SlotAcc} collection.
*
* This avoids a memory allocation for each invocation of collectValFirstPhase.
*/
private IntFunction<SlotContext> slotContext = (slotNum) -> {
long val = table.vals[slotNum];
Comparable value = calc.bitsToValue(val);
return new SlotContext(sf.getType().getFieldQuery(null, sf, calc.formatValue(value)));
};
private void doRehash(LongCounts table) {
if (collectAcc == null && allBucketsAcc == null) return;