com.metamatrix.query.function.aggregate
Class Sum

java.lang.Object
  extended by com.metamatrix.query.function.aggregate.Sum
All Implemented Interfaces:
AggregateFunction
Direct Known Subclasses:
Avg

public class Sum
extends java.lang.Object
implements AggregateFunction

Accumulates (per tuple) and calculates the sum of the values of a column. The type of the result varies depending on the type of the input AggregateSymbol


Field Summary
protected  int accumulatorType
           
protected static int BIG_DECIMAL
           
protected static int BIG_INTEGER
           
protected static int DOUBLE
           
protected static int LONG
           
 
Constructor Summary
Sum()
          Constructor for Sum.
 
Method Summary
 void addInput(java.lang.Object input)
          Called for the element value in every row of a group.
protected  int getAccumulatorType()
          Allows subclasses to determine type of accumulator for the SUM.
 java.lang.Object getResult()
          Called after all values have been processed to get the result.
 void initialize(java.lang.Class dataType, java.lang.Class inputType)
          Called to initialize the function.
 void reset()
          Called to reset the state of the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LONG

protected static final int LONG
See Also:
Constant Field Values

DOUBLE

protected static final int DOUBLE
See Also:
Constant Field Values

BIG_INTEGER

protected static final int BIG_INTEGER
See Also:
Constant Field Values

BIG_DECIMAL

protected static final int BIG_DECIMAL
See Also:
Constant Field Values

accumulatorType

protected int accumulatorType
Constructor Detail

Sum

public Sum()
Constructor for Sum.

Method Detail

getAccumulatorType

protected int getAccumulatorType()
Allows subclasses to determine type of accumulator for the SUM.

Returns:
Type, as defined in constants

initialize

public void initialize(java.lang.Class dataType,
                       java.lang.Class inputType)
Description copied from interface: AggregateFunction
Called to initialize the function. In the future this may expand with additional information.

Specified by:
initialize in interface AggregateFunction
Parameters:
dataType - Data type of element begin aggregated
See Also:
com.metamatrix.query.function.aggregate.AggregateFunction#initialize(boolean, String)

reset

public void reset()
Description copied from interface: AggregateFunction
Called to reset the state of the function.

Specified by:
reset in interface AggregateFunction

addInput

public void addInput(java.lang.Object input)
              throws FunctionExecutionException,
                     ExpressionEvaluationException,
                     MetaMatrixComponentException
Description copied from interface: AggregateFunction
Called for the element value in every row of a group.

Specified by:
addInput in interface AggregateFunction
Parameters:
input - Input value, may be null
Throws:
FunctionExecutionException
ExpressionEvaluationException
MetaMatrixComponentException
See Also:
AggregateFunction.addInput(Object)

getResult

public java.lang.Object getResult()
                           throws FunctionExecutionException,
                                  ExpressionEvaluationException,
                                  MetaMatrixComponentException
Description copied from interface: AggregateFunction
Called after all values have been processed to get the result.

Specified by:
getResult in interface AggregateFunction
Returns:
Result value
Throws:
FunctionExecutionException
ExpressionEvaluationException
MetaMatrixComponentException
See Also:
AggregateFunction.getResult()


Copyright © 2009. All Rights Reserved.