#include <AggComputerImpl.h>
Inheritance diagram for CountStarAggComputer:
Public Member Functions | |
virtual void | clearAccumulator (TupleDatum &accumulatorDatum) |
Clears an accumulator. | |
virtual void | updateAccumulator (TupleDatum &accumulatorDatum, TupleData const &inputTuple) |
Updates an accumulator with a new input tuple. | |
virtual void | initAccumulator (TupleDatum &accumulatorDatumDest, TupleData const &inputTuple) |
Initializes a new accumulator datum from an input tuple. | |
virtual void | initAccumulator (TupleDatum &accumulatorDatumSrc, TupleDatum &accumulatorDatumDest) |
Initializes a new accumulator datum from an existing accumulator datum. | |
virtual void | updateAccumulator (TupleDatum &accumulatorDatumSrc, TupleDatum &accumulatorDatumDest, TupleData const &inputTuple) |
Computes a new accumulator from an existing accumulator dataum and a new input tuple. | |
virtual void | computeOutput (TupleDatum &outputDatum, TupleDatum const &accumulatorDatum) |
Computes an output based on accumulator state. | |
virtual void | setInputAttrIndex (uint iInputAttrIndex) |
Sets the attribute index from which this computer should read input values in source tuples. | |
Static Public Member Functions | |
static AggComputer * | newAggComputer (AggFunction aggFunction, TupleAttributeDescriptor const *pAttrDesc) |
Virtual constructor. | |
Protected Member Functions | |
uint64_t & | interpretDatum (TupleDatum &) |
void | clearAccumulatorImpl (TupleDatum &accumulatorDatum) |
void | initAccumulatorImpl (TupleDatum &accumulatorDatum) |
void | updateAccumulatorImpl (TupleDatum &accumulatorDatum) |
Protected Attributes | |
int | iInputAttr |
Definition at line 58 of file AggComputerImpl.h.
void CountStarAggComputer::clearAccumulator | ( | TupleDatum & | accumulatorDatum | ) | [virtual] |
Clears an accumulator.
accumulatorDatum | in-memory value to be cleared |
Implements AggComputer.
Definition at line 128 of file AggComputer.cpp.
References CountAggComputer::clearAccumulatorImpl(), and AggComputer::iInputAttr.
00129 { 00130 assert(iInputAttr == -1); 00131 clearAccumulatorImpl(accumulatorDatum); 00132 }
void CountStarAggComputer::updateAccumulator | ( | TupleDatum & | accumulatorDatum, | |
TupleData const & | inputTuple | |||
) | [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 |
Implements AggComputer.
Definition at line 134 of file AggComputer.cpp.
References CountAggComputer::updateAccumulatorImpl().
00137 { 00138 updateAccumulatorImpl(accumulatorDatum); 00139 }
void CountStarAggComputer::initAccumulator | ( | TupleDatum & | accumulatorDatumDest, | |
TupleData const & | inputTuple | |||
) | [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 |
Implements AggComputer.
Definition at line 141 of file AggComputer.cpp.
References AggComputer::iInputAttr, and CountAggComputer::initAccumulatorImpl().
00144 { 00145 assert(iInputAttr == -1); 00146 initAccumulatorImpl(accumulatorDatum); 00147 }
void CountStarAggComputer::initAccumulator | ( | TupleDatum & | accumulatorDatumSrc, | |
TupleDatum & | accumulatorDatumDest | |||
) | [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. |
Implements AggComputer.
Definition at line 149 of file AggComputer.cpp.
References TupleDatum::memCopyFrom().
00152 { 00153 accumulatorDatumDest.memCopyFrom(accumulatorDatumSrc); 00154 }
void CountStarAggComputer::updateAccumulator | ( | TupleDatum & | accumulatorDatumSrc, | |
TupleDatum & | accumulatorDatumDest, | |||
TupleData const & | inputTuple | |||
) | [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 |
Implements AggComputer.
Definition at line 156 of file AggComputer.cpp.
References TupleDatum::copyFrom(), and CountAggComputer::updateAccumulatorImpl().
00160 { 00161 updateAccumulatorImpl(accumulatorDatumSrc); 00162 /* 00163 * For count, accumulatorDatumSrc can accomodate the updated value so 00164 * there is no need to use memCopyFrom. 00165 */ 00166 accumulatorDatumDest.copyFrom(accumulatorDatumSrc); 00167 }
uint64_t & CountAggComputer::interpretDatum | ( | TupleDatum & | ) | [inline, protected, inherited] |
Definition at line 94 of file AggComputer.cpp.
References TupleDatum::cbData, and TupleDatum::pData.
Referenced by CountAggComputer::clearAccumulatorImpl(), CountAggComputer::initAccumulatorImpl(), and CountAggComputer::updateAccumulatorImpl().
00095 { 00096 assert(datum.cbData == sizeof(uint64_t)); 00097 assert(datum.pData); 00098 return *reinterpret_cast<uint64_t *>(const_cast<PBuffer>(datum.pData)); 00099 }
void CountAggComputer::clearAccumulatorImpl | ( | TupleDatum & | accumulatorDatum | ) | [inline, protected, inherited] |
Definition at line 101 of file AggComputer.cpp.
References count(), and CountAggComputer::interpretDatum().
Referenced by CountNullableAggComputer::clearAccumulator(), clearAccumulator(), and CountNullableAggComputer::initAccumulator().
00102 { 00103 uint64_t &count = interpretDatum(accumulatorDatum); 00104 count = 0; 00105 }
void CountAggComputer::initAccumulatorImpl | ( | TupleDatum & | accumulatorDatum | ) | [inline, protected, inherited] |
Definition at line 107 of file AggComputer.cpp.
References count(), and CountAggComputer::interpretDatum().
Referenced by CountNullableAggComputer::initAccumulator(), and initAccumulator().
00108 { 00109 uint64_t &count = interpretDatum(accumulatorDatum); 00110 count = 1; 00111 }
void CountAggComputer::updateAccumulatorImpl | ( | TupleDatum & | accumulatorDatum | ) | [inline, protected, inherited] |
Definition at line 113 of file AggComputer.cpp.
References count(), and CountAggComputer::interpretDatum().
Referenced by CountNullableAggComputer::updateAccumulator(), and updateAccumulator().
00115 { 00116 uint64_t &count = interpretDatum(accumulatorDatum); 00117 ++count; 00118 }
void CountAggComputer::computeOutput | ( | TupleDatum & | outputDatum, | |
TupleDatum const & | accumulatorDatum | |||
) | [virtual, inherited] |
Computes an output based on accumulator state.
outputDatum | receives reference to computed output in preparation for marshalling result | |
accumulatorDatum | final in-memory accumulator state |
Implements AggComputer.
Definition at line 120 of file AggComputer.cpp.
00123 { 00124 // Set output to alias accumulator value directly. 00125 outputDatum = accumulatorDatum; 00126 }
AggComputer * AggComputer::newAggComputer | ( | AggFunction | aggFunction, | |
TupleAttributeDescriptor const * | pAttrDesc | |||
) | [static, inherited] |
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, inherited] |
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 AggComputer::iInputAttr.
Referenced by LbmRepeatingAggComputer::setInputAttrIndex().
00086 { 00087 iInputAttr = iInputAttrInit; 00088 }
int AggComputer::iInputAttr [protected, inherited] |
Definition at line 50 of file AggComputer.h.
Referenced by AggComputer::AggComputer(), clearAccumulator(), SumAggComputer< T >::initAccumulator(), ExtremeAggComputer::initAccumulator(), CountNullableAggComputer::initAccumulator(), initAccumulator(), AggComputer::setInputAttrIndex(), SumAggComputer< T >::updateAccumulator(), ExtremeAggComputer::updateAccumulator(), and CountNullableAggComputer::updateAccumulator().