|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.esper.eql.expression.ExprNode
net.esper.eql.expression.ExprAggregateNode
public abstract class ExprAggregateNode
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 AggregationMethod
that reflects
each group's (there may be group-by critera) current aggregation state.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.esper.eql.expression.ExprNode |
---|
ExprNode.MappedPropertyParseResult |
Field Summary | |
---|---|
protected boolean |
isDistinct
Indicator for whether the aggregation is distinct - i.e. |
Constructor Summary | |
---|---|
protected |
ExprAggregateNode(boolean distinct)
Ctor. |
Method Summary | |
---|---|
boolean |
equalsNode(ExprNode node)
Return true if a expression node semantically equals the current node, or false if not. |
protected abstract boolean |
equalsNodeAggregate(ExprAggregateNode node)
Return true if a expression aggregate node semantically equals the current node, or false if not. |
Object |
evaluate(EventBean[] events,
boolean isNewData)
Evaluate event tuple and return result. |
static void |
getAggregatesBottomUp(ExprNode topNode,
List<ExprAggregateNode> aggregateNodes)
Populates into the supplied list all aggregation functions within this expression, if any. |
protected abstract String |
getAggregationFunctionName()
Returns the aggregation function name for representation in a generate expression string. |
AggregationMethod |
getPrototypeAggregator()
Returns the aggregation state prototype for use in grouping aggregation states per group-by keys. |
Class |
getType()
Returns the type that the node's evaluate method returns an instance of. |
boolean |
isConstantResult()
Returns true if the expression node's evaluation value doesn't depend on any events data, as must be determined at validation time, which is bottom-up and therefore reliably allows each node to determine constant value. |
boolean |
isDistinct()
Returns true if the aggregation node is only aggregatig distinct values, or false if aggregating all values. |
void |
setAggregationResultFuture(AggregationResultFuture aggregationResultFuture,
int column)
Assigns to the node the future which can be queried for the current aggregation state at evaluation time. |
String |
toExpressionString()
Renders the aggregation function expression. |
void |
validate(StreamTypeService streamTypeService,
MethodResolutionService methodResolutionService,
ViewResourceDelegate viewResourceDelegate)
Validate node. |
protected abstract AggregationMethod |
validateAggregationChild(StreamTypeService streamTypeService,
MethodResolutionService methodResolutionService)
Gives the aggregation node a chance to validate the sub-expression types. |
protected Class |
validateSingleNumericChild(StreamTypeService streamTypeService)
For use by implementing classes, validates the aggregation node expecting a single numeric-type child node. |
Methods inherited from class net.esper.eql.expression.ExprNode |
---|
accept, addChildNode, deepEquals, dumpDebug, getChildNodes, getValidatedSubtree, parseMappedProperty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean isDistinct
Constructor Detail |
---|
protected ExprAggregateNode(boolean distinct)
distinct
- - sets the flag indicatating whether only unique values should be aggregatedMethod Detail |
---|
protected abstract String getAggregationFunctionName()
protected abstract boolean equalsNodeAggregate(ExprAggregateNode node)
For use by the equalsNode implementation which compares the distinct flag.
node
- to compare to
protected abstract AggregationMethod validateAggregationChild(StreamTypeService streamTypeService, MethodResolutionService methodResolutionService) throws ExprValidationException
streamTypeService
- is the types per streammethodResolutionService
- used for resolving method and function names
ExprValidationException
- when expression validation failedpublic boolean isConstantResult()
ExprNode
isConstantResult
in class ExprNode
public void validate(StreamTypeService streamTypeService, MethodResolutionService methodResolutionService, ViewResourceDelegate viewResourceDelegate) throws ExprValidationException
ExprValidator
streamTypeService
- serves stream event type infomethodResolutionService
- - for resolving class names in library method invocationsviewResourceDelegate
- - delegates for view resources to expression nodes
ExprValidationException
- thrown when validation failedpublic Class getType() throws ExprValidationException
ExprValidator
ExprValidationException
- thrown when validation failedpublic AggregationMethod getPrototypeAggregator()
public void setAggregationResultFuture(AggregationResultFuture aggregationResultFuture, int column)
aggregationResultFuture
- - future containing statecolumn
- - column to hand to future for easy accesspublic final Object evaluate(EventBean[] events, boolean isNewData)
ExprEvaluator
events
- - event tupleisNewData
- - indicates whether we are dealing with new data (istream) or old data (rstream)
public static void getAggregatesBottomUp(ExprNode topNode, List<ExprAggregateNode> aggregateNodes)
Populates by going bottom-up such that nested aggregates appear first.
I.e. sum(volume * sum(price)) would put first A then B into the list with A=sum(price) and B=sum(volume * A)
topNode
- is the expression node to deep inspectaggregateNodes
- is a list of node to populate intopublic boolean isDistinct()
public final boolean equalsNode(ExprNode node)
ExprNode
Concrete implementations should compare the type and any additional information that impact the evaluation of a node.
equalsNode
in class ExprNode
node
- to compare to
protected final Class validateSingleNumericChild(StreamTypeService streamTypeService) throws ExprValidationException
streamTypeService
- - types represented in streams
ExprValidationException
- if the validation failedpublic final String toExpressionString()
toExpressionString
in class ExprNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |