You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/09/02 22:03:27 UTC

[GitHub] [druid] gianm commented on a change in pull request #10340: Fix VARIANCE aggregator comparator

gianm commented on a change in pull request #10340:
URL: https://github.com/apache/druid/pull/10340#discussion_r482515733



##########
File path: extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactory.java
##########
@@ -239,7 +240,9 @@ public Comparator getComparator()
   @Override
   public Object finalizeComputation(@Nullable Object object)
   {
-    return object == null ? null : ((VarianceAggregatorCollector) object).getVariance(isVariancePop);
+    return object == null || ((VarianceAggregatorCollector) object).count == 0
+           ? null

Review comment:
       Hmm, I wonder if this should be `NullHandling.defaultDoubleValue()`.
   
   Will this just happen if nothing gets read?

##########
File path: extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorCollector.java
##########
@@ -60,11 +60,11 @@ public static VarianceAggregatorCollector from(ByteBuffer buffer)
   }
 
   public static final Comparator<VarianceAggregatorCollector> COMPARATOR = (o1, o2) -> {
-    int compare = Longs.compare(o1.count, o2.count);
+    int compare = Doubles.compare(o1.nvariance, o2.nvariance);

Review comment:
       Will this sort the same way as `getVariance(isVariancePop)` in `finalizeComputation`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org