Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class SumAvgAggregateDefinition

extends Object
implements AggregateDefinition
Class Inheritance
All Implemented Interfaces
org.apache.derby.impl.sql.compile.AggregateDefinition
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.context.ContextService, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CompilerContext, .TypeCompiler, .TypeCompilerFactory, org.apache.derby.iapi.types.DataTypeDescriptor, .TypeId

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

Field Summary

Modifier and TypeField and Description
private boolean

Constructor Summary

AccessConstructor and Description
public
SumAvgAggregateDefinition()

Niladic constructor.

Method Summary

Modifier and TypeMethod and Description
public final DataTypeDescriptor

Returns:

the output Class (null if cannot operate on value expression of this type.
getAggregator
(DataTypeDescriptor
the input type, either a user type or a java.lang object
inputType
,
StringBuffer
output parameter, filled in with the class name that implements com.ibm.db2j.aggregates.Aggregator
aggregatorClass
)

Implements org.apache.derby.impl.sql.compile.AggregateDefinition.getAggregator.

Determines the result datatype.

private String

Returns:

SumAggregator.CLASS_NAME/AvgAggregator.CLASS_NAME
getAggregatorClassName
()

Return the aggregator class.

protected String

Returns:

TypeCompiler.SUM_OP /TypeCompiler.AVG_OP
getOperator
()

Return the arithmetic operator corresponding to this operation.

pack-priv final void
setSumOrAvg(boolean isSum)

This is set by the parser.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isSumback to summary
private boolean isSum

Constructor Detail

SumAvgAggregateDefinitionback to summary
public SumAvgAggregateDefinition()

Niladic constructor. Does nothing. For ease Of use, only.

Method Detail

getAggregatorback to summary
public final DataTypeDescriptor getAggregator(DataTypeDescriptor inputType, StringBuffer aggregatorClass)

Implements org.apache.derby.impl.sql.compile.AggregateDefinition.getAggregator.

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().

Parameters
inputType:DataTypeDescriptor

the input type, either a user type or a java.lang object

aggregatorClass:StringBuffer

Doc from org.apache.derby.impl.sql.compile.AggregateDefinition.getAggregator.

output parameter, filled in with the class name that implements com.ibm.db2j.aggregates.Aggregator

Returns:DataTypeDescriptor

the output Class (null if cannot operate on value expression of this type.

getAggregatorClassNameback to summary
private String getAggregatorClassName()

Return the aggregator class.

Returns:String

SumAggregator.CLASS_NAME/AvgAggregator.CLASS_NAME

getOperatorback to summary
protected String getOperator()

Return the arithmetic operator corresponding to this operation.

Returns:String

TypeCompiler.SUM_OP /TypeCompiler.AVG_OP

setSumOrAvgback to summary
pack-priv final void setSumOrAvg(boolean isSum)

This is set by the parser.