suneet-s commented on a change in pull request #9161: first/last aggregators
and nulls
URL: https://github.com/apache/druid/pull/9161#discussion_r368720995
##########
File path:
processing/src/main/java/org/apache/druid/query/aggregation/first/DoubleFirstAggregatorFactory.java
##########
@@ -45,10 +46,34 @@
import java.util.Map;
import java.util.Objects;
-public class DoubleFirstAggregatorFactory extends
NullableNumericAggregatorFactory<ColumnValueSelector>
+public class DoubleFirstAggregatorFactory extends AggregatorFactory
{
+ private static final Aggregator NIL_AGGREGATOR = new DoubleFirstAggregator(
+ NilColumnValueSelector.instance(),
+ NilColumnValueSelector.instance()
+ )
+ {
+ @Override
+ public void aggregate()
+ {
+ // no-op
+ }
+ };
+
+ private static final BufferAggregator NIL_BUFFER_AGGREGATOR = new
DoubleFirstBufferAggregator(
+ NilColumnValueSelector.instance(),
+ NilColumnValueSelector.instance()
+ )
+ {
+ @Override
+ public void aggregate(ByteBuffer buf, int position)
+ {
+ // no-op
+ }
+ };
+
public static final Comparator<SerializablePair<Long, Double>>
VALUE_COMPARATOR =
- Comparator.comparingDouble(o -> o.rhs);
+ SerializablePair.createNullHandlingComparator(Double::compare, true);
Review comment:
It took me a long time to try and figure out what the comparator was used
for. I got wrapped up in the fact that the aggregator was meant compare
timestamps, that I didn't realize this was for ordering. I think a javadoc on
#`AggregatorFactory#getComparator` would have cleared up my confusion pretty
quickly
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]