diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index a6519e0f57b..6f8c449eae2 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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. 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 4c0b244c1dd..c246c210217 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 @@ -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 = (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;