6 #ifndef TURI_SFRAME_ROLLING_AGGREGATE_HPP 7 #define TURI_SFRAME_ROLLING_AGGREGATE_HPP 9 #include <core/data/flexible_type/flexible_type.hpp> 10 #include <core/storage/sframe_data/sarray.hpp> 11 #include <core/storage/sframe_data/groupby_aggregate_operators.hpp> 24 namespace rolling_aggregate {
26 typedef boost::circular_buffer<flexible_type>::iterator circ_buffer_iterator_t;
27 typedef std::function<flexible_type(circ_buffer_iterator_t,circ_buffer_iterator_t)> full_window_fn_type_t;
59 std::shared_ptr<group_aggregate_value> agg_op,
62 size_t min_observations);
66 template<
typename Iterator>
68 Iterator first, Iterator last) {
69 auto agg = agg_op->new_instance();
70 for(; first != last; ++first) {
71 agg->add_element_simple(*first);
83 template<
typename Iterator>
87 size_t observations = 0;
89 bool need_all = (min_observations == size_t(-1));
90 for(; first != last; ++first, ++count) {
93 if(!need_all && (observations >= min_observations)) {
100 return (observations == count);
107 #endif // TURI_SFRAME_ROLLING_AGGREGATE_HPP
bool has_min_observations(size_t min_observations, Iterator first, Iterator last)
std::shared_ptr< sarray< flexible_type > > rolling_apply(const sarray< flexible_type > &input, std::shared_ptr< group_aggregate_value > agg_op, ssize_t window_start, ssize_t window_end, size_t min_observations)
flexible_type full_window_aggregate(std::shared_ptr< group_aggregate_value > agg_op, Iterator first, Iterator last)
Aggregate functions.