Class ExprAggregateNodeBase
java.lang.Object
com.espertech.esper.common.internal.epl.expression.core.ExprNodeBase
com.espertech.esper.common.internal.epl.expression.agg.base.ExprAggregateNodeBase
- All Implemented Interfaces:
ExprAggregateNode
,ExprEvaluator
,ExprForge
,ExprForgeInstrumentable
,ExprNode
,ExprNodeRenderable
,ExprValidator
- Direct Known Subclasses:
ExprAggMultiFunctionCountMinSketchNode
,ExprAggMultiFunctionLinearAccessNode
,ExprAggMultiFunctionSortedMinMaxByNode
,ExprAvedevNode
,ExprAvgNode
,ExprCountEverNode
,ExprCountNode
,ExprFirstLastEverNode
,ExprLeavingAggNode
,ExprMedianNode
,ExprMinMaxAggrNode
,ExprNthAggNode
,ExprPlugInAggNode
,ExprPlugInMultiFunctionAggNode
,ExprRateAggNode
,ExprStddevNode
,ExprSumNode
public abstract class ExprAggregateNodeBase
extends ExprNodeBase
implements ExprEvaluator, ExprAggregateNode, ExprForgeInstrumentable
Base expression node that represents an aggregation function such as 'sum' or 'count'.
In terms of validation each concrete aggregation node must implement it's own validation.
In terms of evaluation this base class will ask the assigned AggregationResultFuture
for the current state,
using a column number assigned to the node.
Concrete subclasses must supply an aggregation state prototype node that reflects each group's (there may be group-by critera) current aggregation state.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CodegenFieldName
protected int
protected boolean
Indicator for whether the aggregation is distinct - i.e.protected ExprAggregateLocalGroupByDesc
protected ExprNode
protected ExprNode[]
Fields inherited from interface com.espertech.esper.common.internal.epl.expression.core.ExprEvaluator
EPTYPE, EPTYPEARRAY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
equalsNode
(ExprNode node, boolean ignoreStreamPrefix) Return true if a expression node semantically equals the current node, or false if not.protected abstract boolean
Return true if a expression aggregate node semantically equals the current node, or false if not.final Object
evaluate
(EventBean[] events, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) Evaluate event tuple and return result.evaluateCodegen
(EPTypeClass requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) evaluateCodegenUninstrumented
(EPTypeClass requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) getAggFuture
(CodegenClassScope codegenClassScope) abstract String
Returns the aggregation function name for representation in a generate expression string.int
Returns the aggregation state factory for use in grouping aggregation states per group-by keys.getForge()
ExprNode[]
Returns precedence.boolean
boolean
Returns true if the aggregation node is only aggregatig distinct values, or false if aggregating all values.protected boolean
protected abstract boolean
protected ExprValidationException
makeExceptionExpectedParamNum
(int lower, int upper) void
setColumn
(int column) void
toPrecedenceFreeEPL
(StringWriter writer, ExprNodeRenderableFlags flags) validate
(ExprValidationContext validationContext) protected abstract AggregationForgeFactory
validateAggregationChild
(ExprValidationContext validationContext) Gives the aggregation node a chance to validate the sub-expression types.void
validateFilter
(ExprNode filterEvaluator) protected final EPTypeClass
validateNumericChildAllowFilter
(boolean hasFilter) void
validatePositionals
(ExprValidationContext validationContext) Methods inherited from class com.espertech.esper.common.internal.epl.expression.core.ExprNodeBase
accept, accept, acceptChildnodes, addChildNode, addChildNodes, addChildNodeToFront, checkValidated, checkValidatedException, getChildNodes, replaceUnlistedChildNode, setChildNode, setChildNodes, toEPL
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.espertech.esper.common.internal.epl.expression.core.ExprNode
accept, accept, acceptChildnodes, addChildNode, addChildNodes, getChildNodes, replaceUnlistedChildNode, setChildNode, setChildNodes
Methods inherited from interface com.espertech.esper.common.internal.epl.expression.core.ExprNodeRenderable
toEPL
-
Field Details
-
column
protected int column -
optionalAggregateLocalGroupByDesc
-
optionalFilter
-
positionalParams
-
aggregationResultFutureMemberName
-
isDistinct
protected boolean isDistinctIndicator for whether the aggregation is distinct - i.e. only unique values are considered.
-
-
Constructor Details
-
ExprAggregateNodeBase
protected ExprAggregateNodeBase(boolean distinct) Ctor.- Parameters:
distinct
- - sets the flag indicatating whether only unique values should be aggregated
-
-
Method Details
-
getAggregationFunctionName
Returns the aggregation function name for representation in a generate expression string.- Returns:
- aggregation function name
-
isFilterExpressionAsLastParameter
protected abstract boolean isFilterExpressionAsLastParameter() -
equalsNodeAggregateMethodOnly
Return true if a expression aggregate node semantically equals the current node, or false if not.For use by the equalsNode implementation which compares the distinct flag.
- Parameters:
node
- to compare to- Returns:
- true if semantically equal, or false if not equals
-
validateAggregationChild
protected abstract AggregationForgeFactory validateAggregationChild(ExprValidationContext validationContext) throws ExprValidationException Gives the aggregation node a chance to validate the sub-expression types.- Parameters:
validationContext
- validation information- Returns:
- aggregation function factory to use
- Throws:
ExprValidationException
- when expression validation failed
-
getForgeConstantType
- Specified by:
getForgeConstantType
in interfaceExprForge
-
getPositionalParams
- Specified by:
getPositionalParams
in interfaceExprAggregateNode
-
getExprEvaluator
- Specified by:
getExprEvaluator
in interfaceExprForge
-
isConstantResult
public boolean isConstantResult() -
getForgeRenderable
- Specified by:
getForgeRenderable
in interfaceExprForge
-
validate
- Specified by:
validate
in interfaceExprValidator
- Throws:
ExprValidationException
-
validatePositionals
public void validatePositionals(ExprValidationContext validationContext) throws ExprValidationException - Specified by:
validatePositionals
in interfaceExprAggregateNode
- Throws:
ExprValidationException
-
getFactory
Returns the aggregation state factory for use in grouping aggregation states per group-by keys.- Specified by:
getFactory
in interfaceExprAggregateNode
- Returns:
- prototype aggregation state as a factory for aggregation states per group-by key value
-
setColumn
public void setColumn(int column) - Specified by:
setColumn
in interfaceExprAggregateNode
-
evaluate
public final Object evaluate(EventBean[] events, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) Description copied from interface:ExprEvaluator
Evaluate event tuple and return result.- Specified by:
evaluate
in interfaceExprEvaluator
- Parameters:
events
- - event tupleisNewData
- - indicates whether we are dealing with new data (istream) or old data (rstream)exprEvaluatorContext
- context for expression evaluation- Returns:
- evaluation result, a boolean value for OR/AND-type evalution nodes.
-
evaluateCodegenUninstrumented
public CodegenExpression evaluateCodegenUninstrumented(EPTypeClass requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) - Specified by:
evaluateCodegenUninstrumented
in interfaceExprForgeInstrumentable
-
evaluateCodegen
public CodegenExpression evaluateCodegen(EPTypeClass requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) - Specified by:
evaluateCodegen
in interfaceExprForge
-
getEvaluationType
- Specified by:
getEvaluationType
in interfaceExprForge
-
getForge
-
isDistinct
public boolean isDistinct()Returns true if the aggregation node is only aggregatig distinct values, or false if aggregating all values.- Specified by:
isDistinct
in interfaceExprAggregateNode
- Returns:
- true if 'distinct' keyword was given, false if not
-
equalsNode
Description copied from interface:ExprNode
Return true if a expression node semantically equals the current node, or false if not.Concrete implementations should compare the type and any additional information that impact the evaluation of a node.
- Specified by:
equalsNode
in interfaceExprNode
- Parameters:
node
- to compare toignoreStreamPrefix
- when the equals-comparison can ignore prefix of event properties- Returns:
- true if semantically equal, or false if not equals
-
getColumn
public int getColumn()- Specified by:
getColumn
in interfaceExprAggregateNode
-
validateNumericChildAllowFilter
protected final EPTypeClass validateNumericChildAllowFilter(boolean hasFilter) throws ExprValidationException - Throws:
ExprValidationException
-
makeExceptionExpectedParamNum
-
toPrecedenceFreeEPL
- Specified by:
toPrecedenceFreeEPL
in classExprNodeBase
-
getPrecedence
Description copied from interface:ExprNode
Returns precedence.- Specified by:
getPrecedence
in interfaceExprNode
- Returns:
- precedence
-
validateFilter
- Throws:
ExprValidationException
-
getOptionalLocalGroupBy
- Specified by:
getOptionalLocalGroupBy
in interfaceExprAggregateNode
-
getOptionalFilter
- Specified by:
getOptionalFilter
in interfaceExprAggregateNode
-
isExprTextWildcardWhenNoParams
protected boolean isExprTextWildcardWhenNoParams() -
getAggFuture
-