com.simba.dsi.ext
Class SimpleAggregationHandler

java.lang.Object
  extended by com.simba.dsi.ext.AbstractAggregationHandler
      extended by com.simba.dsi.ext.SimpleAggregationHandler

public abstract class SimpleAggregationHandler
extends AbstractAggregationHandler

Defines an abstract class to further simplify the process of passing down an AGGREGATION operation.

It does that by making the following "simplified" assumptions,

For example, the following queries are supported, The following queries are not supported, An implementation wishing to support grouping by column only and aggregating on either columns or literals as stated above should extends this class directly. It should only need to provide implementations for the abstract methods. If more complicated grouping and/or aggregating expressions need to be supported, it should extends from AbstractAggregationHandler directly.


Constructor Summary
SimpleAggregationHandler()
           
 
Method Summary
abstract  boolean setAggregateColumn(AggrFunctionID aggrFnID, int colIndex, boolean withDistinct)
          Sets an aggregation function from the AGGREGATE_LIST.
 boolean setAggregateFn(AggrFunctionID aggrFnID, AEValueExpr argExpr, boolean withDistinct)
          Implements support for the following forms of aggregation function.
abstract  boolean setAggregateLiteral(AggrFunctionID aggrFnID, AELiteral argExpr, boolean withDistinct)
          Set an aggregation function from the AGGREGATE_LIST.
abstract  boolean setGroupingColumn(int colIndex)
          Set the column reference from the GROUPING_LIST.
 boolean setGroupingExpr(AEValueExpr node)
          Implements the support for grouping on a single column.
 
Methods inherited from class com.simba.dsi.ext.AbstractAggregationHandler
createResult, setAggregateFn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleAggregationHandler

public SimpleAggregationHandler()
Method Detail

setAggregateColumn

public abstract boolean setAggregateColumn(AggrFunctionID aggrFnID,
                                           int colIndex,
                                           boolean withDistinct)
Sets an aggregation function from the AGGREGATE_LIST.

The aggregation function is in the form of,

 AGGREGATE_FN(column_reference)
 
This method is called by SetAggregateFn(SEAggrFunctionID, AEValueExpr*, bool) when the expression is a column reference.

The implementation _MUST_ ensure that any previous successful invocations of any of the following methods are undone if this method returns false,

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

setAggregateLiteral

public abstract boolean setAggregateLiteral(AggrFunctionID aggrFnID,
                                            AELiteral argExpr,
                                            boolean withDistinct)
Set an aggregation function from the AGGREGATE_LIST. The aggregation function is in the form of,
 AGGREGATE_FN(literal)
 
This method is called by SetAggregateFn(SEAggrFunctionID, AEValueExpr*, bool) when the expression is a literal value.

The implementation _MUST_ ensure that any previous successful invocations of any of the following methods 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.

setGroupingColumn

public abstract boolean setGroupingColumn(int colIndex)
Set the column reference from the GROUPING_LIST.

This method is called by SetGroupingExpr(AEValueExpr*) when the expression is a column reference.

The implementation _MUST_ ensure that any previous successful invocations of any of the following methods are undone if this method returns false,

Parameters:
colIndex - The index of the column to group on.
Returns:
true if the grouping expression is set successfully, false otherwise.

setAggregateFn

public final boolean setAggregateFn(AggrFunctionID aggrFnID,
                                    AEValueExpr argExpr,
                                    boolean withDistinct)
Implements support for the following forms of aggregation function.
  1. AGGREGATE_FN(DISTINCT_FLAT column_reference). In this case, setAggregateColumn(AggrFunctionID, int, boolean) is called.
  2. AGGREGATE_FN(DISTINCT_FLAT literal). In this case, setAggregateLiteral(AggrFunctionID, AELiteral, boolean) is called.
An inheriting class needs only to provide implementations for the above two methods that are going to be called.

Specified by:
setAggregateFn in class AbstractAggregationHandler
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.
See Also:
AbstractAggregationHandler.setAggregateFn(AggrFunctionID, AEValueExpr, boolean)

setGroupingExpr

public final boolean setGroupingExpr(AEValueExpr node)
Implements the support for grouping on a single column.

That is, the following queries are supported.

The following queries, however, are not supported. setGroupingColumn(int) is called to once the grouping expression is found to be a single column reference only.

Specified by:
setGroupingExpr in class AbstractAggregationHandler
Parameters:
node - An expression from the GROUPING_LIST. Cannot be null.
Returns:
true if the grouping expression is set successfully, false otherwise.
See Also:
AbstractAggregationHandler.setGroupingExpr(AEValueExpr)


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