Added quantiling UDAFs
[com/gs-lite.git] / src / ftacmp / generate_utils.h
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
6 \r
7      http://www.apache.org/licenses/LICENSE-2.0\r
8 \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
15 #ifndef __GENERATE_UTILS_H_DEFINED__\r
16 #define __GENERATE_UTILS_H_DEFINED__\r
17 \r
18 #include <string>\r
19 #include <map>\r
20 \r
21 #include "parse_fta.h"\r
22 #include "analyze_fta.h"\r
23 #include "nic_def.h"\r
24 \r
25 //              This file contains functions used by more than one\r
26 //              code generation system.\r
27 \r
28 \r
29 //              replaces dots in node names with undescores - dots are illegal in C variable names\r
30 std::string normalize_name(std::string name);\r
31 \r
32 \r
33 //      name of tuple struct\r
34 \r
35 std::string generate_tuple_name(std::string node_name);\r
36 \r
37 \r
38 //              LFTA allocation function name.\r
39 \r
40 std::string generate_alloc_name(std::string node_name);\r
41 \r
42 \r
43 //              The name of the schema definition string.\r
44 \r
45 std::string generate_schema_string_name(std::string node_name);\r
46 \r
47 \r
48 //              Generate representations of a tuple.\r
49 //              LFTA and HFTA use slightly different names.\r
50 \r
51 std::string generate_tuple_struct(std::string node_name,\r
52                                                         std::vector<scalarexp_t *> sl_list);\r
53 \r
54 std::string generate_host_tuple_struct(table_def *td);\r
55 std::string generate_host_name_tuple_struct(table_def *td);\r
56 \r
57 \r
58 //              convert internal tuple format to exteral tuple format.\r
59 //              mostly, perform htonl conversions.\r
60 \r
61 std::string generate_hfta_finalize_tuple(table_def *td);\r
62 \r
63 \r
64 \r
65 //              make code translation so that it embeds\r
66 //              as a C-string -- escape the escape characters.\r
67 \r
68 std::string make_C_embedded_string(std::string &instr);\r
69 \r
70 //              pack, unpack tuple struct for use by user defined operators.\r
71 std::string generate_host_tuple_pack(table_def *td);\r
72 std::string generate_host_tuple_unpack(table_def *td);\r
73 \r
74 int split_string(char *instr,char sep, char **words,int max_words);\r
75 \r
76 \r
77 // # random numbers for hashing\r
78 #define NRANDS 100\r
79 \r
80 \r
81 #endif\r
82 \r