net.esper.eql.core
Class ResultSetProcessorSimple

java.lang.Object
  extended by net.esper.eql.core.ResultSetProcessorSimple
All Implemented Interfaces:
ResultSetProcessor

public class ResultSetProcessorSimple
extends Object
implements ResultSetProcessor

Result set processor for the simplest case: no aggregation functions used in the select clause, and no group-by.

The processor generates one row for each event entering (new event) and one row for each event leaving (old event).


Nested Class Summary
static class ResultSetProcessorSimple.ResultSetSimpleTransform
          Method to transform an event based on the select expression.
 
Constructor Summary
ResultSetProcessorSimple(SelectExprProcessor selectExprProcessor, OrderByProcessor orderByProcessor, ExprNode optionalHavingNode, boolean isOutputLimiting, boolean isOutputLimitLastOnly)
          Ctor.
 
Method Summary
protected static EventBean[] applyOutputLimit(EventBean[] events, boolean isOutputLimitLastOnly)
          Applies the last/all event output limit clause.
protected static Set<MultiKey<EventBean>> applyOutputLimit(Set<MultiKey<EventBean>> eventSet, boolean isOutputLimitLastOnly)
          Applies the last/all event output limit clause.
 Iterator<EventBean> getIterator(Viewable parent)
          Returns the iterator implementing the group-by and aggregation and order-by logic specific to each case of use of these construct.
 EventType getResultEventType()
          Returns the event type of processed results.
protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, EventBean[] events, ExprNode optionalHavingNode, boolean isOutputLimiting, boolean isOutputLimitLastOnly, boolean isNewData)
          Applies the select-clause to the given events returning the selected events.
protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, Set<MultiKey<EventBean>> events, ExprNode optionalHavingNode, boolean isOutputLimiting, boolean isOutputLimitLastOnly, boolean isNewData)
          Applies the select-clause to the given events returning the selected events.
protected static EventBean[] getSelectEventsNoHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, EventBean[] events, boolean isOutputLimiting, boolean isOutputLimitLastOnly, boolean isNewData)
          Applies the select-clause to the given events returning the selected events.
protected static EventBean[] getSelectEventsNoHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, Set<MultiKey<EventBean>> events, boolean isOutputLimiting, boolean isOutputLimitLastOnly, boolean isNewData)
          Applies the select-clause to the given events returning the selected events.
 Pair<EventBean[],EventBean[]> processJoinResult(Set<MultiKey<EventBean>> newEvents, Set<MultiKey<EventBean>> oldEvents)
          For use by joins posting their result, process the event rows that are entered and removed (new and old events).
 Pair<EventBean[],EventBean[]> processViewResult(EventBean[] newData, EventBean[] oldData)
          For use by views posting their result, process the event rows that are entered and removed (new and old events).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetProcessorSimple

public ResultSetProcessorSimple(SelectExprProcessor selectExprProcessor,
                                OrderByProcessor orderByProcessor,
                                ExprNode optionalHavingNode,
                                boolean isOutputLimiting,
                                boolean isOutputLimitLastOnly)
Ctor.

Parameters:
selectExprProcessor - - for processing the select expression and generting the final output rows
orderByProcessor - - for sorting the outgoing events according to the order-by clause
optionalHavingNode - - having clause expression node
isOutputLimiting - - true to indicate we are output limiting and must keep producing a row per group even if groups didn't change
isOutputLimitLastOnly - - true if output limiting and interested in last event only
Method Detail

getResultEventType

public EventType getResultEventType()
Description copied from interface: ResultSetProcessor
Returns the event type of processed results.

Specified by:
getResultEventType in interface ResultSetProcessor
Returns:
event type of the resulting events posted by the processor.

processJoinResult

public Pair<EventBean[],EventBean[]> processJoinResult(Set<MultiKey<EventBean>> newEvents,
                                                       Set<MultiKey<EventBean>> oldEvents)
Description copied from interface: ResultSetProcessor
For use by joins posting their result, process the event rows that are entered and removed (new and old events). Processes according to select-clauses, group-by clauses and having-clauses and returns new events and old events as specified.

Specified by:
processJoinResult in interface ResultSetProcessor
Parameters:
newEvents - - new events posted by join
oldEvents - - old events posted by join
Returns:
pair of new events and old events

processViewResult

public Pair<EventBean[],EventBean[]> processViewResult(EventBean[] newData,
                                                       EventBean[] oldData)
Description copied from interface: ResultSetProcessor
For use by views posting their result, process the event rows that are entered and removed (new and old events). Processes according to select-clauses, group-by clauses and having-clauses and returns new events and old events as specified.

Specified by:
processViewResult in interface ResultSetProcessor
Parameters:
newData - - new events posted by view
oldData - - old events posted by view
Returns:
pair of new events and old events

getSelectEventsNoHaving

protected static EventBean[] getSelectEventsNoHaving(SelectExprProcessor exprProcessor,
                                                     OrderByProcessor orderByProcessor,
                                                     EventBean[] events,
                                                     boolean isOutputLimiting,
                                                     boolean isOutputLimitLastOnly,
                                                     boolean isNewData)
Applies the select-clause to the given events returning the selected events. The number of events stays the same, i.e. this method does not filter it just transforms the result set.

Parameters:
exprProcessor - - processes each input event and returns output event
orderByProcessor - - orders the outgoing events according to the order-by clause
events - - input events
isOutputLimiting - - true to indicate that we limit output
isOutputLimitLastOnly - - true to indicate that we limit output to the last event
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
output events, one for each input event

applyOutputLimit

protected static EventBean[] applyOutputLimit(EventBean[] events,
                                              boolean isOutputLimitLastOnly)
Applies the last/all event output limit clause.

Parameters:
events - to output
isOutputLimitLastOnly - - flag to indicate output all versus output last
Returns:
events to output

applyOutputLimit

protected static Set<MultiKey<EventBean>> applyOutputLimit(Set<MultiKey<EventBean>> eventSet,
                                                           boolean isOutputLimitLastOnly)
Applies the last/all event output limit clause.

Parameters:
eventSet - to output
isOutputLimitLastOnly - - flag to indicate output all versus output last
Returns:
events to output

getSelectEventsNoHaving

protected static EventBean[] getSelectEventsNoHaving(SelectExprProcessor exprProcessor,
                                                     OrderByProcessor orderByProcessor,
                                                     Set<MultiKey<EventBean>> events,
                                                     boolean isOutputLimiting,
                                                     boolean isOutputLimitLastOnly,
                                                     boolean isNewData)
Applies the select-clause to the given events returning the selected events. The number of events stays the same, i.e. this method does not filter it just transforms the result set.

Parameters:
exprProcessor - - processes each input event and returns output event
orderByProcessor - - for sorting output events according to the order-by clause
events - - input events
isOutputLimiting - - true to indicate that we limit output
isOutputLimitLastOnly - - true to indicate that we limit output to the last event
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
output events, one for each input event

getSelectEventsHaving

protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor,
                                                   OrderByProcessor orderByProcessor,
                                                   EventBean[] events,
                                                   ExprNode optionalHavingNode,
                                                   boolean isOutputLimiting,
                                                   boolean isOutputLimitLastOnly,
                                                   boolean isNewData)
Applies the select-clause to the given events returning the selected events. The number of events stays the same, i.e. this method does not filter it just transforms the result set.

Also applies a having clause.

Parameters:
exprProcessor - - processes each input event and returns output event
orderByProcessor - - for sorting output events according to the order-by clause
events - - input events
optionalHavingNode - - supplies the having-clause expression
isOutputLimiting - - true to indicate that we limit output
isOutputLimitLastOnly - - true to indicate that we limit output to the last event
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
output events, one for each input event

getSelectEventsHaving

protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor,
                                                   OrderByProcessor orderByProcessor,
                                                   Set<MultiKey<EventBean>> events,
                                                   ExprNode optionalHavingNode,
                                                   boolean isOutputLimiting,
                                                   boolean isOutputLimitLastOnly,
                                                   boolean isNewData)
Applies the select-clause to the given events returning the selected events. The number of events stays the same, i.e. this method does not filter it just transforms the result set.

Also applies a having clause.

Parameters:
exprProcessor - - processes each input event and returns output event
orderByProcessor - - for sorting output events according to the order-by clause
events - - input events
optionalHavingNode - - supplies the having-clause expression
isOutputLimiting - - true to indicate that we limit output
isOutputLimitLastOnly - - true to indicate that we limit output to the last event
isNewData - - indicates whether we are dealing with new data (istream) or old data (rstream)
Returns:
output events, one for each input event

getIterator

public Iterator<EventBean> getIterator(Viewable parent)
Description copied from interface: ResultSetProcessor
Returns the iterator implementing the group-by and aggregation and order-by logic specific to each case of use of these construct.

Specified by:
getIterator in interface ResultSetProcessor
Parameters:
parent - is the parent view iterator
Returns:
event iterator