You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2017/04/20 21:47:55 UTC
lucene-solr:branch_6x: SOLR-10499: facet.heatmap DocSet to Bits
optimizations
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 0902c9440 -> eee1b389e
SOLR-10499: facet.heatmap DocSet to Bits optimizations
(cherry picked from commit 9911962)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/eee1b389
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/eee1b389
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/eee1b389
Branch: refs/heads/branch_6x
Commit: eee1b389edac7aac73ab1e9e18b06ce77f7e1851
Parents: 0902c94
Author: David Smiley <ds...@apache.org>
Authored: Thu Apr 20 17:46:28 2017 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Thu Apr 20 17:47:47 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../handler/component/SpatialHeatmapFacets.java | 41 ++++++++++----------
2 files changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eee1b389/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 91115c4..786c330 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -85,6 +85,9 @@ Optimizations
instance if it already is modifiable, otherwise creates a new ModifiableSolrParams instance.
(J�rg Rathlev via Koji)
+* SOLR-10499: facet.heatmap is now significantly faster when the docset (base query) matches everything and there are no
+ deleted docs. It's also faster when the docset matches a small fraction of the index or none. (David Smiley)
+
Bug Fixes
----------------------
* SOLR-10281: ADMIN_PATHS is duplicated in two places and inconsistent. This can cause automatic
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eee1b389/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java b/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
index 4ad882c..9bca5c7 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
@@ -32,6 +32,9 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import org.apache.lucene.util.FixedBitSet;
+import org.apache.solr.search.DocIterator;
+import org.apache.solr.search.SolrIndexSearcher;
import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.shape.Shape;
import org.apache.lucene.spatial.prefix.HeatmapFacetCounter;
@@ -134,32 +137,13 @@ public class SpatialHeatmapFacets {
gridLevel = strategy.getGrid().getLevelForDistance(distErr);
}
- // Turn docSet into Bits
- Bits topAcceptDocs;
- if (docSet instanceof BitDocSet) {
- BitDocSet set = (BitDocSet) docSet;
- topAcceptDocs = set.getBits();
- } else {
- topAcceptDocs = new Bits() {
- @Override
- public boolean get(int index) {
- return docSet.exists(index);
- }
-
- @Override
- public int length() {
- return rb.req.getSearcher().maxDoc();
- }
- };
- }
-
//Compute!
final HeatmapFacetCounter.Heatmap heatmap;
try {
heatmap = HeatmapFacetCounter.calcFacets(
strategy,
rb.req.getSearcher().getTopReaderContext(),
- topAcceptDocs,
+ getTopAcceptDocs(docSet, rb.req.getSearcher()), // turn DocSet into Bits
boundsShape,
gridLevel,
params.getFieldInt(fieldKey, FacetParams.FACET_HEATMAP_MAX_CELLS, 100_000) // will throw if exceeded
@@ -190,6 +174,23 @@ public class SpatialHeatmapFacets {
return result;
}
+ private static Bits getTopAcceptDocs(DocSet docSet, SolrIndexSearcher searcher) throws IOException {
+ if (searcher.getLiveDocs() == docSet) {
+ return null; // means match everything (all live docs). This can speedup things a lot.
+ } else if (docSet.size() == 0) {
+ return new Bits.MatchNoBits(searcher.maxDoc()); // can speedup things a lot
+ } else if (docSet instanceof BitDocSet) {
+ return ((BitDocSet) docSet).getBits();
+ } else {
+ // TODO DocSetBase.calcBits ought to be at DocSet level?
+ FixedBitSet bits = new FixedBitSet(searcher.maxDoc());
+ for (DocIterator iter = docSet.iterator(); iter.hasNext();) {
+ bits.set(iter.nextDoc());
+ }
+ return bits;
+ }
+ }
+
private static void formatCountsAndAddToNL(String fieldKey, ResponseBuilder rb, SolrParams params,
int columns, int rows, int[] counts, NamedList<Object> result) {
final String format = params.getFieldParam(fieldKey, FacetParams.FACET_HEATMAP_FORMAT, FORMAT_INTS2D);