lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [10/26] lucene-solr:jira/solr-12730: SOLR-12882: Eliminate excessive lambda allocation in json facet FacetFieldProcessorByHashDV.collectValFirstPhase
Date Mon, 05 Nov 2018 18:56:28 GMT
SOLR-12882: Eliminate excessive lambda allocation in json facet FacetFieldProcessorByHashDV.collectValFirstPhase


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cf445ba5
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cf445ba5
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cf445ba5

Branch: refs/heads/jira/solr-12730
Commit: cf445ba54998710466a7c6cb489d3162d20d127a
Parents: 05f72a77
Author: Tim Underwood <timunderwood@gmail.com>
Authored: Thu Nov 1 15:05:16 2018 -0400
Committer: David Smiley <dsmiley@apache.org>
Committed: Thu Nov 1 15:05:16 2018 -0400

----------------------------------------------------------------------
 solr/CHANGES.txt                                    |  2 ++
 .../search/facet/FacetFieldProcessorByHashDV.java   | 16 ++++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cf445ba5/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index a6519e0..6f8c449 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.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cf445ba5/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessorByHashDV.java
----------------------------------------------------------------------
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 4c0b244..c246c21 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> 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;
 


Mime
View raw message