6 #ifndef TURI_SFRAME_QUERY_ENGINE_UTIL_AGGREGATES_HPP 7 #define TURI_SFRAME_QUERY_ENGINE_UTIL_AGGREGATES_HPP 8 #include <core/storage/sframe_data/sframe.hpp> 9 #include <core/storage/serialization/serialization_includes.hpp> 10 #include <core/storage/query_engine/operators/reduce.hpp> 11 #include <core/storage/query_engine/planning/planner.hpp> 20 namespace query_eval {
26 template <
typename T,
typename AggregateFunctionType>
31 fn(fn), initial_value(t), value(t) { }
48 std::stringstream strm;
78 AggregateFunctionType fn;
98 template <
typename ResultType,
99 typename ReduceFunctionType,
100 typename AggregateFunctionType>
102 std::shared_ptr<planner_node> input,
103 ReduceFunctionType reduce_fn,
104 AggregateFunctionType aggregate_fn,
105 ResultType init = ResultType()) {
111 auto iter = sfreader->begin(0);
112 ResultType result = init;
114 while(iter != sfreader->end(0)) {
116 std::string st = (*iter)[0];
117 iarchive iarc(st.c_str(), st.length());
119 aggregate_fn(curval, result);
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
group_aggregate_value * new_instance() const
Returns a new empty instance of sum with the same type.
sframe materialize(std::shared_ptr< planner_node > tip, materialize_options exec_params=materialize_options())
void add_element_simple(const flexible_type &flex)
Adds a new element to be summed.
ResultType reduce(std::shared_ptr< planner_node > input, ReduceFunctionType reduce_fn, AggregateFunctionType aggregate_fn, ResultType init=ResultType())
#define ASSERT_TRUE(cond)
flexible_type emit() const
Emits the result.
std::unique_ptr< reader_type > get_reader() const
void combine(const group_aggregate_value &flex)
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
void load(iarchive &iarc)
Deserializer.
void save(oarchive &oarc) const
Serializer.
bool support_type(flex_type_enum) const