#include <AggComputer.h>
Inheritance diagram for AggComputer:
Public Member Functions | |
AggComputer () | |
virtual | ~AggComputer () |
virtual void | setInputAttrIndex (uint iInputAttrIndex) |
Sets the attribute index from which this computer should read input values in source tuples. | |
virtual void | clearAccumulator (TupleDatum &accumulatorDatum)=0 |
Clears an accumulator. | |
virtual void | updateAccumulator (TupleDatum &accumulatorDatum, TupleData const &inputTuple)=0 |
Updates an accumulator with a new input tuple. | |
virtual void | computeOutput (TupleDatum &outputDatum, TupleDatum const &accumulatorDatum)=0 |
Computes an output based on accumulator state. | |
virtual void | initAccumulator (TupleDatum &accumulatorDatumDest, TupleData const &inputTuple)=0 |
Initializes a new accumulator datum from an input tuple. | |
virtual void | initAccumulator (TupleDatum &accumulatorDatumSrc, TupleDatum &accumulatorDatumDest)=0 |
Initializes a new accumulator datum from an existing accumulator datum. | |
virtual void | updateAccumulator (TupleDatum &accumulatorDatumSrc, TupleDatum &accumulatorDatumDest, TupleData const &inputTuple)=0 |
Computes a new accumulator from an existing accumulator dataum and a new input tuple. | |
Static Public Member Functions | |
static AggComputer * | newAggComputer (AggFunction aggFunction, TupleAttributeDescriptor const *pAttrDesc) |
Virtual constructor. | |
Protected Attributes | |
int | iInputAttr |
In order to be used for more complex functions such as AVG which require compound accumulator state, it needs to be extended to allow AggComputer to collaborate with its caller in defining the accumulator tuple. Luckily, Farrago rewrites AVG to SUM/COUNT.
Definition at line 47 of file AggComputer.h.
AggComputer::AggComputer | ( | ) | [explicit] |
Definition at line 80 of file AggComputer.cpp.
References iInputAttr.
00081 { 00082 iInputAttr = -1; 00083 }
AggComputer::~AggComputer | ( | ) | [virtual] |
AggComputer * AggComputer::newAggComputer | ( | AggFunction | aggFunction, | |
TupleAttributeDescriptor const * | pAttrDesc | |||
) | [static] |
Virtual constructor.
aggFunction | function for which to construct a computer | |
pAttrDesc | descriptor for input attribute, or NULL for no input attribute (as in COUNT(*)) |
Definition at line 34 of file AggComputer.cpp.
References AGG_FUNC_COUNT, AGG_FUNC_MAX, AGG_FUNC_MIN, AGG_FUNC_SINGLE_VALUE, AGG_FUNC_SUM, STANDARD_TYPE_DOUBLE, STANDARD_TYPE_INT_16, STANDARD_TYPE_INT_32, STANDARD_TYPE_INT_64, STANDARD_TYPE_INT_8, STANDARD_TYPE_REAL, STANDARD_TYPE_UINT_16, STANDARD_TYPE_UINT_32, STANDARD_TYPE_UINT_64, and STANDARD_TYPE_UINT_8.
Referenced by SortedAggExecStream::newAggComputer(), and LhxAggExecStream::setAggComputers().
00037 { 00038 switch (aggFunction) { 00039 case AGG_FUNC_COUNT: 00040 if (pAttrDesc) { 00041 return new CountNullableAggComputer(); 00042 } else { 00043 return new CountStarAggComputer(); 00044 } 00045 case AGG_FUNC_SUM: 00046 assert(pAttrDesc); 00047 // TODO jvs 6-Oct-2005: gotta use some of that template 00048 // metaprogramming mumbo jumbo to get rid of this 00049 switch (pAttrDesc->pTypeDescriptor->getOrdinal()) { 00050 case STANDARD_TYPE_INT_8: 00051 return new SumAggComputer<int8_t>(); 00052 case STANDARD_TYPE_UINT_8: 00053 return new SumAggComputer<uint8_t>(); 00054 case STANDARD_TYPE_INT_16: 00055 return new SumAggComputer<int16_t>(); 00056 case STANDARD_TYPE_UINT_16: 00057 return new SumAggComputer<uint16_t>(); 00058 case STANDARD_TYPE_INT_32: 00059 return new SumAggComputer<int32_t>(); 00060 case STANDARD_TYPE_UINT_32: 00061 return new SumAggComputer<uint32_t>(); 00062 case STANDARD_TYPE_INT_64: 00063 return new SumAggComputer<int64_t>(); 00064 case STANDARD_TYPE_UINT_64: 00065 return new SumAggComputer<uint64_t>(); 00066 case STANDARD_TYPE_REAL: 00067 return new SumAggComputer<float>(); 00068 case STANDARD_TYPE_DOUBLE: 00069 return new SumAggComputer<double>(); 00070 } 00071 case AGG_FUNC_MIN: 00072 case AGG_FUNC_MAX: 00073 case AGG_FUNC_SINGLE_VALUE: 00074 assert(pAttrDesc); 00075 return new ExtremeAggComputer(aggFunction, *pAttrDesc); 00076 } 00077 permAssert(false); 00078 }
void AggComputer::setInputAttrIndex | ( | uint | iInputAttrIndex | ) | [virtual] |
Sets the attribute index from which this computer should read input values in source tuples.
iInputAttrIndex | 0-based tuple attribute index |
Reimplemented in LbmRepeatingAggComputer.
Definition at line 85 of file AggComputer.cpp.
References iInputAttr.
Referenced by LbmRepeatingAggComputer::setInputAttrIndex().
00086 { 00087 iInputAttr = iInputAttrInit; 00088 }
virtual void AggComputer::clearAccumulator | ( | TupleDatum & | accumulatorDatum | ) | [pure virtual] |
Clears an accumulator.
accumulatorDatum | in-memory value to be cleared |
Implemented in CountStarAggComputer, CountNullableAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
Referenced by LbmRepeatingAggComputer::clearAccumulator().
virtual void AggComputer::updateAccumulator | ( | TupleDatum & | accumulatorDatum, | |
TupleData const & | inputTuple | |||
) | [pure virtual] |
Updates an accumulator with a new input tuple.
accumulatorDatum | in-memory value to be updated | |
inputTuple | source for update; no references to this data should be retained after this method returns |
Implemented in CountStarAggComputer, CountNullableAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
Referenced by LbmRepeatingAggComputer::updateAccumulator().
virtual void AggComputer::computeOutput | ( | TupleDatum & | outputDatum, | |
TupleDatum const & | accumulatorDatum | |||
) | [pure virtual] |
Computes an output based on accumulator state.
outputDatum | receives reference to computed output in preparation for marshalling result | |
accumulatorDatum | final in-memory accumulator state |
Implemented in CountAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
Referenced by LbmRepeatingAggComputer::computeOutput().
virtual void AggComputer::initAccumulator | ( | TupleDatum & | accumulatorDatumDest, | |
TupleData const & | inputTuple | |||
) | [pure virtual] |
Initializes a new accumulator datum from an input tuple.
accumulatorDatumDest | in-memory value to be updated. Memory needs to be associated with this datum by the caller. | |
inputTuple | source for update; no references to this data should be retained after this method returns |
Implemented in CountStarAggComputer, CountNullableAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
virtual void AggComputer::initAccumulator | ( | TupleDatum & | accumulatorDatumSrc, | |
TupleDatum & | accumulatorDatumDest | |||
) | [pure virtual] |
Initializes a new accumulator datum from an existing accumulator datum.
accumulatorDatumSrc | the existing accumulator datum | |
accumulatorDatumDest | the new accumulator datum. Memory needs to be associated with this datum by the caller. |
Implemented in CountStarAggComputer, CountNullableAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
virtual void AggComputer::updateAccumulator | ( | TupleDatum & | accumulatorDatumSrc, | |
TupleDatum & | accumulatorDatumDest, | |||
TupleData const & | inputTuple | |||
) | [pure virtual] |
Computes a new accumulator from an existing accumulator dataum and a new input tuple.
accumulatorDatumSrc | the existing accumulator datum | |
accumulatorDatumDest | the new accumulator datum. memory needs to be associated with this datum by the caller. | |
inputTuple | source for update; no references to this data should be retained after this method returns |
Implemented in CountStarAggComputer, CountNullableAggComputer, ExtremeAggComputer, SumAggComputer< T >, and LbmRepeatingAggComputer.
int AggComputer::iInputAttr [protected] |
Definition at line 50 of file AggComputer.h.
Referenced by AggComputer(), CountStarAggComputer::clearAccumulator(), SumAggComputer< T >::initAccumulator(), ExtremeAggComputer::initAccumulator(), CountNullableAggComputer::initAccumulator(), CountStarAggComputer::initAccumulator(), setInputAttrIndex(), SumAggComputer< T >::updateAccumulator(), ExtremeAggComputer::updateAccumulator(), and CountNullableAggComputer::updateAccumulator().