com.espertech.esper.epl.expression.subquery
Class ExprSubselectNode

java.lang.Object
  extended by com.espertech.esper.epl.expression.core.ExprNodeBase
      extended by com.espertech.esper.epl.expression.subquery.ExprSubselectNode
All Implemented Interfaces:
ExprEvaluator, ExprEvaluatorEnumeration, ExprEvaluatorTypableReturn, ExprNode, ExprValidator, MetaDefItem, java.io.Serializable
Direct Known Subclasses:
ExprSubselectAllSomeAnyNode, ExprSubselectExistsNode, ExprSubselectInNode, ExprSubselectRowNode

public abstract class ExprSubselectNode
extends ExprNodeBase
implements ExprEvaluator, ExprEvaluatorEnumeration, ExprEvaluatorTypableReturn

Represents a subselect in an expression tree.

See Also:
Serialized Form

Nested Class Summary
static class ExprSubselectNode.SubqueryAggregationType
           
 
Field Summary
static ExprSubselectNode[] EMPTY_SUBSELECT_ARRAY
           
protected  ExprEvaluator filterExpr
          The validate filter expression.
protected  EventType rawEventType
          The event type generated for wildcard selects.
protected  java.lang.String[] selectAsNames
           
protected  ExprNode[] selectClause
          The validated select clause.
protected  ExprEvaluator[] selectClauseEvaluator
           
protected  java.lang.String statementName
           
protected  AggregationService subselectAggregationService
           
protected  int subselectNumber
           
 
Constructor Summary
ExprSubselectNode(StatementSpecRaw statementSpec)
          Ctor.
 
Method Summary
 boolean equalsNode(ExprNode node)
          Return true if a expression node semantically equals the current node, or false if not.
abstract  java.lang.Object evaluate(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
          Evaluate the lookup expression returning an evaluation result object.
 java.lang.Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
          Evaluate event tuple and return result.
abstract  java.util.Collection<EventBean> evaluateGetCollEvents(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
           
abstract  java.util.Collection evaluateGetCollScalar(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
           
abstract  EventBean evaluateGetEventBean(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
           
 EventBean evaluateGetEventBean(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 java.util.Collection<EventBean> evaluateGetROCollectionEvents(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
           
 java.util.Collection evaluateGetROCollectionScalar(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
           
abstract  java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
           
 java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
abstract  java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream, boolean isNewData, java.util.Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
           
 java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 ExprEvaluator getExprEvaluator()
           
 ExprEvaluator getFilterExpr()
          Returns filter expr or null if none.
 StreamTypeService getFilterSubqueryStreamTypes()
          Return stream types.
 ExprPrecedenceEnum getPrecedence()
          Returns precedence.
 EventType getRawEventType()
          Returns the event type.
 java.util.LinkedHashMap<java.lang.String,java.lang.Object> getRowProperties()
          Return null to indicate no row-type result available, or a map of property names and types to indicate a row-type result is available.
 ExprNode[] getSelectClause()
          Returns the select clause or null if none.
 StatementSpecCompiled getStatementSpecCompiled()
          Returns the compiled statement spec.
 StatementSpecRaw getStatementSpecRaw()
          Returns the uncompiled statement spec.
 AggregationService getSubselectAggregationService()
           
 ExprSubselectNode.SubqueryAggregationType getSubselectAggregationType()
           
 int getSubselectNumber()
           
abstract  boolean isAllowMultiColumnSelect()
           
 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 isFilterStreamSubselect()
           
 java.lang.Boolean isMultirow()
          Return true for multi-row return, return false for return of single row only
 void setFilterExpr(ExprEvaluator filterExpr)
          Sets the validated filter expression, or null if there is none.
 void setFilterStreamSubselect(boolean filterStreamSubselect)
           
 void setFilterSubqueryStreamTypes(StreamTypeService filterSubqueryStreamTypes)
          Set stream types.
 void setRawEventType(EventType rawEventType)
          Sets the event type generated for wildcard selects.
 void setSelectAsNames(java.lang.String[] selectAsNames)
          Supplies the name of the select expression as-tag
 void setSelectClause(ExprNode[] selectClause)
          Sets the validate select clause
 void setStatementSpecCompiled(StatementSpecCompiled statementSpecCompiled, int subselectNumber)
          Supplies a compiled statement spec.
 void setStrategy(ExprSubselectStrategy strategy)
          Sets the strategy for boiling down the table of lookup events into a subset against which to run the filter.
 void setSubselectAggregationService(AggregationService subselectAggregationService)
           
 void setSubselectAggregationType(ExprSubselectNode.SubqueryAggregationType subselectAggregationType)
           
static ExprSubselectNode[] toArray(java.util.List<ExprSubselectNode> subselectNodes)
           
 void toPrecedenceFreeEPL(java.io.StringWriter writer)
           
abstract  java.util.LinkedHashMap<java.lang.String,java.lang.Object> typableGetRowProperties()
           
 ExprNode validate(ExprValidationContext validationContext)
           
abstract  void validateSubquery(ExprValidationContext validationContext)
           
 
Methods inherited from class com.espertech.esper.epl.expression.core.ExprNodeBase
accept, accept, acceptChildnodes, addChildNode, addChildNodes, addChildNodeToFront, 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.epl.expression.core.ExprEvaluatorEnumeration
getComponentTypeCollection, getEventTypeCollection, getEventTypeSingle
 
Methods inherited from interface com.espertech.esper.epl.expression.core.ExprEvaluator
getType
 

Field Detail

EMPTY_SUBSELECT_ARRAY

public static final ExprSubselectNode[] EMPTY_SUBSELECT_ARRAY

selectClause

protected ExprNode[] selectClause
The validated select clause.


selectClauseEvaluator

protected transient ExprEvaluator[] selectClauseEvaluator

selectAsNames

protected java.lang.String[] selectAsNames

filterExpr

protected transient ExprEvaluator filterExpr
The validate filter expression.


rawEventType

protected transient EventType rawEventType
The event type generated for wildcard selects.


statementName

protected java.lang.String statementName

subselectNumber

protected int subselectNumber

subselectAggregationService

protected transient AggregationService subselectAggregationService
Constructor Detail

ExprSubselectNode

public ExprSubselectNode(StatementSpecRaw statementSpec)
Ctor.

Parameters:
statementSpec - is the lookup statement spec from the parser, unvalidated
Method Detail

evaluate

public abstract java.lang.Object evaluate(EventBean[] eventsPerStream,
                                          boolean isNewData,
                                          java.util.Collection<EventBean> matchingEvents,
                                          ExprEvaluatorContext exprEvaluatorContext)
Evaluate the lookup expression returning an evaluation result object.

Parameters:
eventsPerStream - is the events for each stream in a join
isNewData - is true for new data, or false for old data
matchingEvents - is filtered results from the table of stored lookup events
exprEvaluatorContext - context for expression evalauation
Returns:
evaluation result

evaluateGetCollEvents

public abstract java.util.Collection<EventBean> evaluateGetCollEvents(EventBean[] eventsPerStream,
                                                                      boolean isNewData,
                                                                      java.util.Collection<EventBean> matchingEvents,
                                                                      ExprEvaluatorContext exprEvaluatorContext)

evaluateGetCollScalar

public abstract java.util.Collection evaluateGetCollScalar(EventBean[] eventsPerStream,
                                                           boolean isNewData,
                                                           java.util.Collection<EventBean> matchingEvents,
                                                           ExprEvaluatorContext exprEvaluatorContext)

evaluateGetEventBean

public abstract EventBean evaluateGetEventBean(EventBean[] eventsPerStream,
                                               boolean isNewData,
                                               java.util.Collection<EventBean> matchingEvents,
                                               ExprEvaluatorContext exprEvaluatorContext)

isAllowMultiColumnSelect

public abstract boolean isAllowMultiColumnSelect()

validateSubquery

public abstract void validateSubquery(ExprValidationContext validationContext)
                               throws ExprValidationException
Throws:
ExprValidationException

typableGetRowProperties

public abstract java.util.LinkedHashMap<java.lang.String,java.lang.Object> typableGetRowProperties()
                                                                                            throws ExprValidationException
Throws:
ExprValidationException

evaluateTypableSingle

public abstract java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream,
                                                         boolean isNewData,
                                                         java.util.Collection<EventBean> matchingEvents,
                                                         ExprEvaluatorContext exprEvaluatorContext)

evaluateTypableMulti

public abstract java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream,
                                                          boolean isNewData,
                                                          java.util.Collection<EventBean> matchingEvents,
                                                          ExprEvaluatorContext exprEvaluatorContext)

getExprEvaluator

public ExprEvaluator getExprEvaluator()
Specified by:
getExprEvaluator in interface ExprNode

isConstantResult

public boolean isConstantResult()
Description copied from interface: ExprNode
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.

Specified by:
isConstantResult in interface ExprNode
Returns:
true for constant evaluation value, false for non-constant evaluation value

validate

public ExprNode validate(ExprValidationContext validationContext)
                  throws ExprValidationException
Specified by:
validate in interface ExprValidator
Throws:
ExprValidationException

setStatementSpecCompiled

public void setStatementSpecCompiled(StatementSpecCompiled statementSpecCompiled,
                                     int subselectNumber)
Supplies a compiled statement spec.

Parameters:
statementSpecCompiled - compiled validated filters

getStatementSpecCompiled

public StatementSpecCompiled getStatementSpecCompiled()
Returns the compiled statement spec.

Returns:
compiled statement

setSelectClause

public void setSelectClause(ExprNode[] selectClause)
Sets the validate select clause

Parameters:
selectClause - is the expression representing the select clause

evaluate

public java.lang.Object evaluate(EventBean[] eventsPerStream,
                                 boolean isNewData,
                                 ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: ExprEvaluator
Evaluate event tuple and return result.

Specified by:
evaluate in interface ExprEvaluator
Parameters:
eventsPerStream - - event tuple
isNewData - - 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.

evaluateGetROCollectionEvents

public java.util.Collection<EventBean> evaluateGetROCollectionEvents(EventBean[] eventsPerStream,
                                                                     boolean isNewData,
                                                                     ExprEvaluatorContext exprEvaluatorContext)
Specified by:
evaluateGetROCollectionEvents in interface ExprEvaluatorEnumeration

evaluateGetROCollectionScalar

public java.util.Collection evaluateGetROCollectionScalar(EventBean[] eventsPerStream,
                                                          boolean isNewData,
                                                          ExprEvaluatorContext exprEvaluatorContext)
Specified by:
evaluateGetROCollectionScalar in interface ExprEvaluatorEnumeration

evaluateGetEventBean

public EventBean evaluateGetEventBean(EventBean[] eventsPerStream,
                                      boolean isNewData,
                                      ExprEvaluatorContext context)
Specified by:
evaluateGetEventBean in interface ExprEvaluatorEnumeration

getRowProperties

public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getRowProperties()
                                                                            throws ExprValidationException
Description copied from interface: ExprEvaluatorTypableReturn
Return null to indicate no row-type result available, or a map of property names and types to indicate a row-type result is available.

Specified by:
getRowProperties in interface ExprEvaluatorTypableReturn
Returns:
map of property names and types or null
Throws:
ExprValidationException - if the expression is invalid

isMultirow

public java.lang.Boolean isMultirow()
Description copied from interface: ExprEvaluatorTypableReturn
Return true for multi-row return, return false for return of single row only

Specified by:
isMultirow in interface ExprEvaluatorTypableReturn
Returns:
multi-row flag

evaluateTypableSingle

public java.lang.Object[] evaluateTypableSingle(EventBean[] eventsPerStream,
                                                boolean isNewData,
                                                ExprEvaluatorContext context)
Specified by:
evaluateTypableSingle in interface ExprEvaluatorTypableReturn

evaluateTypableMulti

public java.lang.Object[][] evaluateTypableMulti(EventBean[] eventsPerStream,
                                                 boolean isNewData,
                                                 ExprEvaluatorContext context)
Specified by:
evaluateTypableMulti in interface ExprEvaluatorTypableReturn

getStatementSpecRaw

public StatementSpecRaw getStatementSpecRaw()
Returns the uncompiled statement spec.

Returns:
statement spec uncompiled

setSelectAsNames

public void setSelectAsNames(java.lang.String[] selectAsNames)
Supplies the name of the select expression as-tag

Parameters:
selectAsNames - is the as-name(s)

setFilterExpr

public void setFilterExpr(ExprEvaluator filterExpr)
Sets the validated filter expression, or null if there is none.

Parameters:
filterExpr - is the filter

toPrecedenceFreeEPL

public void toPrecedenceFreeEPL(java.io.StringWriter writer)
Specified by:
toPrecedenceFreeEPL in class ExprNodeBase

getPrecedence

public ExprPrecedenceEnum getPrecedence()
Description copied from interface: ExprNode
Returns precedence.

Specified by:
getPrecedence in interface ExprNode
Returns:
precedence

equalsNode

public boolean equalsNode(ExprNode node)
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 interface ExprNode
Parameters:
node - to compare to
Returns:
true if semantically equal, or false if not equals

setStrategy

public void setStrategy(ExprSubselectStrategy strategy)
Sets the strategy for boiling down the table of lookup events into a subset against which to run the filter.

Parameters:
strategy - is the looking strategy (full table scan or indexed)

setRawEventType

public void setRawEventType(EventType rawEventType)
Sets the event type generated for wildcard selects.

Parameters:
rawEventType - is the wildcard type (parent view)

getSelectClause

public ExprNode[] getSelectClause()
Returns the select clause or null if none.

Returns:
clause

getFilterExpr

public ExprEvaluator getFilterExpr()
Returns filter expr or null if none.

Returns:
filter

getRawEventType

public EventType getRawEventType()
Returns the event type.

Returns:
type

getFilterSubqueryStreamTypes

public StreamTypeService getFilterSubqueryStreamTypes()
Return stream types.

Returns:
types

setFilterSubqueryStreamTypes

public void setFilterSubqueryStreamTypes(StreamTypeService filterSubqueryStreamTypes)
Set stream types.

Parameters:
filterSubqueryStreamTypes - types

getSubselectAggregationType

public ExprSubselectNode.SubqueryAggregationType getSubselectAggregationType()

setSubselectAggregationType

public void setSubselectAggregationType(ExprSubselectNode.SubqueryAggregationType subselectAggregationType)

getSubselectNumber

public int getSubselectNumber()

setFilterStreamSubselect

public void setFilterStreamSubselect(boolean filterStreamSubselect)

isFilterStreamSubselect

public boolean isFilterStreamSubselect()

toArray

public static ExprSubselectNode[] toArray(java.util.List<ExprSubselectNode> subselectNodes)

setSubselectAggregationService

public void setSubselectAggregationService(AggregationService subselectAggregationService)

getSubselectAggregationService

public AggregationService getSubselectAggregationService()

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com