Fix HyperUniquesAggregatorFactory comparator

This commit is contained in:
jon-wei 2016-03-24 18:38:42 -07:00
parent 980943074b
commit 9afaa2b94a
2 changed files with 11 additions and 23 deletions

View File

@ -21,6 +21,7 @@ package io.druid.query.aggregation.hyperloglog;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Ordering;
import com.metamx.common.IAE;
import com.metamx.common.StringUtils;
import io.druid.query.aggregation.Aggregator;
@ -106,20 +107,7 @@ public class HyperUniquesAggregatorFactory extends AggregatorFactory
@Override
public Comparator getComparator()
{
return new Comparator<HyperLogLogCollector>()
{
@Override
public int compare(HyperLogLogCollector lhs, HyperLogLogCollector rhs)
{
if(lhs == null) {
return -1;
}
if(rhs == null) {
return 1;
}
return lhs.compareTo(rhs);
}
};
return Ordering.<HyperLogLogCollector>natural().nullsFirst();
}
@Override

View File

@ -377,17 +377,17 @@ public class TopNQueryRunnerTest
new TopNResultValue(
Arrays.<Map<String, Object>>asList(
ImmutableMap.<String, Object>builder()
.put("market", "total_market")
.put("uniques", 0)
.build(),
.put("market", "spot")
.put("uniques", 0)
.build(),
ImmutableMap.<String, Object>builder()
.put("market", "spot")
.put("uniques", 0)
.build(),
.put("market", "total_market")
.put("uniques", 0)
.build(),
ImmutableMap.<String, Object>builder()
.put("market", "upfront")
.put("uniques", 0)
.build()
.put("market", "upfront")
.put("uniques", 0)
.build()
)
)
)