com.espertech.esper.epl.agg.service
Class AggSvcGroupByWTableBase

java.lang.Object
  extended by com.espertech.esper.epl.agg.service.AggSvcGroupByWTableBase
All Implemented Interfaces:
AggregationResultFuture, AggregationService
Direct Known Subclasses:
AggSvcGroupByWTableImpl, AggSvcGroupByWTableRollupMultiKeyImpl, AggSvcGroupByWTableRollupSingleKeyImpl

public abstract class AggSvcGroupByWTableBase
extends java.lang.Object
implements AggregationService

Implementation for handling aggregation with grouping by group-keys.


Field Summary
protected  AggregationAccessorSlotPair[] accessors
           
protected  ExprNode[] accessStateExpr
           
protected  AggregationMethod[] currentAggregatorMethods
           
protected  AggregationState[] currentAggregatorStates
           
protected  java.lang.Object currentGroupKey
           
protected  boolean isJoin
           
protected  TableColumnMethodPair[] methodPairs
           
protected  TableMetadata tableMetadata
           
protected  TableStateInstanceGroupBy tableStateInstance
           
protected  int[] targetStates
           
 
Constructor Summary
AggSvcGroupByWTableBase(TableMetadata tableMetadata, TableColumnMethodPair[] methodPairs, AggregationAccessorSlotPair[] accessors, boolean join, TableStateInstanceGroupBy tableStateInstance, int[] targetStates, ExprNode[] accessStateExpr, AggregationAgent[] agents)
           
 
Method Summary
 void accept(AggregationServiceVisitor visitor)
           
 void acceptGroupDetail(AggregationServiceVisitorWGroupDetail visitor)
           
 void applyEnter(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
          Apply events as entering a window (new events).
protected  void applyEnterGroupKey(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
           
abstract  void applyEnterInternal(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
           
 void applyLeave(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
          Apply events as leaving a window (old events).
protected  void applyLeaveGroupKey(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
           
abstract  void applyLeaveInternal(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
           
 void clearResults(ExprEvaluatorContext exprEvaluatorContext)
          Clear current aggregation state.
 java.util.Collection<EventBean> getCollectionOfEvents(int column, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 java.util.Collection<java.lang.Object> getCollectionScalar(int column, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 EventBean getEventBean(int column, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context)
           
 java.lang.Object getGroupKey(int agentInstanceId)
           
 java.util.Collection<java.lang.Object> getGroupKeys(ExprEvaluatorContext exprEvaluatorContext)
           
 java.lang.Object getValue(int column, int agentInstanceId, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
          Returns current aggregation state, for use by expression node representing an aggregation function.
 boolean isGrouped()
           
 void setCurrentAccess(java.lang.Object groupByKey, int agentInstanceId, AggregationGroupByRollupLevel rollupLevel)
          Set the current aggregation state row - for use when evaluation nodes are asked to evaluate.
 void setRemovedCallback(AggregationRowRemovedCallback callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableMetadata

protected final TableMetadata tableMetadata

methodPairs

protected final TableColumnMethodPair[] methodPairs

accessors

protected final AggregationAccessorSlotPair[] accessors

isJoin

protected final boolean isJoin

tableStateInstance

protected final TableStateInstanceGroupBy tableStateInstance

targetStates

protected final int[] targetStates

accessStateExpr

protected final ExprNode[] accessStateExpr

currentAggregatorMethods

protected AggregationMethod[] currentAggregatorMethods

currentAggregatorStates

protected AggregationState[] currentAggregatorStates

currentGroupKey

protected java.lang.Object currentGroupKey
Constructor Detail

AggSvcGroupByWTableBase

public AggSvcGroupByWTableBase(TableMetadata tableMetadata,
                               TableColumnMethodPair[] methodPairs,
                               AggregationAccessorSlotPair[] accessors,
                               boolean join,
                               TableStateInstanceGroupBy tableStateInstance,
                               int[] targetStates,
                               ExprNode[] accessStateExpr,
                               AggregationAgent[] agents)
Method Detail

applyEnterInternal

public abstract void applyEnterInternal(EventBean[] eventsPerStream,
                                        java.lang.Object groupByKey,
                                        ExprEvaluatorContext exprEvaluatorContext)

applyLeaveInternal

public abstract void applyLeaveInternal(EventBean[] eventsPerStream,
                                        java.lang.Object groupByKey,
                                        ExprEvaluatorContext exprEvaluatorContext)

applyEnter

public void applyEnter(EventBean[] eventsPerStream,
                       java.lang.Object groupByKey,
                       ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: AggregationService
Apply events as entering a window (new events).

Specified by:
applyEnter in interface AggregationService
Parameters:
eventsPerStream - - events for each stream entering window
groupByKey - - can be null if grouping without keys is desired, else the keys or array of keys to use for grouping, each distinct key value results in a new row of aggregation state.
exprEvaluatorContext - context for expression evaluatiom

applyLeave

public void applyLeave(EventBean[] eventsPerStream,
                       java.lang.Object groupByKey,
                       ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: AggregationService
Apply events as leaving a window (old events).

Specified by:
applyLeave in interface AggregationService
Parameters:
eventsPerStream - - events for each stream entering window
groupByKey - - can be null if grouping without keys is desired, else the keys or array of keys to use for grouping, each distinct key value results in a new row of aggregation state.
exprEvaluatorContext - context for expression evaluatiom

applyEnterGroupKey

protected void applyEnterGroupKey(EventBean[] eventsPerStream,
                                  java.lang.Object groupByKey,
                                  ExprEvaluatorContext exprEvaluatorContext)

applyLeaveGroupKey

protected void applyLeaveGroupKey(EventBean[] eventsPerStream,
                                  java.lang.Object groupByKey,
                                  ExprEvaluatorContext exprEvaluatorContext)

setCurrentAccess

public void setCurrentAccess(java.lang.Object groupByKey,
                             int agentInstanceId,
                             AggregationGroupByRollupLevel rollupLevel)
Description copied from interface: AggregationService
Set the current aggregation state row - for use when evaluation nodes are asked to evaluate.

Specified by:
setCurrentAccess in interface AggregationService
Parameters:
groupByKey - - single key identifying the row of aggregation states
agentInstanceId - context partition id

getValue

public java.lang.Object getValue(int column,
                                 int agentInstanceId,
                                 EventBean[] eventsPerStream,
                                 boolean isNewData,
                                 ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: AggregationResultFuture
Returns current aggregation state, for use by expression node representing an aggregation function.

Specified by:
getValue in interface AggregationResultFuture
Parameters:
column - is assigned to the aggregation expression node and passed as an column (index) into a row
agentInstanceId - the context partition id
Returns:
current aggragation state

getCollectionOfEvents

public java.util.Collection<EventBean> getCollectionOfEvents(int column,
                                                             EventBean[] eventsPerStream,
                                                             boolean isNewData,
                                                             ExprEvaluatorContext context)
Specified by:
getCollectionOfEvents in interface AggregationResultFuture

getCollectionScalar

public java.util.Collection<java.lang.Object> getCollectionScalar(int column,
                                                                  EventBean[] eventsPerStream,
                                                                  boolean isNewData,
                                                                  ExprEvaluatorContext context)
Specified by:
getCollectionScalar in interface AggregationResultFuture

getEventBean

public EventBean getEventBean(int column,
                              EventBean[] eventsPerStream,
                              boolean isNewData,
                              ExprEvaluatorContext context)
Specified by:
getEventBean in interface AggregationResultFuture

setRemovedCallback

public void setRemovedCallback(AggregationRowRemovedCallback callback)
Specified by:
setRemovedCallback in interface AggregationService

accept

public void accept(AggregationServiceVisitor visitor)
Specified by:
accept in interface AggregationService

acceptGroupDetail

public void acceptGroupDetail(AggregationServiceVisitorWGroupDetail visitor)
Specified by:
acceptGroupDetail in interface AggregationService

isGrouped

public boolean isGrouped()
Specified by:
isGrouped in interface AggregationService

getGroupKey

public java.lang.Object getGroupKey(int agentInstanceId)
Specified by:
getGroupKey in interface AggregationResultFuture

getGroupKeys

public java.util.Collection<java.lang.Object> getGroupKeys(ExprEvaluatorContext exprEvaluatorContext)
Specified by:
getGroupKeys in interface AggregationResultFuture

clearResults

public void clearResults(ExprEvaluatorContext exprEvaluatorContext)
Description copied from interface: AggregationService
Clear current aggregation state.

Specified by:
clearResults in interface AggregationService

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