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

java.lang.Object
  extended by com.espertech.esper.epl.agg.service.AggregationServiceBaseGrouped
      extended by com.espertech.esper.epl.agg.service.AggSvcGroupByRefcountedWAccessImpl
All Implemented Interfaces:
AggregationResultFuture, AggregationService

public class AggSvcGroupByRefcountedWAccessImpl
extends AggregationServiceBaseGrouped

Implementation for handling aggregation with grouping by group-keys.


Field Summary
protected  AggregationStateFactory[] accessAggregations
           
protected  AggregationAccessorSlotPair[] accessors
           
protected  java.util.Map<java.lang.Object,AggregationMethodPairRow> aggregatorsPerGroup
           
protected  boolean isJoin
           
protected  java.util.List<java.lang.Object> removedKeys
           
 
Fields inherited from class com.espertech.esper.epl.agg.service.AggregationServiceBaseGrouped
aggregators, evaluators, groupKeyBinding
 
Constructor Summary
AggSvcGroupByRefcountedWAccessImpl(ExprEvaluator[] evaluators, AggregationMethodFactory[] prototypes, java.lang.Object groupKeyBinding, MethodResolutionService methodResolutionService, AggregationAccessorSlotPair[] accessors, AggregationStateFactory[] accessAggregations, boolean isJoin)
          Ctor.
 
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).
 void applyLeave(EventBean[] eventsPerStream, java.lang.Object groupByKey, ExprEvaluatorContext exprEvaluatorContext)
          Apply events as leaving a window (old events).
 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.
protected  void handleRemovedKeys()
           
 void internalHandleGroupRemove(java.lang.Object groupByKey)
           
 void internalHandleGroupUpdate(java.lang.Object groupByKey, AggregationMethodPairRow row)
           
 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

accessors

protected final AggregationAccessorSlotPair[] accessors

accessAggregations

protected final AggregationStateFactory[] accessAggregations

isJoin

protected final boolean isJoin

aggregatorsPerGroup

protected java.util.Map<java.lang.Object,AggregationMethodPairRow> aggregatorsPerGroup

removedKeys

protected java.util.List<java.lang.Object> removedKeys
Constructor Detail

AggSvcGroupByRefcountedWAccessImpl

public AggSvcGroupByRefcountedWAccessImpl(ExprEvaluator[] evaluators,
                                          AggregationMethodFactory[] prototypes,
                                          java.lang.Object groupKeyBinding,
                                          MethodResolutionService methodResolutionService,
                                          AggregationAccessorSlotPair[] accessors,
                                          AggregationStateFactory[] accessAggregations,
                                          boolean isJoin)
Ctor.

Parameters:
evaluators - - evaluate the sub-expression within the aggregate function (ie. sum(4*myNum))
prototypes - - collect the aggregation state that evaluators evaluate to, act as prototypes for new aggregations aggregation states for each group
methodResolutionService - - factory for creating additional aggregation method instances per group key
accessors - accessor definitions
accessAggregations - access aggs
isJoin - true for join, false for single-stream
Method Detail

clearResults

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


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).

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).

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

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.

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.

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)

getCollectionScalar

public java.util.Collection<java.lang.Object> getCollectionScalar(int column,
                                                                  EventBean[] eventsPerStream,
                                                                  boolean isNewData,
                                                                  ExprEvaluatorContext context)

getEventBean

public EventBean getEventBean(int column,
                              EventBean[] eventsPerStream,
                              boolean isNewData,
                              ExprEvaluatorContext context)

setRemovedCallback

public void setRemovedCallback(AggregationRowRemovedCallback callback)

internalHandleGroupUpdate

public void internalHandleGroupUpdate(java.lang.Object groupByKey,
                                      AggregationMethodPairRow row)

internalHandleGroupRemove

public void internalHandleGroupRemove(java.lang.Object groupByKey)

accept

public void accept(AggregationServiceVisitor visitor)

acceptGroupDetail

public void acceptGroupDetail(AggregationServiceVisitorWGroupDetail visitor)

isGrouped

public boolean isGrouped()

handleRemovedKeys

protected void handleRemovedKeys()

getGroupKey

public java.lang.Object getGroupKey(int agentInstanceId)

getGroupKeys

public java.util.Collection<java.lang.Object> getGroupKeys(ExprEvaluatorContext exprEvaluatorContext)

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