fix int_to_string_map bug; allow blank lines and comments in output_spec.cfg
[com/gs-lite.git] / src / ftacmp / translate_fta.cc
index b6855ff..4ee0bb4 100644 (file)
@@ -55,6 +55,8 @@ Copyright 2014 AT&T Intellectual Property
 #include"xml_t.h"
 #include"field_list.h"
 
+#include "gsconfig.h"
+
 extern int xmlParserparse(void);
 extern FILE *xmlParserin;
 extern int xmlParserdebug;
@@ -395,24 +397,26 @@ int main(int argc, char **argv){
                while(fgets(tmpstr,TMPSTRLEN,osp_in)){
                        o_lineno++;
                        int nflds = split_string(tmpstr,',',flds,MAXFLDS);
-                       if(nflds == 7){
+                       if(tmpstr[0]!='\n' && tmpstr[0]!='\r' && tmpstr[0]!='\0' && tmpstr[0]!='#'){
+                               if(nflds == 7){
 //             make operator type lowercase
-                               char *tmpc;
-                               for(tmpc=flds[1];*tmpc!='\0';++tmpc)
-                                       *tmpc = tolower(*tmpc);
-
-                               ospec_str *tmp_ospec = new ospec_str();
-                               tmp_ospec->query = flds[0];
-                               tmp_ospec->operator_type = flds[1];
-                               tmp_ospec->operator_param = flds[2];
-                               tmp_ospec->output_directory = flds[3];
-                               tmp_ospec->bucketwidth = atoi(flds[4]);
-                               tmp_ospec->partitioning_flds = flds[5];
-                               tmp_ospec->n_partitions = atoi(flds[6]);
-                               qname_to_ospec.insert(pair<string,int>(tmp_ospec->query,output_specs.size()));
-                               output_specs.push_back(tmp_ospec);
-                       }else{
-                               fprintf(stderr,"Warning, line %d corrupted in output_spec.cfg, has %d fields.\n",o_lineno,nflds);
+                                       char *tmpc;
+                                       for(tmpc=flds[1];*tmpc!='\0';++tmpc)
+                                               *tmpc = tolower(*tmpc);
+       
+                                       ospec_str *tmp_ospec = new ospec_str();
+                                       tmp_ospec->query = flds[0];
+                                       tmp_ospec->operator_type = flds[1];
+                                       tmp_ospec->operator_param = flds[2];
+                                       tmp_ospec->output_directory = flds[3];
+                                       tmp_ospec->bucketwidth = atoi(flds[4]);
+                                       tmp_ospec->partitioning_flds = flds[5];
+                                       tmp_ospec->n_partitions = atoi(flds[6]);
+                                       qname_to_ospec.insert(pair<string,int>(tmp_ospec->query,output_specs.size()));
+                                       output_specs.push_back(tmp_ospec);
+                               }else{
+                                       fprintf(stderr,"Warning, line %d corrupted in output_spec.cfg, has %d fields.\n",o_lineno,nflds);
+                               }
                        }
                }
                fclose(osp_in);
@@ -1351,6 +1355,7 @@ fprintf(stderr,"Parsing file %s\n",qpathname.c_str());
        }
        if(dangling_ospecs!=""){
                fprintf(stderr,"WARNING, the following entries in output_spec.cfg don't have a matching query: %s\n",dangling_ospecs.c_str());
+               exit(1);
        }
 
        string dangling_par = "";
@@ -1907,7 +1912,11 @@ for(q=0;q<hfta_sets.size();++q){
                string lmach = hostname;
                if(tvec.size()>0){
                        liface = tvec[0]->get_interface();      // iface queries have been resolved
-                       lmach = tvec[0]->get_machine();
+                       if(tvec[0]->get_machine() != ""){
+                               lmach = tvec[0]->get_machine();
+                       }else{
+                               fprintf(stderr,"WARNING, lfta %s has empty machine name, using %s\n",  split_queries[l]->query_plan[0]->node_name.c_str(), hostname.c_str());
+                       }
                } // else{
                        interface_names.push_back(liface);
                        machine_names.push_back(lmach);
@@ -2311,7 +2320,6 @@ for(i=0;i<hfta_list.size();++i){          // query also has an HFTA component
 //                     if(hfta_namespace == "")
 //                             warning_str += "\tnamespace not found.\n";
 
-// STOPPED HERE
 //     There is a get_tbl_keys method implemented for qp_nodes,
 //     integrate it into steam_query, then call it to find keys,
 //     and annotate feidls with their key-ness.
@@ -3078,19 +3086,34 @@ void generate_makefile(vector<string> &input_file_names, int nfiles,
                vector<string> ift = ifdb->get_iface_vals(ifmachines[ifnm],ifnm, "InterfaceType", erri, err_str);
                for(int ift_i=0;ift_i<ift.size();ift_i++){
                        if(ift[ift_i]=="PROTO"){
+#ifdef PROTO_ENABLED                           
                                use_proto = true;
+#else
+                               fprintf(stderr,"Runtime libraries built without PROTO support. Rebuild with PROTO_ENABLED defined in gsoptions.h\n");
+                               exit(0);
+#endif
                        }
                }
                ift = ifdb->get_iface_vals(ifmachines[ifnm],ifnm, "BSA", erri, err_str);
                for(int ift_i=0;ift_i<ift.size();ift_i++){
                        if(ift[ift_i] == "TRUE" || ift[ift_i] == "True" || ift[ift_i] == "true"){       
+#ifdef BSA_ENABLED                             
                                use_bsa = true;
+#else
+                               fprintf(stderr,"Runtime libraries built without BSA support. Rebuild with BSA_ENABLED defined in gsoptions.h\n");
+                               exit(0);
+#endif                                 
                        }
                }
                ift = ifdb->get_iface_vals(ifmachines[ifnm],ifnm, "KAFKA", erri, err_str);
                for(int ift_i=0;ift_i<ift.size();ift_i++){
                        if(ift[ift_i] == "TRUE" || ift[ift_i] == "True" || ift[ift_i] == "true"){       
+#ifdef KAFKA_ENABLED                           
                                use_kafka = true;
+#else
+                               fprintf(stderr,"Runtime libraries built without KAFKA support. Rebuild with KAFKA_ENABLED defined in gsoptions.h\n");
+                               exit(0);
+#endif 
                        }
                }
        }
@@ -3120,12 +3143,16 @@ void generate_makefile(vector<string> &input_file_names, int nfiles,
                fprintf(outfl," -last ");
        if(use_pads)
                fprintf(outfl, " -ldll -ldl ");
-       if(use_proto)
-               fprintf(outfl, " -L/usr/local/lib/ -lprotobuf-c ");
-       if(use_bsa)
-               fprintf(outfl, " -lbsa_stream ");
-       if(use_kafka)
-               fprintf(outfl, " -lrdkafka ");
+
+#ifdef PROTO_ENABLED   
+       fprintf(outfl, " -L/usr/local/lib/ -lprotobuf-c ");
+#endif
+#ifdef BSA_ENABLED     
+       fprintf(outfl, " -lbsa_stream ");
+#endif
+#ifdef KAFKA_ENABLED   
+       fprintf(outfl, " -lrdkafka ");
+#endif
        fprintf(outfl," -lgscpaux");
 #ifdef GCOV
        fprintf(outfl," -fprofile-arcs");