|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mckoi.database.AbstractFunction
com.mckoi.database.AbstractAggregateFunction
public abstract class AbstractAggregateFunction
Provides convenience methods for handling aggregate functions (functions that are evaluated over a grouping set). Note that this class handles the most common form of aggregate functions. These are aggregates with no more or no less than one parameter, and that return NULL if the group set has a length of 0. If an aggregate function doesn't fit this design, then the developer must roll their own AbstractFunction to handle it.
This object handles full expressions being passed as parameters to the aggregate function. The expression is evaluated for each set in the group. Therefore the aggregate function, avg(length(description)) will find the average length of the description column. sum(price * quantity) will find the sum of the price * quantity of each set in the group.
Constructor Summary | |
---|---|
AbstractAggregateFunction(java.lang.String name,
Expression[] params)
Constructs an aggregate function. |
Method Summary | |
---|---|
abstract TObject |
evalAggregate(GroupResolver group,
QueryContext context,
TObject val1,
TObject val2)
Evaluates the aggregate function for the given values and returns the result. |
TObject |
evaluate(GroupResolver group,
VariableResolver resolver,
QueryContext context)
Evaluates the function and returns a TObject that represents the result of the function. |
TObject |
postEvalAggregate(GroupResolver group,
QueryContext context,
TObject result)
Called just before the value is returned to the parent. |
Methods inherited from class com.mckoi.database.AbstractFunction |
---|
allElements, allVariables, getName, getParameter, init, isAggregate, isGlob, parameterCount, prepareParameters, returnTType, returnTType, setAggregate, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractAggregateFunction(java.lang.String name, Expression[] params)
Method Detail |
---|
public abstract TObject evalAggregate(GroupResolver group, QueryContext context, TObject val1, TObject val2)
NOTE: This first time this method is called on a set, 'val1' is 'null' and 'val2' contains the first value in the set.
public TObject postEvalAggregate(GroupResolver group, QueryContext context, TObject result)
public final TObject evaluate(GroupResolver group, VariableResolver resolver, QueryContext context)
Function
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |