Package edu.caltech.nanodb.functions
Class AggregateFunction
- java.lang.Object
-
- edu.caltech.nanodb.functions.Function
-
- edu.caltech.nanodb.functions.ScalarFunction
-
- edu.caltech.nanodb.functions.AggregateFunction
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
CountAggregate
,CountStar
,MinMaxAggregate
,StdDevVarAggregate
,SumAvgAggregate
public abstract class AggregateFunction extends ScalarFunction
This class provides the general abstraction for aggregate functions.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
supportsDistinct
If this flag is true, the aggregate function supports the DISTINCT keyword before its first argument.
-
Constructor Summary
Constructors Constructor Description AggregateFunction(boolean supportsDistinct)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addValue(java.lang.Object value)
Adds a value to the aggregate function so that it can update its internal state.abstract void
clearResult()
Clears the aggregate function's current state so that the object can be reused to compute an aggregate on another set of input values.abstract java.lang.Object
getResult()
Returns the aggregated result computed for this aggregate function.boolean
supportsDistinct()
-
Methods inherited from class edu.caltech.nanodb.functions.ScalarFunction
getReturnType
-
-
-
-
Method Detail
-
supportsDistinct
public boolean supportsDistinct()
-
clearResult
public abstract void clearResult()
Clears the aggregate function's current state so that the object can be reused to compute an aggregate on another set of input values.
-
addValue
public abstract void addValue(java.lang.Object value)
Adds a value to the aggregate function so that it can update its internal state. Generally, aggregate functions ignorenull
inputs (which represent SQL NULL values) when computing their results.- Parameters:
value
- the value to add to the aggregate function
-
getResult
public abstract java.lang.Object getResult()
Returns the aggregated result computed for this aggregate function. Generally, if aggregate functions receive no non-null inputs then they should produce a null result. (COUNT is an exception to this rule, producing 0 in that case.)- Returns:
- the result of the aggregate computation.
-
-