org.teiid.query.function.aggregate
Class Avg

java.lang.Object
  extended by org.teiid.query.function.aggregate.AggregateFunction
      extended by org.teiid.query.function.aggregate.Sum
          extended by org.teiid.query.function.aggregate.Avg

public class Avg
extends Sum

Accumulates (per tuple) and calculates the average of the values of a column. The type of the result varies depending on the type of the input AggregateSymbol - the type will not be an integral type but will always be some kind of decimal type.


Field Summary
 
Fields inherited from class org.teiid.query.function.aggregate.Sum
accumulatorType, BIG_DECIMAL, BIG_INTEGER, DOUBLE, LONG
 
Constructor Summary
Avg()
           
 
Method Summary
 void addInputDirect(java.lang.Object input, java.util.List<?> tuple)
          Called for the element value in every row of a group.
 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 org.teiid.query.function.aggregate.Sum
getAccumulatorType
 
Methods inherited from class org.teiid.query.function.aggregate.AggregateFunction
addInput, respectsNull, setConditionIndex, setExpressionIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Avg

public Avg()
Method Detail

initialize

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

Overrides:
initialize in class Sum
Parameters:
dataType - Data type of element begin aggregated
See Also:
org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)

reset

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

Overrides:
reset in class Sum

addInputDirect

public void addInputDirect(java.lang.Object input,
                           java.util.List<?> tuple)
                    throws FunctionExecutionException,
                           ExpressionEvaluationException,
                           TeiidComponentException
Description copied from class: AggregateFunction
Called for the element value in every row of a group.

Overrides:
addInputDirect in class Sum
Parameters:
input - Input value, may be null
Throws:
FunctionExecutionException
ExpressionEvaluationException
TeiidComponentException
See Also:
AggregateFunction.addInputDirect(Object, List)

getResult

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

Overrides:
getResult in class Sum
Returns:
Result value
Throws:
FunctionExecutionException
ExpressionEvaluationException
TeiidComponentException
See Also:
AggregateFunction.getResult()


Copyright © 2011. All Rights Reserved.