ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
AvgAgg< T > Struct Template Reference

Aggregator implementing AVG; always returns a float result. More...

Inheritance diagram for AvgAgg< T >:
Collaboration diagram for AvgAgg< T >:

Public Member Functions

void add (const AggValue &x) override
 Incorporate one input value into the running aggregate.
 
AggregationOperator op () const override
 Return the aggregation operator this accumulator implements.
 
AggValue finalize () const override
 Return the final aggregate result.
 
ValueType inputType () const override
 Return the type of the input values accepted by add().
 
ValueType resultType () const override
 Return the type of the value returned by finalize().
 
- Public Member Functions inherited from Aggregator
virtual ~Aggregator ()=default
 

Protected Attributes

double sum = 0
 Running sum of all non-NULL input values.
 
unsigned count = 0
 Number of non-NULL inputs seen so far.
 
bool has = false
 true once the first non-NULL input has been seen
 

Detailed Description

template<class T>
struct AvgAgg< T >

Aggregator implementing AVG; always returns a float result.

Definition at line 227 of file Aggregation.cpp.

Member Function Documentation

◆ add()

template<class T >
void AvgAgg< T >::add ( const AggValue x)
inlineoverridevirtual

Incorporate one input value into the running aggregate.

Parameters
xInput value to add.

Implements Aggregator.

Definition at line 234 of file Aggregation.cpp.

Here is the call graph for this function:

◆ finalize()

template<class T >
AggValue AvgAgg< T >::finalize ( ) const
inlineoverridevirtual

Return the final aggregate result.

Returns
The accumulated aggregate as an AggValue.

Implements Aggregator.

Definition at line 244 of file Aggregation.cpp.

◆ inputType()

template<class T >
ValueType AvgAgg< T >::inputType ( ) const
inlineoverridevirtual

Return the type of the input values accepted by add().

Returns
The ValueType of values passed to add().

Implements Aggregator.

Definition at line 247 of file Aggregation.cpp.

◆ op()

template<class T >
AggregationOperator AvgAgg< T >::op ( ) const
inlineoverridevirtual

Return the aggregation operator this accumulator implements.

Returns
The AggregationOperator enum value for this accumulator.

Implements Aggregator.

Definition at line 241 of file Aggregation.cpp.

◆ resultType()

template<class T >
ValueType AvgAgg< T >::resultType ( ) const
inlineoverridevirtual

Return the type of the value returned by finalize().

Defaults to inputType(); override when the result type differs (e.g., AVG returns FLOAT regardless of the input type).

Returns
The ValueType of the value returned by finalize().

Reimplemented from Aggregator.

Definition at line 255 of file Aggregation.cpp.

Member Data Documentation

◆ count

template<class T >
unsigned AvgAgg< T >::count = 0
protected

Number of non-NULL inputs seen so far.

Definition at line 230 of file Aggregation.cpp.

◆ has

template<class T >
bool AvgAgg< T >::has = false
protected

true once the first non-NULL input has been seen

Definition at line 231 of file Aggregation.cpp.

◆ sum

template<class T >
double AvgAgg< T >::sum = 0
protected

Running sum of all non-NULL input values.

Definition at line 229 of file Aggregation.cpp.


The documentation for this struct was generated from the following file: