mirror of https://github.com/apache/druid.git
Merge pull request #2729 from jon-wei/fix_hyperunique_comparator
Fix HyperUniquesAggregatorFactory comparator
This commit is contained in:
commit
0dae28b6af
|
@ -21,6 +21,7 @@ package io.druid.query.aggregation.hyperloglog;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.google.common.collect.Ordering;
|
||||||
import com.metamx.common.IAE;
|
import com.metamx.common.IAE;
|
||||||
import com.metamx.common.StringUtils;
|
import com.metamx.common.StringUtils;
|
||||||
import io.druid.query.aggregation.Aggregator;
|
import io.druid.query.aggregation.Aggregator;
|
||||||
|
@ -106,20 +107,7 @@ public class HyperUniquesAggregatorFactory extends AggregatorFactory
|
||||||
@Override
|
@Override
|
||||||
public Comparator getComparator()
|
public Comparator getComparator()
|
||||||
{
|
{
|
||||||
return new Comparator<HyperLogLogCollector>()
|
return Ordering.<HyperLogLogCollector>natural().nullsFirst();
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(HyperLogLogCollector lhs, HyperLogLogCollector rhs)
|
|
||||||
{
|
|
||||||
if(lhs == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(rhs == null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return lhs.compareTo(rhs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -377,11 +377,11 @@ public class TopNQueryRunnerTest
|
||||||
new TopNResultValue(
|
new TopNResultValue(
|
||||||
Arrays.<Map<String, Object>>asList(
|
Arrays.<Map<String, Object>>asList(
|
||||||
ImmutableMap.<String, Object>builder()
|
ImmutableMap.<String, Object>builder()
|
||||||
.put("market", "total_market")
|
.put("market", "spot")
|
||||||
.put("uniques", 0)
|
.put("uniques", 0)
|
||||||
.build(),
|
.build(),
|
||||||
ImmutableMap.<String, Object>builder()
|
ImmutableMap.<String, Object>builder()
|
||||||
.put("market", "spot")
|
.put("market", "total_market")
|
||||||
.put("uniques", 0)
|
.put("uniques", 0)
|
||||||
.build(),
|
.build(),
|
||||||
ImmutableMap.<String, Object>builder()
|
ImmutableMap.<String, Object>builder()
|
||||||
|
|
Loading…
Reference in New Issue