com.espertech.esper.epl.core
Class ResultSetProcessorAggregateGrouped

java.lang.Object
  extended by com.espertech.esper.epl.core.ResultSetProcessorAggregateGrouped
All Implemented Interfaces:
ResultSetProcessor

public class ResultSetProcessorAggregateGrouped
extends Object
implements ResultSetProcessor

Result-set processor for the aggregate-grouped case: there is a group-by and one or more non-aggregation event properties in the select clause are not listed in the group by, and there are aggregation functions.

This processor does perform grouping by computing MultiKey group-by keys for each row. The processor generates one row for each event entering (new event) and one row for each event leaving (old event).

Aggregation state is a table of rows held by AggregationService where the row key is the group-by MultiKey.


Constructor Summary
ResultSetProcessorAggregateGrouped(SelectExprProcessor selectExprProcessor, OrderByProcessor orderByProcessor, AggregationService aggregationService, List<ExprNode> groupKeyNodes, ExprNode optionalHavingNode, boolean isSelectRStream)
          Ctor.
 
Method Summary
 void clear()
          Clear out current state.
protected  MultiKeyUntyped generateGroupKey(EventBean[] eventsPerStream, boolean isNewData)
          Generates the group-by key for the row
 Iterator<EventBean> getIterator(Set<MultiKey<EventBean>> joinSet)
          Returns the iterator for iterating over a join-result.
 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.
 ExprNode getOptionalHavingNode()
          Returns the having node.
 EventType getResultEventType()
          Returns the event type of processed results.
 SelectExprProcessor getSelectExprProcessor()
          Returns the select expression processor
 UniformPair<EventBean[]> processJoinResult(Set<MultiKey<EventBean>> newEvents, Set<MultiKey<EventBean>> oldEvents, boolean isSynthesize)
          For use by joins posting their result, process the event rows that are entered and removed (new and old events).
 UniformPair<EventBean[]> processOutputLimitedJoin(List<UniformPair<Set<MultiKey<EventBean>>>> joinEventsSet, boolean generateSynthetic, OutputLimitLimitType outputLimitLimitType)
          Processes batched events in case of output-rate limiting.
 UniformPair<EventBean[]> processOutputLimitedView(List<UniformPair<EventBean[]>> viewEventsList, boolean generateSynthetic, OutputLimitLimitType outputLimitLimitType)
          Processes batched events in case of output-rate limiting.
 UniformPair<EventBean[]> processViewResult(EventBean[] newData, EventBean[] oldData, boolean isSynthesize)
          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

ResultSetProcessorAggregateGrouped

public ResultSetProcessorAggregateGrouped(SelectExprProcessor selectExprProcessor,
                                          OrderByProcessor orderByProcessor,
                                          AggregationService aggregationService,
                                          List<ExprNode> groupKeyNodes,
                                          ExprNode optionalHavingNode,
                                          boolean isSelectRStream)
Ctor.

Parameters:
selectExprProcessor - - for processing the select expression and generting the final output rows
orderByProcessor - - for sorting outgoing events according to the order-by clause
aggregationService - - handles aggregation
groupKeyNodes - - list of group-by expression nodes needed for building the group-by keys
optionalHavingNode - - expression node representing validated HAVING clause, or null if none given. Aggregation functions in the having node must have been pointed to the AggregationService for evaluation.
isSelectRStream - - true if remove stream events should be generated
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 UniformPair<EventBean[]> processJoinResult(Set<MultiKey<EventBean>> newEvents,
                                                  Set<MultiKey<EventBean>> oldEvents,
                                                  boolean isSynthesize)
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
isSynthesize - - set to true to indicate that synthetic events are required for an iterator result set
Returns:
pair of new events and old events

processViewResult

public UniformPair<EventBean[]> processViewResult(EventBean[] newData,
                                                  EventBean[] oldData,
                                                  boolean isSynthesize)
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
isSynthesize - - set to true to indicate that synthetic events are required for an iterator result set
Returns:
pair of new events and old events

generateGroupKey

protected MultiKeyUntyped generateGroupKey(EventBean[] eventsPerStream,
                                           boolean isNewData)
Generates the group-by key for the row

Parameters:
eventsPerStream - is the row of events
isNewData - is true for new data
Returns:
grouping keys

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

getSelectExprProcessor

public SelectExprProcessor getSelectExprProcessor()
Returns the select expression processor

Returns:
select processor.

getOptionalHavingNode

public ExprNode getOptionalHavingNode()
Returns the having node.

Returns:
having expression

getIterator

public Iterator<EventBean> getIterator(Set<MultiKey<EventBean>> joinSet)
Description copied from interface: ResultSetProcessor
Returns the iterator for iterating over a join-result.

Specified by:
getIterator in interface ResultSetProcessor
Parameters:
joinSet - is the join result set
Returns:
iterator over join results

clear

public void clear()
Description copied from interface: ResultSetProcessor
Clear out current state.

Specified by:
clear in interface ResultSetProcessor

processOutputLimitedJoin

public UniformPair<EventBean[]> processOutputLimitedJoin(List<UniformPair<Set<MultiKey<EventBean>>>> joinEventsSet,
                                                         boolean generateSynthetic,
                                                         OutputLimitLimitType outputLimitLimitType)
Description copied from interface: ResultSetProcessor
Processes batched events in case of output-rate limiting.

Specified by:
processOutputLimitedJoin in interface ResultSetProcessor
Parameters:
joinEventsSet - the join results
generateSynthetic - flag to indicate whether synthetic events must be generated
outputLimitLimitType - the type of output rate limiting
Returns:
results for dispatch

processOutputLimitedView

public UniformPair<EventBean[]> processOutputLimitedView(List<UniformPair<EventBean[]>> viewEventsList,
                                                         boolean generateSynthetic,
                                                         OutputLimitLimitType outputLimitLimitType)
Description copied from interface: ResultSetProcessor
Processes batched events in case of output-rate limiting.

Specified by:
processOutputLimitedView in interface ResultSetProcessor
Parameters:
viewEventsList - the view results
generateSynthetic - flag to indicate whether synthetic events must be generated
outputLimitLimitType - the type of output rate limiting
Returns:
results for dispatch

© 2007 EsperTech Inc.
All rights reserved.
Visit us at espertech.com