Turi Create  4.0
groupby_aggregate.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_SFRAME_QUERY_ENGINE_HPP
7 #define TURI_SFRAME_QUERY_ENGINE_HPP
8 #include <vector>
9 #include <string>
10 #include <utility>
11 #include <memory>
12 #include <core/storage/sframe_data/group_aggregate_value.hpp>
13 
14 namespace turi {
15 class sframe;
16 namespace query_eval {
17 struct planner_node;
18 
19 /**
20  * \ingroup sframe_query_engine
21  * \addtogroup Algorithms Algorithms
22  * \{
23  */
24 /**
25  * Groupby aggregate algorithm that operates on lazy input.
26  *
27  * Identical to \ref turi::groupby_aggregate but can take a lazy input.
28  *
29  * \param source The lazy input node
30  * \param source_column_names The column names of the input source
31  * \param keys An array of column names to generate the group on
32  * \param output_column_names The output column names for each aggregate.
33  * This must be the same length as the 'groups' parameter.
34  * Output column names must be unique and must not
35  * share similar column names as keys. If there are any
36  * empty entries, their values will be automatically
37  * assigned.
38  * \param groups A collection of {column_names, group operator} pairs describing
39  * the aggregates to generate. You can have multiple aggregators
40  * for each set of columns. You do not need every column in the source
41  * to be represented. This must be the same length as the
42  * 'group_output_columns' parameter.
43 
44  */
45 std::shared_ptr<sframe> groupby_aggregate(
46  const std::shared_ptr<planner_node>& source,
47  const std::vector<std::string>& source_column_names,
48  const std::vector<std::string>& keys,
49  const std::vector<std::string>& output_column_names,
50  const std::vector<std::pair<std::vector<std::string>,
51  std::shared_ptr<group_aggregate_value>>>& groups);
52 
53 /// \}
54 } // namespace query_eval
55 } // namespace turi
56 #endif
std::set< Key > keys(const std::map< Key, T > &map)
Definition: stl_util.hpp:358
std::shared_ptr< sframe > groupby_aggregate(const std::shared_ptr< planner_node > &source, const std::vector< std::string > &source_column_names, const std::vector< std::string > &keys, const std::vector< std::string > &output_column_names, const std::vector< std::pair< std::vector< std::string >, std::shared_ptr< group_aggregate_value >>> &groups)