ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Aggregation.cpp File Reference

Aggregation operator and accumulator implementations. More...

#include "Aggregation.h"
#include <string>
#include <stdexcept>
#include "utils/lsyscache.h"
#include "utils/elog.h"
#include "provsql_error.h"
Include dependency graph for Aggregation.cpp:

Go to the source code of this file.

Classes

struct  NoneAgg
 Aggregator that ignores all inputs and always returns NULL. More...
 
struct  False<... >
 
struct  StandardAgg< T >
 Base aggregator template for scalar types (int, float, bool, string). More...
 
struct  SumAgg< T >
 Aggregator implementing SUM for integer or float types. More...
 
struct  MinAgg< T >
 Aggregator implementing MIN for integer or float types. More...
 
struct  MaxAgg< T >
 Aggregator implementing MAX for integer or float types. More...
 
struct  AndAgg
 Aggregator implementing boolean AND (returns false if any input is false). More...
 
struct  OrAgg
 Aggregator implementing boolean OR (returns true if any input is true). More...
 
struct  ChooseAgg< T >
 Aggregator implementing CHOOSE (returns the first non-NULL input). More...
 
struct  AvgAgg< T >
 Aggregator implementing AVG; always returns a float result. More...
 
struct  ArrayAgg< T >
 Aggregator implementing ARRAY_AGG; collects all non-NULL inputs into an array. More...
 

Functions

AggregationOperator getAggregationOperator (Oid oid)
 Map a PostgreSQL aggregate function OID to an AggregationOperator.
 
std::unique_ptr< AggregatormakeAggregator (AggregationOperator op, ValueType t)
 Create a concrete Aggregator for the given operator and value type.
 

Detailed Description

Aggregation operator and accumulator implementations.

Implements the two factory functions declared in Aggregation.h:

Each aggregation function × value-type combination has its own Aggregator subclass defined locally in this file (e.g. SumAggregator<long>, MinAggregator<double>, ArrayAggregator<std::string>, etc.).

Definition in file Aggregation.cpp.

Function Documentation

◆ getAggregationOperator()

AggregationOperator getAggregationOperator ( Oid  oid)

Map a PostgreSQL aggregate function OID to an AggregationOperator.

Parameters
oidOID of the aggregate function (e.g. F_COUNT_ANY, F_SUM_INT4).
Returns
The corresponding AggregationOperator.

Definition at line 29 of file Aggregation.cpp.

Here is the caller graph for this function:

◆ makeAggregator()

std::unique_ptr< Aggregator > makeAggregator ( AggregationOperator  op,
ValueType  t 
)

Create a concrete Aggregator for the given operator and value type.

Parameters
opThe aggregation function to implement.
tThe type of input values that will be accumulated.
Returns
A heap-allocated Aggregator, or nullptr if the combination is not supported.

Definition at line 294 of file Aggregation.cpp.

Here is the caller graph for this function: