Default implementation for getDouble(). (#4595)

* Default implementation for getDouble().

* use getFloat for default implementation.

* addressed comment.

* new line.
This commit is contained in:
Akash Dwivedi 2017-07-25 17:06:27 -07:00 committed by Parag Jain
parent d4ef0f6d94
commit c372d2ecc1
2 changed files with 18 additions and 2 deletions

View File

@ -41,7 +41,16 @@ public interface Aggregator extends Closeable
Object get(); Object get();
float getFloat(); float getFloat();
long getLong(); 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 @Override
void close(); void close();

View File

@ -123,11 +123,18 @@ public interface BufferAggregator extends HotLoopCallee
* have an {@link AggregatorFactory#getTypeName()} of "double". * have an {@link AggregatorFactory#getTypeName()} of "double".
* If unimplemented, throwing an {@link UnsupportedOperationException} is common and recommended. * 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 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 * @param position offset within the byte buffer at which the aggregate value is stored
* @return the double representation of the aggregate * @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 * Release any resources used by the aggregator