Apache Solr open-source search software
SOLR-12880: Show the FacetProcessor class name instead of the FacetRequest in the JSON Facets debug-trace output
Tim Underwoodfbb987282e76
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b8f9f180e67..3c58d35c6dd 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -296,6 +296,9 @@ Improvements* SOLR-12964: Json Facets: use DocValuesIterator advanceExact() instead of advance() in FacetFieldProcessorByHashDV andUniqueSinglevaluedSlotAcc. (Tim Underwood)+* SOLR-12880: Json Facets: Show the FacetProcessor class name instead of the FacetRequest in the JSON Facets debug-trace+ output (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/FacetHeatmap.java b/solr/core/src/java/org/apache/solr/search/facet/FacetHeatmap.javaindex b5e481a1760..c3386e23e72 100644--- a/solr/core/src/java/org/apache/solr/search/facet/FacetHeatmap.java+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetHeatmap.java@@ -208,62 +208,69 @@ public class FacetHeatmap extends FacetRequest {@Overridepublic FacetProcessor createFacetProcessor(FacetContext fcontext) {- return new FacetProcessor(fcontext, this) {- @Override- public void process() throws IOException {- super.process(); // handles domain changes-- //Compute!- final HeatmapFacetCounter.Heatmap heatmap;- try {- heatmap = HeatmapFacetCounter.calcFacets(- strategy,- fcontext.searcher.getTopReaderContext(),- getTopAcceptDocs(fcontext.base, fcontext.searcher), // turn DocSet into Bits- boundsShape,- gridLevel,- maxCells);- } catch (IllegalArgumentException e) {//e.g. too many cells- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e.toString(), e);- }-- //Populate response- response = new SimpleOrderedMap();- response.add("gridLevel", gridLevel);- response.add("columns", heatmap.columns);- response.add("rows", heatmap.rows);- response.add("minX", heatmap.region.getMinX());- response.add("maxX", heatmap.region.getMaxX());- response.add("minY", heatmap.region.getMinY());- response.add("maxY", heatmap.region.getMaxY());+ return new FacetHeatmapProcessor(fcontext);+ }- //A shard request will always be a PNG- String format = fcontext.isShard() ? FORMAT_PNG : FacetHeatmap.this.format;+ // don't use an anonymous class since the getSimpleName() isn't friendly in debug output+ private class FacetHeatmapProcessor extends FacetProcessor {+ public FacetHeatmapProcessor(FacetContext fcontext) {+ super(fcontext, FacetHeatmap.this);+ }- response.add("counts_" + format, formatCountsVal(format, heatmap.columns, heatmap.rows, heatmap.counts, fcontext.getDebugInfo()));+ @Override+ public void process() throws IOException {+ super.process(); // handles domain changes- // note: we do not call processStats or processSubs as it's not supported yet+ //Compute!+ final HeatmapFacetCounter.Heatmap heatmap;+ try {+ heatmap = HeatmapFacetCounter.calcFacets(+ strategy,+ fcontext.searcher.getTopReaderContext(),+ getTopAcceptDocs(fcontext.base, fcontext.searcher), // turn DocSet into Bits+ boundsShape,+ gridLevel,+ maxCells);+ } catch (IllegalArgumentException e) {//e.g. too many cells+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e.toString(), e);}- //TODO this is a general utility that should go elsewhere? DocSetUtil? Then should DocSetBase.getBits go away?- private Bits getTopAcceptDocs(DocSet docSet, SolrIndexSearcher searcher) throws IOException {- if (docSet.size() == searcher.numDocs()) {- 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.getBits ought to be at DocSet level? Though it doesn't know maxDoc but it could?- FixedBitSet bits = new FixedBitSet(searcher.maxDoc());- for (DocIterator iter = docSet.iterator(); iter.hasNext();) {- bits.set(iter.nextDoc());- }- return bits;+ //Populate response+ response = new SimpleOrderedMap();+ response.add("gridLevel", gridLevel);+ response.add("columns", heatmap.columns);+ response.add("rows", heatmap.rows);+ response.add("minX", heatmap.region.getMinX());+ response.add("maxX", heatmap.region.getMaxX());+ response.add("minY", heatmap.region.getMinY());+ response.add("maxY", heatmap.region.getMaxY());++ //A shard request will always be a PNG+ String format = fcontext.isShard() ? FORMAT_PNG : FacetHeatmap.this.format;++ response.add("counts_" + format, formatCountsVal(format, heatmap.columns, heatmap.rows, heatmap.counts, fcontext.getDebugInfo()));++ // note: we do not call processStats or processSubs as it's not supported yet+ }++ //TODO this is a general utility that should go elsewhere? DocSetUtil? Then should DocSetBase.getBits go away?+ private Bits getTopAcceptDocs(DocSet docSet, SolrIndexSearcher searcher) throws IOException {+ if (docSet.size() == searcher.numDocs()) {+ 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.getBits ought to be at DocSet level? Though it doesn't know maxDoc but it could?+ FixedBitSet bits = new FixedBitSet(searcher.maxDoc());+ for (DocIterator iter = docSet.iterator(); iter.hasNext();) {+ bits.set(iter.nextDoc());}+ return bits;}+ }- };}private static Object formatCountsVal(String format, int columns, int rows, int[] counts, FacetDebugInfo debugInfo) {diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.javaindex 658e0fcffc0..4135c87db68 100644--- a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java@@ -371,7 +371,7 @@ public abstract class FacetRequest {debugInfo.setFilter(fcontext.filter.toString());}debugInfo.setReqDescription(getFacetDescription());- debugInfo.setProcessor(getClass().getSimpleName());+ debugInfo.setProcessor(facetProcessor.getClass().getSimpleName());debugInfo.putInfoItem("domainSize", (long) fcontext.base.size());RTimer timer = new RTimer();facetProcessor.process();