com.simba.dsi.ext
Class AbstractAggregationHandler

java.lang.Object
  extended by com.simba.dsi.ext.AbstractAggregationHandler
Direct Known Subclasses:
SimpleAggregationHandler

public abstract class AbstractAggregationHandler
extends java.lang.Object

Defines an abstract class to facilitate the process of passing down of a relational AGGREGATION operation.

The design assumes the following process of passing down an AGGREGATION operation,

  1. Add expressions from the GROUPING_LIST one by one by calling setGroupingExpr(). If one of the expressions is failed to set, the process is aborted. The order of the list is the order they appear in the GROUP BY list.
  2. Set aggregate functions from the AGGREGATE_LIST one by one by calling setAggregateFn(). If one of the aggregate functions is failed to set, the process is aborted.
  3. Create a result set representing the aggregation result by calling createResult(). Assume the aggregation operation has the GROUPING_LIST of (G1, G2, ...) and the AGGREGATION_LIST(A1, A2, ...), then the result set must have the ordered column set (G1, G2, ..., A1, A2, ...).
  4. If there is a filter that operates on the aggregated result, SimbaEngine will attempt to pass down the filter to the returned table. See AbstractBooleanExprHandler and the sub-classes for details on how a filter is passed down.
An implementation wishing to support "complicated" aggregate and grouping expressions such as the followings should extend this class directly. It should provide implementations for the abstract methods only.


Constructor Summary
AbstractAggregationHandler()
           
 
Method Summary
abstract  DSIExtResultSet createResult()
          Creates the result set representing the aggregation result.
abstract  boolean setAggregateFn(AggrFunctionID aggrFnID)
          Sets one aggregation function from the AGGREGATE_LIST that operates on all fields.
abstract  boolean setAggregateFn(AggrFunctionID aggrFnID, AEValueExpr argExpr, boolean withDistinct)
          Sets one aggregation function from the AGGREGATE_LIST that operates the expression.
abstract  boolean setGroupingExpr(AEValueExpr node)
          Sets one expression from the GROUPING_LIST.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAggregationHandler

public AbstractAggregationHandler()
Method Detail

createResult

public abstract DSIExtResultSet createResult()
Creates the result set representing the aggregation result.

Returns:
The result set representing the aggregation result on success, null otherwise.

setAggregateFn

public abstract boolean setAggregateFn(AggrFunctionID aggrFnID)
Sets one aggregation function from the AGGREGATE_LIST that operates on all fields.

Currently, the only supported aggregate function in this form is "count(*)".

The implementation _MUST_ ensure that any previous setAggregateFn() and setGroupingExpr() operations are undone if this method returns false.

Parameters:
aggrFnID - The ID of the aggregate function. Currently, the only supported value is SE_FUNCT_COUNT_STAR.
Returns:
true if the aggregation function is set successfully, false otherwise.

setAggregateFn

public abstract boolean setAggregateFn(AggrFunctionID aggrFnID,
                                       AEValueExpr argExpr,
                                       boolean withDistinct)
Sets one aggregation function from the AGGREGATE_LIST that operates the expression. That is, it is in the form of
 AGGR_FN(expr)
 
The implementation _MUST_ ensure that any previous setAggregateFn() and setGroupingExpr() operations are undone if this method returns false.

Parameters:
aggrFnID - The ID of the aggregate function.
argExpr - The argument for the aggregate function.
withDistinct - Whether to aggregate on distinct values of argExpr.
Returns:
true if the aggregation function is set successfully, false otherwise.

setGroupingExpr

public abstract boolean setGroupingExpr(AEValueExpr node)
Sets one expression from the GROUPING_LIST. The implementation _MUST_ ensure that any previous setAggregateFn() and setGroupingExpr() operations are undone if this method returns false.

Parameters:
node - An expression from the GROUPING_LIST. Cannot be null.
Returns:
true if the grouping expression is set successfully, false otherwise.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.