1 /* ------------------------------------------------
2 Copyright 2014 AT&T Intellectual Property
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ------------------------------------------- */
16 #include"type_objects.h"
22 void data_type::assign_schema_type(){
29 schema_type = "USHORT";
38 schema_type = "ULLONG";
41 schema_type = "LLONG";
44 schema_type = "FLOAT";
47 schema_type = "V_STR";
50 schema_type = "TIMEVAL";
59 sprintf(tmps,"FSTRING%d",size);
63 schema_type = "UNDEFINED_TYPE";
69 data_type::data_type(string st){
73 assign_type_from_string(st);
77 // Assign data type of a colref using information about
78 // modifiers as well as data type. This should be made robust.
79 data_type::data_type(string st, param_list *modifiers){
83 assign_type_from_string(st);
85 if(modifiers != NULL){
87 for(i=0;i<modifiers->size();i++){
88 if( modifiers->contains_key("increasing") ||
89 modifiers->contains_key("Increasing") ||
90 modifiers->contains_key("INCREASING")){
91 temporal = increasing_t;
93 if( modifiers->contains_key("decreasing") ||
94 modifiers->contains_key("Decreasing") ||
95 modifiers->contains_key("DECREASING")){
96 temporal = decreasing_t;
98 if(modifiers->contains_key("subtype")){
99 subtype = modifiers->val_of("subtype");
106 void data_type::assign_type_from_string(string st){
107 if(st == "bool" || st == "Bool" || st == "BOOL"){
109 assign_schema_type();
112 if(st == "ushort" || st == "Ushort" || st == "USHORT"){
114 assign_schema_type();
117 if(st == "uint" || st == "Uint" || st == "UINT"){
119 assign_schema_type();
122 if(st == "int" || st == "Int" || st == "INT"){
124 assign_schema_type();
127 if(st == "ullong" || st == "Ullong" || st == "ULLONG"){
129 assign_schema_type();
132 if(st == "llong" || st == "llong" || st == "LLONG"){
134 assign_schema_type();
137 if(st == "float" || st == "Float" || st == "FLOAT"){
139 assign_schema_type();
142 if(st == "string" || st == "String" || st == "STRING" ||
143 st == "v_str" || st == "V_str" || st == "V_STR"){
145 assign_schema_type();
148 if(st == "timeval" || st == "Timeval" || st == "TIMEVAL"){
150 assign_schema_type();
155 assign_schema_type();
158 if(st == "IPV6" || st == "IPv6"){
160 assign_schema_type();
163 if(sscanf(st.c_str(),"fstring%d",&size)>0){
165 assign_schema_type();
168 if(sscanf(st.c_str(),"Fstring%d",&size)>0){
170 assign_schema_type();
173 if(sscanf(st.c_str(),"FSTRING%d",&size)>0){
175 assign_schema_type();
180 assign_schema_type();
184 data_type::data_type(data_type *lhs, string &op){
186 // type = undefined_t;
187 // temporal_type l_tempo = lhs->get_temporal();;
188 // if(l_tempo == constant_t) temporal = constant_t;
189 // else temporal = varying_t;
191 temporal = compute_temporal_type(lhs->get_temporal(),op);
194 switch(lhs->get_type()){
201 // if(l_tempo == increasing_t) temporal = decreasing_t;
202 // if(l_tempo == decreasing_t) temporal = increasing_t;
207 // if(l_tempo == increasing_t) temporal = decreasing_t;
208 // if(l_tempo == decreasing_t) temporal = increasing_t;
212 // if(l_tempo == increasing_t) temporal = decreasing_t;
213 // if(l_tempo == decreasing_t) temporal = increasing_t;
221 switch(lhs->get_type()){
229 type = lhs->get_type();
237 switch(lhs->get_type()){
244 type = lhs->get_type();
251 subtype = lhs->subtype;
252 assign_schema_type();
255 temporal_type data_type::compute_temporal_type(temporal_type l_tempo, string &op){
258 if(l_tempo == constant_t) ret = constant_t;
259 else ret = varying_t;
262 if(l_tempo == increasing_t) ret = decreasing_t;
263 else if(l_tempo == decreasing_t) ret = increasing_t;
269 data_type::data_type(data_type *lhs, data_type *rhs, const string &op){
273 dtype l_type = lhs->get_type();
274 dtype r_type = rhs->get_type();
276 // First, deduce the type of the result.
277 if( (op=="-")||(op=="+")||(op=="/")||(op=="*")||(op=="%")||(op==">>")||(op=="<<") ){
278 switch(lhs->get_type()){
280 switch(rhs->get_type()){
284 type = rhs->get_type();
288 if(op != ">>" && op != "<<")
289 type = rhs->get_type();
292 if(op != "%" && op != ">>" && op != "<<")
296 if(op == "+") type = timeval_t;
303 switch(rhs->get_type()){
311 if(op != ">>" && op != "<<")
312 type = rhs->get_type();
315 if(op != "%" && op != ">>" && op != "<<")
319 if(op == "+") type = timeval_t;
326 switch(rhs->get_type()){
332 type = rhs->get_type();
336 if(op != ">>" && op != "<<")
337 type = rhs->get_type();
340 if(op != "%" && op != ">>" && op != "<<")
344 if(op == "+") type = timeval_t;
351 switch(rhs->get_type()){
358 if(op != ">>" && op != "<<")
362 if(op != ">>" && op != "<<")
366 if(op != "%" && op != ">>" && op != "<<")
374 switch(rhs->get_type()){
382 if(op != ">>" && op != "<<")
386 if(op != "%" && op != ">>" && op != "<<")
394 if(op != "%" && op != ">>" && op != "<<"){
395 switch(rhs->get_type()){
411 switch(rhs->get_type()){
415 if(op == "+" || op == "-" || op == "/"){
433 if( (op == "|") || (op == "&") ){
434 switch(lhs->get_type()){
436 switch(rhs->get_type()){
442 type = rhs->get_type();
452 switch(rhs->get_type()){
460 type = rhs->get_type();
473 switch(rhs->get_type()){
484 type = rhs->get_type();
494 switch(rhs->get_type()){
502 type = rhs->get_type();
512 switch(rhs->get_type()){
528 switch(rhs->get_type()){
542 switch(rhs->get_type()){
553 if(rhs->get_type() == ipv6_t)
560 assign_schema_type();
561 temporal = compute_temporal_type(lhs->get_temporal(),rhs->get_temporal(),lhs->get_type(), rhs->get_type(), op);
562 if(lhs->subtype == rhs->subtype){
563 subtype = lhs->subtype;
570 temporal_type data_type::compute_temporal_type(temporal_type l_tempo, temporal_type r_tempo, dtype l_type, dtype r_type, const string &op){
573 // Next, deduce the temporalness of the result.
574 // One complication : if the value of the RHS or LHS is
575 // negative, we can't deduce anything about the temporality
578 // temporal_type l_tempo = lhs->get_temporal();
579 // temporal_type r_tempo = rhs->get_temporal();
580 // dtype l_type = lhs->get_type();
581 // dtype r_type = rhs->get_type();
584 if(l_tempo == constant_t) ret = r_tempo;
585 if(r_tempo == constant_t) ret = l_tempo;
586 if(l_tempo == r_tempo) ret = r_tempo;
589 if(l_tempo == constant_t && r_tempo == constant_t) ret = constant_t;
590 if((l_tempo == constant_t || l_tempo ==decreasing_t) &&
591 r_tempo == increasing_t &&
592 (r_type != int_t && r_type != floating_t) ) ret = decreasing_t;
593 if((l_tempo == constant_t || l_tempo ==increasing_t) &&
594 r_tempo == decreasing_t &&
595 (r_type != int_t && r_type != floating_t) ) ret = increasing_t;
598 // If the value might be negative, can't deduce anything
599 // However Java doesn't have unsigned types so the logic which forbids int has to be relaxed.
601 // if((l_type!=int_t && l_type!=floating_t && l_type!=llong_t) && (r_type!=int_t && r_type!=floating_t && r_type!=llong_t)){
602 if(!((l_type==int_t || l_type==floating_t || l_type==llong_t) && (r_type==int_t || r_type==floating_t || r_type==llong_t))){
603 if(l_tempo == constant_t) ret = r_tempo;
604 if(r_tempo == constant_t) ret = l_tempo;
605 if(l_tempo == r_tempo) ret = r_tempo;
609 // if((l_type!=int_t && l_type!=floating_t && l_type!=llong_t) && (r_type!=int_t && r_type!=floating_t && r_type!=llong_t)){
610 if(!((l_type==int_t || l_type==floating_t || l_type==llong_t) && (r_type==int_t || r_type==floating_t || r_type==llong_t))){
611 if((l_tempo == constant_t || l_tempo ==decreasing_t) &&
612 (r_tempo == increasing_t)) ret = decreasing_t;
613 if((l_tempo == constant_t || l_tempo ==increasing_t) &&
614 (r_tempo == decreasing_t )) ret = increasing_t;
615 if(r_tempo == constant_t) ret = l_tempo;
624 data_type *data_type::duplicate(){
625 data_type *ret = new data_type();
626 ret->schema_type = schema_type;
629 ret->temporal = temporal;
630 ret->subtype = subtype;
635 field_entry *data_type::make_field_entry(string n){
636 field_entry *fe = new field_entry(n, schema_type);
637 if(temporal == increasing_t)
638 fe->add_modifier("INCREASING");
639 if(temporal == decreasing_t)
640 fe->add_modifier("DECREASING");
641 if(subtype != "") fe->add_modifier("subtype",subtype.c_str());
645 bool data_type::fta_legal_operation(
646 data_type *lhs, data_type *rhs, string &op){
648 dtype l_type = lhs->get_type();
649 dtype r_type = rhs->get_type();
652 // Currently, anything goes. Should be controlled by
657 // Only +, -, *, /, |, & are legal in the fta.
658 // The only ops on a llong or ullong are +, -
659 // no ops on float, timeval permitted, but these
660 // are illegal data types in the FTA and are handled elsewhere.
662 if(!( (op == "-") || (op == "+") || (op == "/") || (op == "*") || (op == "|") || (op == "&")))
665 if( (l_type == llong_t) || (l_type == u_llong_t) || (r_type == llong_t) || (r_type == u_llong_t)){
666 if(op == "*" || op == "/")
675 bool data_type::fta_legal_operation(data_type *lhs, string &op){
678 // negation and not are as legal at the fta on all fta-legal types
679 // as at the user level.
683 bool data_type::fta_legal_type(){
685 // Currently, anything goes.
686 // Should control by a config file.
687 // Currently, only the float and the timeval are not legal at the fta.
688 // if(type == floating_t || type == timeval_t) return(false);
694 // The data type of a literal
696 data_type::data_type(int it){
697 temporal = constant_t;
703 case LITERAL_LONGINT:
715 case LITERAL_TIMEVAL:
729 assign_schema_type();
732 void data_type::set_aggr_data_type(const string &op, data_type *dt){
733 dtype se_type = dt->type;
735 temporal = varying_t;
738 if((se_type == u_int_t)||(se_type == u_short_t)||(se_type == int_t)||
739 (se_type == u_llong_t)||(se_type == llong_t)||(se_type == floating_t))
745 if((se_type == u_int_t) || (se_type == u_short_t) || (se_type == bool_t))
747 if((se_type == int_t) || (se_type == u_llong_t) ||
748 (se_type == llong_t) || (se_type == floating_t) )
750 // temporal = dt->temporal; // temporal not preserved by sum.
751 subtype = dt->subtype;
753 if(op == "MIN" || op == "MAX"){
755 // temporal = dt->temporal; // temporal not preserved by min or max.
756 subtype = dt->subtype;
758 if(op == "AND_AGGR" || op == "OR_AGGR" || op == "XOR_AGGR"){
759 if( (se_type == u_int_t) || (se_type == u_short_t) ||
760 (se_type == int_t) || (se_type == llong_t) ||
761 (se_type == u_llong_t) || (se_type == bool_t) )
763 subtype = dt->subtype;
765 assign_schema_type();
771 bool data_type::is_comparable(data_type *rhs, string op){
817 if(rhs->type == ipv6_t)
829 // type string to get val from pass-by-ref fcn.
830 // (Does not seem to be used ?)
831 string data_type::get_CC_accessor_type(){
834 return("gs_int32_t *");
839 return("gs_uint32_t *");
841 return("gs_uint64_t *");
843 return("gs_int64_t *");
845 return("gs_float_t *");
847 return("struct gs_string *");
849 return("gs_int8_t *");
851 return("struct timeval *");
853 return("struct ipv6_str *");
855 return("ERROR: Unknown type in data_type::get_CC_accessor_type\n");
859 // type of a variable holding this value.
860 string data_type::get_cvar_type(){
864 return("gs_int32_t ");
869 return("gs_uint32_t ");
871 return("gs_uint64_t ");
873 return("gs_int64_t ");
875 return("gs_float_t ");
877 return("struct gs_string");
879 return("struct ipv6_str");
881 sprintf(tmps,"gs_int8_t[%d] ",size);
884 return("struct timeval ");
886 return("ERROR: Unknown type in data_type::get_cvar_type\n");
890 // type of a variable holding this value.
891 string data_type::get_tuple_cvar_type(){
895 return("gs_int32_t ");
900 return("gs_uint32_t ");
902 return("gs_uint64_t ");
904 return("gs_int64_t ");
906 return("gs_float_t ");
908 return("struct string32");
910 return("struct ipv6_str");
912 sprintf(tmps,"gs_int8_t[%d] ",size);
915 return("struct timeval ");
917 return("ERROR: Unknown type in data_type::get_cvar_type\n");
923 // type of an in-memory variable holding this value.
924 // TODO: use get_cvar_type as a subroutine
925 string data_type::make_cvar(std::string v){
929 return("gs_int32_t "+v);
934 return("gs_uint32_t "+v);
936 return("gs_uint64_t "+v);
938 return("gs_int64_t "+v);
940 return("gs_float_t "+v);
942 return("struct gs_string "+v);
944 return("struct ipv6_str "+v);
946 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
949 return("struct timeval "+v);
951 return("ERROR: Unknown type in data_type::make_cvar\n");
955 // type of a tuple variable holding this value.
956 // TODO: use get_tuple_cvar_type as a subroutine
957 string data_type::make_tuple_cvar(std::string v){
961 return("gs_int32_t "+v);
966 return("gs_uint32_t "+v);
968 return("gs_uint64_t "+v);
970 return("gs_int64_t "+v);
972 return("gs_float_t "+v);
974 return("struct string32 "+v);
976 return("struct ipv6_str "+v);
978 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
981 return("struct timeval "+v);
983 return("ERROR: Unknown type in data_type::make_cvar\n");
988 // type of a variable holding this value.
989 // The type at the host might be different (esp. string vs. vstring)
990 string data_type::get_host_cvar_type(){
994 return("gs_int32_t ");
999 return("gs_uint32_t ");
1001 return("gs_uint64_t ");
1003 return("gs_int64_t ");
1005 return("gs_float_t ");
1007 return("struct vstring");
1009 return("struct hfta_ipv6_str");
1011 sprintf(tmps,"gs_int8_t[%d] ",size);
1014 return("struct timeval ");
1016 return("ERROR: Unknown type in data_type::get_host_cvar_type\n");
1021 // type of a variable holding this value.
1022 // The type at the host might be different (esp. string vs. vstring)
1023 string data_type::make_host_cvar(std::string v){
1027 return("gs_int32_t "+v);
1032 return("gs_uint32_t "+v);
1034 return("gs_uint64_t "+v);
1036 return("gs_int64_t "+v);
1038 return("gs_float_t "+v);
1040 return("struct vstring "+v);
1042 return("struct hfta_ipv6_str "+v);
1044 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
1047 return("struct timeval "+v);
1049 return("ERROR: Unknown type in data_type::make_host_cvar\n");
1053 string data_type::make_host_tuple_cvar(std::string v){
1057 return("gs_int32_t "+v);
1062 return("gs_uint32_t "+v);
1064 return("gs_uint64_t "+v);
1066 return("gs_int64_t "+v);
1068 return("gs_float_t "+v);
1070 return("struct vstring32 "+v);
1072 return("struct hfta_ipv6_str "+v);
1074 sprintf(tmps,"gs_int8_t %s[%d] ",v.c_str(),size);
1077 return("struct timeval "+v);
1079 return("ERROR: Unknown type in data_type::make_host_cvar\n");
1085 string data_type::get_hfta_unpack_fcn(){
1088 return("fta_unpack_int");
1091 return("fta_unpack_uint");
1093 return("fta_unpack_ushort");
1095 return("fta_unpack_bool");
1097 return("fta_unpack_ullong");
1099 return("fta_unpack_llong");
1101 return("fta_unpack_float");
1103 return("fta_unpack_vstr");
1105 return("fta_unpack_fstring");
1107 return("fta_unpack_timeval");
1109 return("fta_unpack_ipv6");
1111 return("ERROR: Unknown type in dtype::get_hfta_unpack_fcn\n");
1115 string data_type::get_hfta_unpack_fcn_noxf(){
1118 return("fta_unpack_int_noxf");
1121 return("fta_unpack_uint_noxf");
1123 return("fta_unpack_ushort_noxf");
1125 return("fta_unpack_bool_noxf");
1127 return("fta_unpack_ullong_noxf");
1129 return("fta_unpack_llong_noxf");
1131 return("fta_unpack_float_noxf");
1133 return("fta_unpack_vstr_noxf");
1135 return("fta_unpack_fstring_noxf");
1137 return("fta_unpack_timeval_noxf");
1139 return("fta_unpack_ipv6_noxf");
1141 return("ERROR: Unknown type in dtype::get_hfta_unpack_fcn_noxf\n");
1146 // Return true if comparing these types requires
1147 // a special function.
1149 // 1) the function should act like strcmp (-1, 0, 1)
1150 // 2) this fcn assumes that type checking
1151 // has already been done.
1152 bool data_type::complex_comparison(data_type *dt){
1164 string data_type::get_comparison_fcn(data_type *dt){
1167 return("Compare_Timeval");
1169 return("str_compare");
1171 return("ipv6_compare");
1173 return("ERROR_NO_SUCH_COMPARISON_FCN");
1176 string data_type::get_equals_fcn(data_type *dt){
1179 return("Compare_Timeval");
1181 return("str_equal");
1183 return("ipv6_compare");
1185 return("ERROR_NO_SUCH_COMPARISON_FCN");
1189 string data_type::get_hfta_comparison_fcn(data_type *dt){
1192 return("hfta_Compare_Timeval");
1194 return("hfta_vstr_compare");
1196 return("hfta_ipv6_compare");
1198 return("ERROR_NO_SUCH_COMPARISON_FCN");
1201 string data_type::get_hfta_equals_fcn(data_type *dt){
1204 return("hfta_Compare_Timeval");
1206 return("hfta_vstr_equal");
1208 return("hfta_ipv6_compare");
1210 return("ERROR_NO_SUCH_COMPARISON_FCN");
1214 // Return true if operating on these types requires
1215 // a special function for this operator.
1217 // 1) the function should act like
1218 // int operator_fcn(*retun_val, *lhs, *rhs)
1219 // 2) this fcn assumes that type checking
1220 // has already been done.
1221 bool data_type::complex_operator(data_type *dt, string &op){
1238 if(op == "+" || op == "-" || op == "/")
1249 if((op=="&" || op=="|") && dt->type == ipv6_t)
1259 bool data_type::complex_operator(string &op){
1263 string data_type::get_complex_operator(data_type *dt, string &op){
1269 return("Add_Int_Timeval");
1281 return("Add_Timeval_Int");
1283 return("Subtract_Timeval_Int");
1285 return("Divide_Timeval_Int");
1289 return("Subtract_Timeval_Timeval");
1296 if(dt->type == ipv6_t){
1307 return("ERROR_NO_COMPLEX_BINARY_OPERATOR");
1310 string data_type::get_complex_operator(string &op){
1312 return("ERROR_NO_COMPLEX_UNARY_OPERATOR");
1316 bool data_type::use_hashfunc(){
1332 fprintf(stderr,"ERROR: Unknown type in data_type::use_hashfunc\n");
1337 string data_type::get_hfta_hashfunc(){
1344 return("ERROR NO HFTA HASHFUNC");
1347 //return("hfta_ullong_hashfunc");
1348 return("hfta_ULLONG_to_hash");
1350 //return("hfta_ullong_hashfunc");
1351 return("hfta_LLONG_to_hash");
1353 //return("hfta_float_hashfunc");
1354 return("hfta_FLOAT_to_hash");
1357 return("hfta_IPV6_to_hash");
1359 return("hfta_timeval_hashfunc");
1361 return("hfta_vstr_hashfunc");
1363 fprintf(stderr,"ERROR: Unknown type in data_type::get_hfta_hashfunc\n");
1365 return("false"); // to make compiler happy
1369 // Return true if the data type contains a ptr to a
1370 // memory buffer. (copying sometimes requires special cate).
1372 bool data_type::is_buffer_type(){
1389 fprintf(stderr,"ERROR: Unknown type in dtype::is_buffer_type\n");
1395 // Fcns which return the names of functions for
1396 // handling complex types.
1398 //-----------------------------
1401 string data_type::get_buffer_assign_copy(){
1404 return("str_assign_with_copy");
1409 return("ERROR_NO_SUCH_buffer_assign_copy_FCN");
1412 string data_type::get_buffer_tuple_copy(){
1415 return("str_assign_with_copy_in_tuple");
1420 return("ERROR_NO_SUCH_buffer_tuple_copy_FCN");
1423 string data_type::get_buffer_replace(){
1426 return("str_replace");
1431 return("ERROR_NO_SUCH_buffer_replace_FCN");
1434 string data_type::get_buffer_size(){
1437 return("str_length");
1442 return("ERROR_NO_SUCH_buffer_size_FCN");
1445 string data_type::get_buffer_destroy(){
1448 return("str_destroy");
1453 return("ERROR_NO_SUCH_buffer_destroy_FCN");
1456 //-----------------------------
1459 string data_type::get_hfta_buffer_assign_copy(){
1462 return("hfta_vstr_assign_with_copy");
1467 return("ERROR_NO_SUCH_buffer_assign_copy_FCN");
1470 string data_type::get_hfta_buffer_tuple_copy(){
1473 return("hfta_vstr_assign_with_copy_in_tuple");
1478 return("ERROR_NO_SUCH_buffer_tuple_copy_FCN");
1481 string data_type::get_hfta_buffer_replace(){
1484 return("hfta_vstr_replace");
1489 return("ERROR_NO_SUCH_buffer_replace_FCN");
1492 string data_type::get_hfta_buffer_size(){
1495 return("hfta_vstr_length");
1500 return("ERROR_NO_SUCH_buffer_size_FCN");
1503 string data_type::get_hfta_buffer_destroy(){
1506 return("hfta_vstr_destroy");
1511 return("ERROR_NO_SUCH_buffer_destroy_FCN");
1513 //-----------------------------
1516 // Return true if the data type is represented by a strucutre.
1517 bool data_type::is_structured_type(){
1534 fprintf(stderr,"ERROR: Unknown type in dtype::is_structured_type\n");
1541 // type of a variable holding this value.
1542 // Seems to be a relic
1544 string data_type::get_interface_type(){
1550 return("unsigned int ");
1552 return("unsigned short int ");
1556 return("unsigned long long int ");
1558 return("long long int ");
1564 sprintf(tmps,"char[%d] ",size);
1571 return("ERROR: Unknown type in dtype::get_interface_type\n");
1577 // This type of handle registration is obsolete
1579 string data_type::handle_registration_name(){
1583 return("str_register_search_string");
1587 return("ERROR UNKNOWN LITERAL");
1590 string data_type::hfta_handle_registration_name(){
1594 return("vstr_register_search_string");
1598 return("ERROR UNKNOWN LITERAL");
1602 string data_type::get_handle_destructor(){
1606 return("str_release_search_string");
1610 return("ERROR UNKNOWN LITERAL");
1614 // should be the inverse of
1615 // data_type::data_type(string st, param_list *modifiers)
1616 vector<string> data_type::get_param_keys(){
1617 vector<string> retval;
1619 if(temporal == increasing_t)
1620 retval.push_back("INCREASING");
1621 if(temporal == decreasing_t)
1622 retval.push_back("DECREASING");
1623 if(subtype != "") retval.push_back("subtype");
1628 string data_type::get_param_val(string k){
1629 if(k=="subtype") return subtype;
1633 std::string data_type::get_temporal_string(){
1634 if(temporal == increasing_t)
1635 return("INCREASING");
1636 if(temporal == decreasing_t)
1637 return("DECREASING");
1642 bool data_type::needs_hn_translation(){
1659 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::needs_hn_translation\n");
1665 std::string data_type::hton_translation(){
1666 fprintf(stderr,"INTERNAL ERROR, hton_translation called.\n");
1688 return("hton_ipv6");
1691 return("INTERNAL ERROR, net translation for buffered types needs special handling.\n");
1693 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::hton_translation\n");
1695 return("INTERNAL ERROR: NO SUCH TYPE IN hton_translation");
1699 std::string data_type::ntoh_translation(){
1700 fprintf(stderr,"INTERNAL ERROR, ntoh_translation called.\n");
1722 return("ntoh_ipv6");
1725 return("INTERNAL ERROR, net translation for buffered types needs special handling.\n");
1727 fprintf(stderr,"INTERNAL ERROR: Unknown type in dtype::ntoh_translation\n");
1729 return("INTERNAL ERROR: NO SUCH TYPE IN ntoh_translation");
1733 int data_type::type_indicator(){
1740 return(USHORT_TYPE);
1744 return(ULLONG_TYPE);
1750 return(TIMEVAL_TYPE);
1758 return(FSTRING_TYPE);
1760 return(UNDEFINED_TYPE);
1762 return(UNDEFINED_TYPE);
1767 int data_type::type_size(){
1770 return(sizeof(gs_int32_t));
1775 return(sizeof(gs_uint32_t));
1777 return(sizeof(gs_uint64_t));
1779 return(sizeof(gs_int64_t));
1781 return(sizeof(gs_float_t));
1783 return(sizeof(timeval)); // IMPLEMENTATION DEPENDENT
1785 return(sizeof(hfta_ipv6_str)); // IMPLEMENTATION DEPENDENT
1787 return(sizeof(vstring32)); // IMPLEMENTATION DEPENDENT
1796 // for external functions and predicates
1799 bool data_type::call_compatible(data_type *o){
1800 if(type != o->get_type()) return(false);
1801 if(type == fstring_t){
1802 if(size != 0 && size != o->type_size()) return(false);
1807 // test for equality : used by bind_to_schema and by testing for
1810 bool data_type::equal(data_type *o){
1811 if(type != o->get_type()) return(false);
1812 if(type == fstring_t){
1813 if(size != o->type_size()) return(false);
1819 bool data_type::subsumes_type(data_type *o){
1820 if(type != o->get_type()) return(false);
1821 if(type == fstring_t){
1822 if(size != o->type_size()) return(false);
1824 if(this->is_temporal() && temporal != o->get_temporal()) return false;
1825 if(subtype != "" && subtype != o->subtype) return false;
1830 bool data_type::equals(data_type *o){
1831 if(type != o->get_type()) return(false);
1832 if(type == fstring_t){
1833 if(size != o->type_size()) return(false);
1835 if(temporal != o->get_temporal()) return false;
1836 if(subtype != o->subtype) return false;
1841 bool data_type::equal_subtypes(data_type *o){
1842 if(type != o->get_type()) return(false);
1843 if(type == fstring_t){
1844 if(size != o->type_size()) return(false);
1846 if(subtype != o->subtype) return false;
1852 string data_type::to_string(){
1853 string ret = schema_type;
1854 if(this->is_temporal() || subtype != ""){
1856 if(temporal == increasing_t)
1857 ret += "INCREASING";
1858 if(temporal == decreasing_t)
1859 ret += "DECREASING";
1860 if(this->is_temporal() && subtype != "")
1863 ret += "subtype "+subtype;
1871 string data_type::get_min_literal() {
1883 return("LLONG_MIN");
1889 return("0000:0000:0000:0000:0000:0000:0000:0000");
1892 return("ERROR: Min literal is undefined for strings\n");
1894 return("ERROR: Unknown type in data_type::get_min_literal\n");
1898 string data_type::get_max_literal() {
1908 return("ULLONG_MAX");
1910 return("LLONG_MAX");
1914 return("{UINT_MAX,UINT_MAX}");
1916 return("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
1919 return("ERROR: Max literal is undefined for strings\n");
1921 return("ERROR: Unknown type in data_type::get_max_literal\n");
1926 string data_type::get_wl_extract_fcn() {
1929 return("wl_csv_int");
1931 return("wl_csv_bool");
1934 return("wl_csv_uint");
1936 return("wl_csv_ip");
1938 return("wl_csv_ullong");
1940 return("wl_csv_llong");
1942 return("wl_csv_float");
1944 return("ERROR_TIMEVAL_T_EXTRACTION_NOT_SUPPORTED");
1946 return("wl_csv_ipv6");
1949 return("wl_csv_string");
1951 return("ERROR: Unknown type in data_type::get_wl_extract_fcn\n");