Merge branch asf/cassandra-2.2 into cassandra-3.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0e96d3e5 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0e96d3e5 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0e96d3e5 Branch: refs/heads/cassandra-3.0 Commit: 0e96d3e5248750239f9b762b1f9fb2d28d763976 Parents: f85a20f 60997c2 Author: Benjamin Lerer <b.le...@gmail.com> Authored: Tue Apr 19 17:49:13 2016 +0200 Committer: Benjamin Lerer <b.le...@gmail.com> Committed: Tue Apr 19 17:51:41 2016 +0200 ---------------------------------------------------------------------- .../apache/cassandra/cql3/functions/AggregateFcts.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/0e96d3e5/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java index 79a08cd,cca6156..b2cae50 --- a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java +++ b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java @@@ -703,101 -657,25 +703,101 @@@ public abstract class AggregateFct * The SUM function for counter column values. */ public static final AggregateFunction sumFunctionForCounter = - new NativeAggregateFunction("sum", CounterColumnType.instance, CounterColumnType.instance) + new NativeAggregateFunction("sum", CounterColumnType.instance, CounterColumnType.instance) + { + public Aggregate newAggregate() + { + return new LongSumAggregate(); + } + }; + + /** + * AVG function for counter column values. + */ + public static final AggregateFunction avgFunctionForCounter = + new NativeAggregateFunction("avg", CounterColumnType.instance, CounterColumnType.instance) + { + public Aggregate newAggregate() + { + return new LongAvgAggregate(); + } + }; + + /** + * The MIN function for counter column values. + */ + public static final AggregateFunction minFunctionForCounter = + new NativeAggregateFunction("min", CounterColumnType.instance, CounterColumnType.instance) + { + public Aggregate newAggregate() + { + return new Aggregate() { - public Aggregate newAggregate() + private Long min; + + public void reset() { - return new LongSumAggregate(); + min = null; + } + + public ByteBuffer compute(int protocolVersion) + { + return min != null ? LongType.instance.decompose(min) : null; + } + + public void addInput(int protocolVersion, List<ByteBuffer> values) + { + ByteBuffer value = values.get(0); + + if (value == null) + return; + + long lval = LongType.instance.compose(value); + + if (min == null || lval < min) + min = lval; } }; + } + }; /** -- * AVG function for counter column values. ++ * MAX function for counter column values. */ - public static final AggregateFunction avgFunctionForCounter = - new NativeAggregateFunction("avg", CounterColumnType.instance, CounterColumnType.instance) + public static final AggregateFunction maxFunctionForCounter = + new NativeAggregateFunction("max", CounterColumnType.instance, CounterColumnType.instance) + { + public Aggregate newAggregate() + { + return new Aggregate() { - public Aggregate newAggregate() + private Long max; + + public void reset() { - return new LongAvgAggregate(); + max = null; + } + + public ByteBuffer compute(int protocolVersion) + { + return max != null ? LongType.instance.decompose(max) : null; + } + + public void addInput(int protocolVersion, List<ByteBuffer> values) + { + ByteBuffer value = values.get(0); + + if (value == null) + return; + + long lval = LongType.instance.compose(value); + + if (max == null || lval > max) + max = lval; } }; + } + }; /** * Creates a MAX function for the specified type.