Turi Create  4.0
materialize_options.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_MATERIALIZE_OPTIONS_HPP
7 #define TURI_SFRAME_QUERY_ENGINE_MATERIALIZE_OPTIONS_HPP
8 #include <memory>
9 #include <cstddef>
10 #include <functional>
11 #include <vector>
12 #include <string>
13 
14 namespace turi {
15 class sframe_rows;
16 namespace query_eval {
17 
18 /**
19  * \ingroup sframe_query_engine
20  * \addtogroup planning Planning, Optimization and Execution
21  * \{
22  */
23 
24 /**
25  * Materialization options.
26  *
27  * This options can be used to control each stage of the materialization
28  * pipeline. Used in the \ref materialize methods.
29  */
31 
32  /**
33  * The number of segments to break parallel processing into. Also
34  * may affect the number of segments of the output SFrame.
35  */
36  size_t num_segments = 0;
37 
38  /**
39  * If set, the final sframe output will be streamed into the callback
40  * function and an empty SFrame will be returned.
41  *
42  * The type of the callback function is
43  * \code
44  * std::function<bool(size_t, const std::shared_ptr<sframe_rows>&)>,
45  * \endcode
46  *
47  * where the first argument is the segment_id being processed, and
48  * the rest is the data. If true is returned, then the processing
49  * is stopped.
50  */
51  std::function<bool(size_t, const std::shared_ptr<sframe_rows>&)> write_callback;
52 
53  /**
54  * Disables query optimizations.
55  */
56  bool disable_optimization = false;
57 
58  /**
59  * If Optimizations are enabled, enabling this will only
60  * run the first pass optimizations: project/union reordering.
61  */
63 
64  /**
65  * If true, then the naive materialize algorithm will be run.
66  * All nodes will be explicitly materialized, and no
67  * optimization will be performed. Useful for error checking
68  * the optimizations.
69  */
70  bool naive_mode = false;
71 
72  /**
73  * If true, the materialization algorithm will partially materialize
74  * the query plan until all remaining paths are linearly consumable.
75  *
76  * For successful query execution, this should always be true. When this is
77  * false, query execution may fail for particular types of plans due to
78  * rate control issues.
79  */
80  bool partial_materialize = true;
81 
82  /**
83  * if set, these parameter defines the sframe output index file location
84  * of the final sframe. Also see \ref output_column_names
85  * This argument has no effect if \ref write_callback is set.
86  */
87  std::string output_index_file = "";
88 
89  /**
90  * if set, this parameter defines the column names of the output sframe.
91  * Otherwise X1,X2,X3... is used.
92  * of the final sframe. Also see \ref output_index_file.
93  * This argument has no effect if \ref write_callback is set.
94  */
95  std::vector<std::string> output_column_names;
96 };
97 
98 /// \}
99 } // query_eval
100 } // turicreate
101 #endif
std::function< bool(size_t, const std::shared_ptr< sframe_rows > &)> write_callback
std::vector< std::string > output_column_names