Skip to content

Commit

Permalink
Default implementation for getDouble(). (apache#4595)
Browse files Browse the repository at this point in the history
* Default implementation for getDouble().

* use getFloat for default implementation.

* addressed comment.

* new line.
  • Loading branch information
akashdw authored and pjain1 committed Jul 26, 2017
1 parent d4ef0f6 commit c372d2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c372d2e

Please sign in to comment.