org.apache.derby.impl.sql.compile
Class SumAvgAggregateDefinition

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.SumAvgAggregateDefinition
All Implemented Interfaces:
AggregateDefinition

public class SumAvgAggregateDefinition
extends java.lang.Object
implements AggregateDefinition

Defintion for the SUM()/AVG() aggregates.


Field Summary
private  boolean isSum
           
 
Constructor Summary
SumAvgAggregateDefinition()
          Niladic constructor.
 
Method Summary
 DataTypeDescriptor getAggregator(DataTypeDescriptor inputType, java.lang.StringBuffer aggregatorClass)
          Determines the result datatype.
private  java.lang.String getAggregatorClassName()
          Return the aggregator class.
protected  java.lang.String getOperator()
          Return the arithmetic operator corresponding to this operation.
 void setSumOrAvg(boolean isSum)
          This is set by the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isSum

private boolean isSum
Constructor Detail

SumAvgAggregateDefinition

public SumAvgAggregateDefinition()
Niladic constructor. Does nothing. For ease Of use, only.

Method Detail

getAggregator

public final DataTypeDescriptor getAggregator(DataTypeDescriptor inputType,
                                              java.lang.StringBuffer aggregatorClass)
Determines the result datatype. Accept NumberDataValues only.

Note: In the future you should be able to do a sum user data types. One option would be to run sum on anything that implements plus(). In which case avg() would need divide().

Specified by:
getAggregator in interface AggregateDefinition
Parameters:
inputType - the input type, either a user type or a java.lang object
aggregatorClass - output parameter, filled in with the class name that implements com.ibm.db2j.aggregates.Aggregator
Returns:
the output Class (null if cannot operate on value expression of this type.
See Also:
TypeDescriptor

getAggregatorClassName

private java.lang.String getAggregatorClassName()
Return the aggregator class.

Returns:
SumAggregator.CLASS_NAME/AvgAggregator.CLASS_NAME

getOperator

protected java.lang.String getOperator()
Return the arithmetic operator corresponding to this operation.

Returns:
TypeCompiler.SUM_OP /TypeCompiler.AVG_OP

setSumOrAvg

public final void setSumOrAvg(boolean isSum)
This is set by the parser.


Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.