1 /* ------------------------------------------------
\r
2 Copyright 2014 AT&T Intellectual Property
\r
3 Licensed under the Apache License, Version 2.0 (the "License");
\r
4 you may not use this file except in compliance with the License.
\r
5 You may obtain a copy of the License at
\r
7 http://www.apache.org/licenses/LICENSE-2.0
\r
9 Unless required by applicable law or agreed to in writing, software
\r
10 distributed under the License is distributed on an "AS IS" BASIS,
\r
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 See the License for the specific language governing permissions and
\r
13 limitations under the License.
\r
14 ------------------------------------------- */
\r
16 #ifndef __PRINT_PLAN_H
\r
17 #define __PRINT_PLAN_H
\r
24 using namespace std;
\r
27 int print_qp_node(FILE* fd, int i, stream_query* query, map<string, int>& lfta_names, map<string, int>& fta_names) {
\r
31 qp_node* node = query->query_plan[i];
\r
33 string ntype = node->node_type();
\r
35 fprintf(fd, "\tNODE %s, type %s\n", node->node_name.c_str(), ntype.c_str());
\r
37 if (!node->predecessors.empty()) {
\r
38 for (j = 0; j < node->predecessors.size(); ++j)
\r
39 fprintf(fd, "\t\tCHILD_NODE %s\n", query->query_plan[query->query_plan[i]->predecessors[j]]->node_name.c_str());
\r
44 // print input tables
\r
45 vector<tablevar_t *> input_tables = node->get_input_tbls();
\r
47 for (j = 0; j < input_tables.size(); ++j) {
\r
48 tablevar_t * table = input_tables[j];
\r
50 if (lfta_names.count(table->schema_name))
\r
51 fprintf(fd, "\t\tSOURCE_LFTA %s\n", table->schema_name.c_str());
\r
52 else if (fta_names.count(table->schema_name))
\r
53 fprintf(fd, "\t\tSOURCE_HFTA %s\n", table->schema_name.c_str());
\r
64 int print_query(FILE* fd, stream_query* query, map<string, int>& lfta_names) {
\r
66 fprintf(fd, "HFTA %s\n", query->query_name.c_str());
\r
69 vector<tablevar_t *> tmp_tv = query->get_input_tables();
\r
71 map<string, int> fta_names;
\r
73 for(itv=0;itv<tmp_tv.size();++itv) {
\r
74 fta_names[tmp_tv[itv]->get_schema_name()] = 0;
\r
77 for (int i = 0; i < query->query_plan.size(); ++i) {
\r
78 if (query->query_plan[i])
\r
79 print_qp_node(fd, i, query, lfta_names, fta_names);
\r
86 int print_hftas(const char* fname, vector<stream_query *>& hfta_list, map<string, int>& lfta_names, vector<string>& query_names, vector<string>& interface_names) {
\r
88 FILE* f = fopen(fname, "w");
\r
89 for (int i = 0; i < hfta_list.size(); ++i) {
\r
90 print_query(f, hfta_list[i], lfta_names);
\r
94 for (int mi = 0; mi < query_names.size(); ++mi) {
\r
95 fprintf(f,"LFTA %s\n",query_names[mi].c_str());
\r
96 fprintf(f,"\tINTERFACE %s\n",interface_names[mi].c_str());
\r
107 #endif // __PRINT_PLAN_H
\r