SOLR-11317: change FacetStream to handle int/long as well as double for metrics

This commit is contained in:
yonik 2017-09-05 14:14:19 -04:00
parent ffb7e4f2a5
commit 2ed1573adc
2 changed files with 7 additions and 6 deletions

View File

@ -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 {

View File

@ -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 {