Turi Create  4.0
turi::query_eval::generic_aggregator< T, AggregateFunctionType > Class Template Reference

#include <core/storage/query_engine/util/aggregates.hpp>

Public Member Functions

group_aggregate_valuenew_instance () const
 Returns a new empty instance of sum with the same type.
 
void add_element_simple (const flexible_type &flex)
 Adds a new element to be summed.
 
flexible_type emit () const
 Emits the result.
 
void combine (const group_aggregate_value &flex)
 
bool support_type (flex_type_enum) const
 
void save (oarchive &oarc) const
 Serializer.
 
void load (iarchive &iarc)
 Deserializer.
 
std::string name () const
 
virtual void add_element (const std::vector< flexible_type > &values)
 
virtual void partial_finalize ()
 
virtual flex_type_enum set_input_types (const std::vector< flex_type_enum > &types)
 
virtual void print (std::ostream &os) const
 

Detailed Description

template<typename T, typename AggregateFunctionType>
class turi::query_eval::generic_aggregator< T, AggregateFunctionType >

Implements a generic aggregator where a function is called on each add method.

Any attempt to combine, or save, will result in a failure.

Definition at line 27 of file aggregates.hpp.

Member Function Documentation

◆ add_element()

virtual void turi::group_aggregate_value::add_element ( const std::vector< flexible_type > &  values)
inlinevirtualinherited

Adds an element to the aggregate. Elements to be added will be either the input_type (as set by set_input_type()) or UNDEFINED.

Operator that expects more than one input values need to overwrite this function

Reimplemented in turi::groupby_operators::zip_dict, turi::groupby_operators::argmax, and turi::groupby_operators::argmin.

Definition at line 60 of file group_aggregate_value.hpp.

◆ combine()

template<typename T, typename AggregateFunctionType>
void turi::query_eval::generic_aggregator< T, AggregateFunctionType >::combine ( const group_aggregate_value other)
inlinevirtual

Combines two partial aggregates

Implements turi::group_aggregate_value.

Definition at line 54 of file aggregates.hpp.

◆ name()

template<typename T, typename AggregateFunctionType>
std::string turi::query_eval::generic_aggregator< T, AggregateFunctionType >::name ( ) const
inlinevirtual

Returns a printable name of the operation.

Implements turi::group_aggregate_value.

Definition at line 73 of file aggregates.hpp.

◆ partial_finalize()

virtual void turi::group_aggregate_value::partial_finalize ( )
inlinevirtualinherited

No more elements will be added to this value. However, this value may still be combined with other values.

Reimplemented in turi::groupby_operators::quantile.

Definition at line 75 of file group_aggregate_value.hpp.

◆ print()

virtual void turi::group_aggregate_value::print ( std::ostream &  os) const
inlinevirtualinherited

Override this function for allowing the operator to be easily printed.

std::cout << aggregator <<s std::endl;

Reimplemented in turi::groupby_operators::variance.

Definition at line 134 of file group_aggregate_value.hpp.

◆ set_input_types()

virtual flex_type_enum turi::group_aggregate_value::set_input_types ( const std::vector< flex_type_enum > &  types)
inlinevirtualinherited

Sets the input types and returns the output type. For instance, a sum aggregator when summing integers will return an integer, and when summing doubles will return doubles.

Default implementation assumes there is ony one input, and output type is the same as input type.

Reimplemented in turi::groupby_operators::zip_list, turi::groupby_operators::zip_dict, turi::groupby_operators::non_null_count, turi::groupby_operators::count, turi::groupby_operators::argmax, and turi::groupby_operators::argmin.

Definition at line 102 of file group_aggregate_value.hpp.

◆ support_type()

template<typename T, typename AggregateFunctionType>
bool turi::query_eval::generic_aggregator< T, AggregateFunctionType >::support_type ( flex_type_enum  type) const
inlinevirtual

Returns true if the the aggregate_value can consume a column of this type, and false otherwise. (For instance, a sum aggregator can consume integers and floats, and not anything else).

Implements turi::group_aggregate_value.

Definition at line 58 of file aggregates.hpp.


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