From 2ed1573adc9a7e340d1ab6ccaabf05d1bf024be3 Mon Sep 17 00:00:00 2001 From: yonik Date: Tue, 5 Sep 2017 14:14:19 -0400 Subject: [PATCH] SOLR-11317: change FacetStream to handle int/long as well as double for metrics --- .../test/org/apache/solr/handler/TestSQLHandler.java | 3 --- .../solr/client/solrj/io/stream/FacetStream.java | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java index 32060029bd6..70ebd0aa788 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java @@ -23,7 +23,6 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; -import org.apache.lucene.util.LuceneTestCase; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -38,13 +37,11 @@ import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; - import org.apache.solr.common.util.NamedList; import org.junit.After; import org.junit.Before; import org.junit.Test; -@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-11317") public class TestSQLHandler extends AbstractFullDistribZkTestBase { static { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java index e11bf023276..639782e1707 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java @@ -495,11 +495,15 @@ public class FacetStream extends TupleStream implements Expressible { for(Metric metric : _metrics) { String identifier = metric.getIdentifier(); if(!identifier.startsWith("count(")) { - double d = (double)bucket.get("facet_"+m); + Number d = ((Number)bucket.get("facet_"+m)); if(metric.outputLong) { - t.put(identifier, Math.round(d)); + if (d instanceof Long || d instanceof Integer) { + t.put(identifier, d.longValue()); + } else { + t.put(identifier, Math.round(d.doubleValue())); + } } else { - t.put(identifier, d); + t.put(identifier, d.doubleValue()); } ++m; } else {