diff --git a/processing/src/main/java/io/druid/query/aggregation/Aggregator.java b/processing/src/main/java/io/druid/query/aggregation/Aggregator.java index 28421fa67f4..fb4689fe009 100644 --- a/processing/src/main/java/io/druid/query/aggregation/Aggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/Aggregator.java @@ -41,7 +41,16 @@ public interface Aggregator extends Closeable Object get(); float getFloat(); long getLong(); - double getDouble(); + + /** + * The default implementation casts {@link Aggregator#getFloat()} to double. + * This default method is added to enable smooth backward compatibility, please re-implement it if your aggregators + * work with numeric double columns. + */ + default double getDouble() + { + return (double) getFloat(); + } @Override void close(); diff --git a/processing/src/main/java/io/druid/query/aggregation/BufferAggregator.java b/processing/src/main/java/io/druid/query/aggregation/BufferAggregator.java index d67588fbe94..9dc9acb3267 100644 --- a/processing/src/main/java/io/druid/query/aggregation/BufferAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/BufferAggregator.java @@ -123,11 +123,18 @@ public interface BufferAggregator extends HotLoopCallee * have an {@link AggregatorFactory#getTypeName()} of "double". * If unimplemented, throwing an {@link UnsupportedOperationException} is common and recommended. * + * The default implementation casts {@link BufferAggregator#getFloat(ByteBuffer, int)} to double. + * This default method is added to enable smooth backward compatibility, please re-implement it if your aggregators + * work with numeric double columns. + * * @param buf byte buffer storing the byte array representation of the aggregate * @param position offset within the byte buffer at which the aggregate value is stored * @return the double representation of the aggregate */ - double getDouble(ByteBuffer buf, int position); + default double getDouble(ByteBuffer buf, int position) + { + return (double) getFloat(buf, position); + } /** * Release any resources used by the aggregator