6 #ifndef TURI_SFRAME_QUERY_ENGINE_QUERY_NODE_INFO_H_ 7 #define TURI_SFRAME_QUERY_ENGINE_QUERY_NODE_INFO_H_ 9 #include <core/storage/query_engine/operators/operator.hpp> 10 #include <core/storage/query_engine/operators/operator_properties.hpp> 11 #include <core/storage/query_engine/planning/planner_node.hpp> 15 namespace turi {
namespace query_eval {
18 typedef std::shared_ptr<node_info> node_info_ptr;
19 typedef std::shared_ptr<const node_info> cnode_info_ptr;
28 node_info(std::shared_ptr<planner_node> _pnode)
38 std::shared_ptr<planner_node>
pnode;
51 std::vector<node_info_ptr>
inputs, outputs;
56 bool node_visited =
false;
59 bool node_discarded =
false;
64 private:
mutable size_t _num_columns = size_t(-1);
70 if(_num_columns ==
size_t(-1))
88 auto it = this->pnode->operator_parameters.find(s);
89 ASSERT_MSG(it != this->pnode->operator_parameters.end(),
90 (std::string(
"Parameter ") + s +
" not valid in node of type " 97 bool has_p(
const std::string& s)
const {
98 auto it = this->pnode->operator_parameters.find(s);
99 return (it != this->pnode->operator_parameters.end());
102 template <
typename T>
103 const T& any_p(
const std::string& s)
const {
104 auto it = this->pnode->any_operator_parameters.find(s);
105 ASSERT_MSG(it != this->pnode->any_operator_parameters.end(),
106 (std::string(
"Any-parameter ") + s +
" not valid in node of type " 109 return it->second.as<T>();
112 bool has_any_p(
const std::string& s)
const {
113 auto it = this->pnode->any_operator_parameters.find(s);
114 return (it != this->pnode->any_operator_parameters.end());
120 inline bool input_type_present(
planner_node_type t,
size_t threshhold = 1)
const {
123 for(
const auto& n : inputs) {
126 if(threshhold == 1 || count >= threshhold)
139 inline void _debug_check_consistency(std::set<const node_info*>& seen)
const {
145 DASSERT_EQ(pnode->inputs.size(), inputs.size());
149 DASSERT_EQ(inputs.size(), attributes.
num_inputs);
155 std::map<const node_info*, size_t> input_counts;
156 for(
size_t i = 0; i < inputs.size(); ++i)
157 input_counts[inputs[i].
get()] += 1;
159 for(
size_t i = 0; i < inputs.size(); ++i) {
162 size_t n_present = 0;
163 for(
const auto& out : inputs[i]->outputs) {
165 if(out.get() ==
this)
169 DASSERT_EQ(n_present, input_counts.at(inputs[i].get()));
175 std::map<const node_info*, size_t> output_counts;
176 for(
size_t i = 0; i < outputs.size(); ++i)
177 output_counts[outputs[i].
get()] += 1;
179 for(
size_t i = 0; i < outputs.size(); ++i) {
180 size_t n_present = 0;
181 for(
const auto& out : outputs[i]->inputs) {
182 if(out.get() ==
this)
185 DASSERT_EQ(n_present, output_counts.at(outputs[i].get()));
190 for(
size_t i = 0; i < outputs.size(); ++i) {
191 outputs[i]->_debug_check_consistency(seen);
194 for(
size_t i = 0; i < inputs.size(); ++i) {
195 inputs[i]->_debug_check_consistency(seen);
200 inline void _debug_check_consistency()
const {
202 std::set<const node_info*> seen;
203 _debug_check_consistency(seen);
bool is_linear_transform(const query_operator_attributes &attr)
int64_t infer_planner_node_length(std::shared_ptr< planner_node > pnode)
std::string planner_node_type_to_name(planner_node_type type)
int num_inputs
Number of inputs expected to the operator.
std::vector< node_info_ptr > inputs
size_t num_columns() const
size_t infer_planner_node_num_output_columns(std::shared_ptr< planner_node > pnode)
query_operator_attributes planner_node_type_to_attributes(planner_node_type type)
bool is_sublinear_transform(const query_operator_attributes &attr)
std::shared_ptr< planner_node > pnode
bool is_source_node(const query_operator_attributes &attr)
#define DASSERT_TRUE(cond)
query_operator_attributes attributes