Class AggregateFunction
- java.lang.Object
-
- org.teiid.query.function.aggregate.AggregateFunction
-
- Direct Known Subclasses:
Count
,CountBig
,LeadLagValue
,NthValue
,RankingFunction
,RankingFunctionBig
,SingleArgumentAggregateFunction
,SortingFilter
,StringAgg
,UserDefined
public abstract class AggregateFunction extends Object
This represents the interface for an aggregate function. The basic lifecycle is that the AggregateFunction is initialize()'d with the type of the element being aggregated, then addInput() is called for every row in the group, then getResult() is called to retrieve the result.
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]
argIndexes
-
Constructor Summary
Constructors Constructor Description AggregateFunction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addInput(List<?> tuple, CommandContext commandContext)
abstract void
addInputDirect(List<?> tuple, CommandContext commandContext)
Called for the element value in every row of a group.boolean
filter(List<?> tuple)
int[]
getArgIndexes()
Class<?>
getOutputType(AggregateSymbol function)
abstract Object
getResult(CommandContext commandContext)
Called after all values have been processed to get the result.void
getState(List<Object> state)
List<? extends Class<?>>
getStateTypes()
void
initialize(Class<?> dataType, Class<?>[] inputTypes)
Called to initialize the function.abstract void
reset()
Called to reset the state of the function.boolean
respectsNull()
void
setArgIndexes(int[] argIndexes)
void
setConditionIndex(int conditionIndex)
int
setState(List<?> state, int index)
-
-
-
Method Detail
-
setArgIndexes
public void setArgIndexes(int[] argIndexes)
-
setConditionIndex
public void setConditionIndex(int conditionIndex)
-
initialize
public void initialize(Class<?> dataType, Class<?>[] inputTypes)
Called to initialize the function. In the future this may expand with additional information.- Parameters:
dataType
- Data type of element begin aggregatedinputTypes
-
-
getArgIndexes
public int[] getArgIndexes()
-
reset
public abstract void reset()
Called to reset the state of the function.
-
addInput
public void addInput(List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException
-
filter
public boolean filter(List<?> tuple)
-
respectsNull
public boolean respectsNull()
-
addInputDirect
public abstract void addInputDirect(List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException
Called for the element value in every row of a group.- Parameters:
tuple
-commandContext
-- Throws:
TeiidProcessingException
TeiidComponentException
-
getResult
public abstract Object getResult(CommandContext commandContext) throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException, TeiidProcessingException
Called after all values have been processed to get the result.- Parameters:
commandContext
-- Returns:
- Result value
- Throws:
TeiidProcessingException
FunctionExecutionException
ExpressionEvaluationException
TeiidComponentException
-
setState
public int setState(List<?> state, int index)
-
getOutputType
public Class<?> getOutputType(AggregateSymbol function)
-
-