From: vlad shkapenyuk Date: Tue, 22 Sep 2020 12:51:21 +0000 (-0400) Subject: Fix HFTA operators and UDAFs broken by the last update X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F4756%2F1;p=com%2Fgs-lite.git Fix HFTA operators and UDAFs broken by the last update Signed-off-by: vlad shkapenyuk Change-Id: I2685f8d3a6e52dead28b66c66bd2da13933dfaf2 --- diff --git a/bin/buildit b/bin/buildit index c762ffc..60fd877 100755 --- a/bin/buildit +++ b/bin/buildit @@ -23,7 +23,7 @@ then exit -1 fi -$GSLITE_ROOT/bin/translate_fta -h localhost -c -M -R $GSLITE_ROOT -C $GSLITE_ROOT/cfg -l $GSLITE_ROOT/qlib packet_schema.txt *.gsql +$GSLITE_ROOT/bin/translate_fta -f -N -h localhost -c -M -R $GSLITE_ROOT -C $GSLITE_ROOT/cfg -l $GSLITE_ROOT/qlib packet_schema.txt *.gsql ret=$? if [ $ret -ne 0 ] then diff --git a/cfg/external_fcns.def b/cfg/external_fcns.def index 071a290..999211a 100644 --- a/cfg/external_fcns.def +++ b/cfg/external_fcns.def @@ -610,8 +610,8 @@ uint FUN [LFTA_LEGAL, COST EXPENSIVE] uint FUN [COST LOW] extr_med_hfta0_fcn(string); uint EXTR qspace_of quant_udaf_hfta0 extr_quant_hfta0_space (uint); uint FUN [COST LOW] extr_quant_hfta0_space(string); - string UDAF [SUBAGGR quant_udaf_lfta3, SUPERAGGR quant_udaf_hfta3] quant_udaf_hfta0 fstring16 (uint); - string UDAF quant_udaf_hfta3 fstring16 (string); + string UDAF [SUBAGGR quant_udaf_lfta3, SUPERAGGR quant_udaf_hfta3] quant_udaf_hfta0 fstring24 (uint); + string UDAF quant_udaf_hfta3 fstring24 (string); string UDAF quant_udaf_lfta3 fstring6600 (uint); /////////////////////////////////////////////////////////// @@ -676,20 +676,20 @@ uint FUN [LFTA_LEGAL, COST EXPENSIVE] // count the # times the payload is different from the previous value ///////////////////////////////////////////////////////////// - uint UDAF [SUBAGGR count_diff_lfta_ui, SUPERAGGR count_diff_hfta] count_diff fstring12 (uint); - uint UDAF count_diff_hfta fstring12 (string); + uint UDAF [SUBAGGR count_diff_lfta_ui, SUPERAGGR count_diff_hfta] count_diff fstring16 (uint); + uint UDAF count_diff_hfta fstring16 (string); string UDAF count_diff_lfta_ui fstring20 (uint); - uint UDAF [SUBAGGR count_diff_lfta_i, SUPERAGGR count_diff_hfta] count_diff fstring12 (int); + uint UDAF [SUBAGGR count_diff_lfta_i, SUPERAGGR count_diff_hfta] count_diff fstring16 (int); string UDAF count_diff_lfta_i fstring20 (int); - uint UDAF [SUBAGGR count_diff_lfta_ul, SUPERAGGR count_diff_hfta] count_diff fstring12 (ullong); + uint UDAF [SUBAGGR count_diff_lfta_ul, SUPERAGGR count_diff_hfta] count_diff fstring16 (ullong); string UDAF count_diff_lfta_ul fstring20 (ullong); - uint UDAF [SUBAGGR count_diff_lfta_l, SUPERAGGR count_diff_hfta] count_diff fstring12 (llong); + uint UDAF [SUBAGGR count_diff_lfta_l, SUPERAGGR count_diff_hfta] count_diff fstring16 (llong); string UDAF count_diff_lfta_l fstring20 (llong); - uint UDAF [SUBAGGR count_diff_lfta_s, SUPERAGGR count_diff_hfta] count_diff fstring12 (string); + uint UDAF [SUBAGGR count_diff_lfta_s, SUPERAGGR count_diff_hfta] count_diff fstring16 (string); string UDAF count_diff_lfta_s fstring20 (string); diff --git a/include/hfta/groupby_operator.h b/include/hfta/groupby_operator.h index e831bc0..6085907 100644 --- a/include/hfta/groupby_operator.h +++ b/include/hfta/groupby_operator.h @@ -77,21 +77,21 @@ public: flush_old(result); } if(n_patterns <= 1){ - aggregate aggr; + char aggr_buffer[sizeof(aggregate)]; // create an aggregate in preallocated buffer - func.create_aggregate(tup, (char*)&aggr); + func.create_aggregate(tup, aggr_buffer); // neeed operator= doing a deep copy - group_table.insert(grp, aggr); + group_table.insert(grp, (*(aggregate*)aggr_buffer)); }else{ int p; // TODO this code is wrong, must check if each pattern is in the group table. for(p=0;p load_factor) || ((2 * max_load) < load_factor)) { - min_buckets = _max_size / load_factor; + min_buckets = ceil(_max_size / load_factor); } - - if (min_buckets) { + + + if (min_buckets) { // find power-of-2 size large than min_buckets; int nb; for(nb=2;nb load_factor) || ((2 * max_load) < load_factor)) { - min_buckets = _max_size / load_factor; + min_buckets = ceil(_max_size / load_factor); } if (min_buckets) { // find power-of-2 size large than min_buckets; int nb; for(nb=2;nbis_buffer_type()){ + sprintf(tmpstr,"\t\t%s(&gb_var%d);\n", + gdt->get_hfta_buffer_init().c_str(), g ); + ret += tmpstr; + } + } + ret += "\t};\n"; } @@ -9476,7 +9485,10 @@ ret += "// hfta_disorder = "+int_to_string(hfta_disorder)+"\n"; // For temporal status tuple we don't need to do anything else - ret += "\tif (temp_tuple_received) return NULL;\n\n"; + ret += "\tif (temp_tuple_received){\n"; + ret += "\t\tdisordered_arrival = false;\n"; + ret += "\t\treturn NULL;\n\n"; + ret += "\t}\n"; for(w=0;wis_buffer_type()){ + sprintf(tmpstr,"\t\t%s(&gb_var%d);\n", + gdt->get_hfta_buffer_init().c_str(), g ); + ret += tmpstr; + } + } + ret += "\t};\n"; + ret += "\t// shallow copy constructor\n"; ret += "\t"+generate_functor_name() + "_groupdef("+ this->generate_functor_name() + "_groupdef &gd){\n"; diff --git a/src/ftacmp/translate_fta.cc b/src/ftacmp/translate_fta.cc index 19ff634..5784795 100644 --- a/src/ftacmp/translate_fta.cc +++ b/src/ftacmp/translate_fta.cc @@ -134,6 +134,60 @@ void generate_makefile(vector &input_file_names, int nfiles, // Dump schema summary void dump_summary(stream_query *str){ + for(int q=0;qquery_plan.size();++q){ + qp_node *qp = str->query_plan[q]; + if(qp==NULL) + continue; // there can be blanks + + fprintf(schema_summary_output,"-----\n"); + fprintf(schema_summary_output,"%s\n",qp->node_name.c_str()); + + table_def *sch = qp->get_fields(); + + vector flds = sch->get_fields(); + int f; + for(f=0;f0) fprintf(schema_summary_output,"|"); + fprintf(schema_summary_output,"%s",flds[f]->get_name().c_str()); + } + fprintf(schema_summary_output,"\n"); + for(f=0;f0) fprintf(schema_summary_output,"|"); + fprintf(schema_summary_output,"%s",flds[f]->get_type().c_str()); + } + fprintf(schema_summary_output,"\n"); + + map defines = qp->get_definitions(); + string comment = ""; + if(defines.count("comment")>0){ + comment = defines["comment"]; + } + fprintf(schema_summary_output,"%s\n",comment.c_str()); + + vector input_tables = qp->get_input_tbls(); + for(int t=0; t0) fprintf(schema_summary_output,"|"); + string machine = input_tables[t]->get_machine(); + string iface = input_tables[t]->get_interface(); + string schema = input_tables[t]->get_schema_name(); + if(machine!=""){ + fprintf(schema_summary_output,"%s.",machine.c_str()); + } + if(iface!=""){ + fprintf(schema_summary_output,"%s.",iface.c_str()); + }else{ + if(machine!="") fprintf(schema_summary_output,"."); + } + fprintf(schema_summary_output,"%s",schema.c_str()); + } + + fprintf(schema_summary_output,"\n"); + } + + + +/* + fprintf(schema_summary_output,"-----\n"); fprintf(schema_summary_output,"%s\n",str->query_name.c_str()); table_def *sch = str->get_output_tabledef(); @@ -150,6 +204,32 @@ void dump_summary(stream_query *str){ fprintf(schema_summary_output,"%s",flds[f]->get_type().c_str()); } fprintf(schema_summary_output,"\n"); + + string comment = ""; + if(str->defines.count("comment")>0){ + comment = str->defines["comment"]; + } + fprintf(schema_summary_output,"%s\n",comment.c_str()); + + vector input_tables = str->get_input_tables(); + for(int t=0; t0) fprintf(schema_summary_output,"|"); + string machine = input_tables[t]->get_machine(); + string iface = input_tables[t]->get_interface(); + string schema = input_tables[t]->get_schema_name(); + if(machine!=""){ + fprintf(schema_summary_output,"%s.",machine.c_str()); + } + if(iface!=""){ + fprintf(schema_summary_output,"%s.",iface.c_str()); + }else{ + if(machine!="") fprintf(schema_summary_output,"."); + } + fprintf(schema_summary_output,"%s",schema.c_str()); + } + fprintf(schema_summary_output,"\n"); +*/ + } // Globals @@ -1234,8 +1314,8 @@ fprintf(stderr,"Parsing file %s\n",qpathname.c_str()); map hfta_name_map; // vector< vector > process_sets; // vector< set > stream_node_sets; - reverse(process_order.begin(), process_order.end()); // get listing in reverse order. - // i.e. process leaves 1st. + reverse(process_order.begin(), process_order.end()); // get listing in reverse . + // order: process leaves 1st. for(i=0;iis_externally_visible == true){ //printf("Visible.\n"); @@ -2159,13 +2239,13 @@ else{ } */ -/* -// output schema summary - if(output_schema_summary){ - dump_summary(split_queries[0]); - } -*/ } +// output schema summary + if(output_schema_summary){ + for(int o=0;olength = 0; } +// Make the vstring safe to destroy even if its never initialized +// (e.g. stack-allocated groups containing strings) +void hfta_vstr_init(vstring * str) { + str->length = 0; +} gs_retval_t hfta_vstr_length(vstring *str) { return str->length;