[
https://issues.apache.org/jira/browse/PHOENIX-458?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gabriel Reid resolved PHOENIX-458.
----------------------------------
Resolution: Fixed
Bulk resolve of closed issues imported from GitHub. This status was reached by
first re-opening all closed imported issues and then resolving them in bulk.
> Support FLOAT/DOUBLE SUM aggregation
> ------------------------------------
>
> Key: PHOENIX-458
> URL: https://issues.apache.org/jira/browse/PHOENIX-458
> Project: Phoenix
> Issue Type: Task
> Reporter: James Taylor
> Assignee: JingchengDu
> Labels: bug
>
> A few changes are necessary to support summing over FLOAT/DOUBLE:
> 1. Implement an abstract class called DoubleSumAggregator that'll be just
> like NumberSumAggregator, but the member variable will be a double instead of
> a long and we'll use decode/encodeDouble.
> 2. In SumAggregateFunction.java, modify the factory methods to create the
> correct Aggregator class for FLOAT/DOUBLE:
> <pre><code>
> @Override
> public Aggregator newServerAggregator() {
> final PDataType type = getAggregatorExpression().getDataType();
> ColumnModifier columnModifier =
> getAggregatorExpression().getColumnModifier();
> switch( type ) {
> case DECIMAL:
> return new DecimalSumAggregator(columnModifier);
> case DOUBLE:
> case FLOAT:
> return new DoubleSumAggregator(columnModifier) {
> @Override
> protected PDataType getInputDataType() {
> return type;
> }
> };
> default:
> return new NumberSumAggregator(columnModifier) {
> @Override
> protected PDataType getInputDataType() {
> return type;
> }
> };
> }
> }
>
> @Override
> public Aggregator newClientAggregator() {
> switch( getDataType() ) {
> case DECIMAL:
> // On the client, we'll always aggregate over non modified
> column values,
> // because we always get them back from the server in their
> non modified
> // form.
> return new DecimalSumAggregator(null);
> case LONG:
> return new LongSumAggregator(null);
> case DOUBLE:
> return new DoubleSumAggregator(null);
> default:
> throw new IllegalStateException("Unexpected SUM type: " +
> getDataType());
> }
> }
> </code></pre>
--
This message was sent by Atlassian JIRA
(v6.2#6252)