diff --git a/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java index cc8ff7ba431..852b4fa323d 100644 --- a/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/hyperloglog/HyperUniquesAggregatorFactory.java @@ -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() - { - @Override - public int compare(HyperLogLogCollector lhs, HyperLogLogCollector rhs) - { - if(lhs == null) { - return -1; - } - if(rhs == null) { - return 1; - } - return lhs.compareTo(rhs); - } - }; + return Ordering.natural().nullsFirst(); } @Override diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java index f822c18ec21..4bee2f23aae 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java @@ -377,17 +377,17 @@ public class TopNQueryRunnerTest new TopNResultValue( Arrays.>asList( ImmutableMap.builder() - .put("market", "total_market") - .put("uniques", 0) - .build(), + .put("market", "spot") + .put("uniques", 0) + .build(), ImmutableMap.builder() - .put("market", "spot") - .put("uniques", 0) - .build(), + .put("market", "total_market") + .put("uniques", 0) + .build(), ImmutableMap.builder() - .put("market", "upfront") - .put("uniques", 0) - .build() + .put("market", "upfront") + .put("uniques", 0) + .build() ) ) )