OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThriftTypesConvert.h File Reference
#include "gen-cpp/heavy_types.h"
#include "Logger/Logger.h"
#include <string>
+ Include dependency graph for ThriftTypesConvert.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define THRIFT_ENCODING_CASE(encoding)
 
#define UNTHRIFT_ENCODING_CASE(encoding)
 

Functions

TDatumType::type type_to_thrift (const SQLTypeInfo &type_info)
 
SQLTypes thrift_to_type (const TDatumType::type &type)
 
TEncodingType::type encoding_to_thrift (const SQLTypeInfo &type_info)
 
EncodingType thrift_to_encoding (const TEncodingType::type tEncodingType)
 
std::string thrift_to_name (const TTypeInfo &ti)
 
std::string thrift_to_encoding_name (const TTypeInfo &ti)
 
SQLTypeInfo type_info_from_thrift (const TTypeInfo &thrift_ti, const bool strip_geo_encoding=false)
 

Macro Definition Documentation

#define THRIFT_ENCODING_CASE (   encoding)
Value:
case kENCODING_##encoding: \
return TEncodingType::encoding;

Definition at line 137 of file ThriftTypesConvert.h.

Referenced by encoding_to_thrift().

#define UNTHRIFT_ENCODING_CASE (   encoding)
Value:
case TEncodingType::encoding: \
return kENCODING_##encoding;

Definition at line 141 of file ThriftTypesConvert.h.

Referenced by thrift_to_encoding().

Function Documentation

TEncodingType::type encoding_to_thrift ( const SQLTypeInfo type_info)
inline

Definition at line 145 of file ThriftTypesConvert.h.

References CHECK, SQLTypeInfo::get_compression(), NONE, and THRIFT_ENCODING_CASE.

Referenced by DBHandler::detect_column_types(), DBHandler::populateThriftColumnType(), ThriftSerializers::target_meta_info_to_thrift(), and ThriftSerializers::type_info_to_thrift().

145  {
146  switch (type_info.get_compression()) {
148  THRIFT_ENCODING_CASE(FIXED)
152  THRIFT_ENCODING_CASE(SPARSE)
153  THRIFT_ENCODING_CASE(GEOINT)
154  THRIFT_ENCODING_CASE(DATE_IN_DAYS)
155  default:
156  CHECK(false);
157  }
158  abort();
159 }
#define THRIFT_ENCODING_CASE(encoding)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
bool g_enable_watchdog false
Definition: Execute.cpp:79
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EncodingType thrift_to_encoding ( const TEncodingType::type  tEncodingType)
inline

Definition at line 163 of file ThriftTypesConvert.h.

References CHECK, NONE, and UNTHRIFT_ENCODING_CASE.

Referenced by DBHandler::create_table(), thrift_to_encoding_name(), thrift_to_name(), and type_info_from_thrift().

163  {
164  switch (tEncodingType) {
170  UNTHRIFT_ENCODING_CASE(SPARSE)
171  UNTHRIFT_ENCODING_CASE(GEOINT)
172  UNTHRIFT_ENCODING_CASE(DATE_IN_DAYS)
173  default:
174  CHECK(false);
175  }
176  abort();
177 }
#define UNTHRIFT_ENCODING_CASE(encoding)
bool g_enable_watchdog false
Definition: Execute.cpp:79
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

std::string thrift_to_encoding_name ( const TTypeInfo &  ti)
inline

Definition at line 204 of file ThriftTypesConvert.h.

References kARRAY, kNULLT, thrift_to_encoding(), thrift_to_type(), and run_benchmark_import::type.

Referenced by DBHandler::create_table().

204  {
205  const auto type = thrift_to_type(ti.type);
206  const auto encoding = thrift_to_encoding(ti.encoding);
207  auto internal_ti = SQLTypeInfo(ti.is_array ? kARRAY : type,
208  0,
209  0,
210  !ti.nullable,
211  encoding,
212  0,
213  ti.is_array ? type : kNULLT);
214  return internal_ti.get_compression_name();
215 }
EncodingType thrift_to_encoding(const TEncodingType::type tEncodingType)
SQLTypes thrift_to_type(const TDatumType::type &type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string thrift_to_name ( const TTypeInfo &  ti)
inline

Definition at line 179 of file ThriftTypesConvert.h.

References IS_GEO, kARRAY, kDECIMAL, kNULLT, kNUMERIC, kTIMESTAMP, thrift_to_encoding(), thrift_to_type(), and run_benchmark_import::type.

Referenced by DBHandler::create_table().

179  {
180  const auto type = thrift_to_type(ti.type);
181  const auto encoding = thrift_to_encoding(ti.encoding);
182  auto internal_ti = SQLTypeInfo(ti.is_array ? kARRAY : type,
183  0,
184  0,
185  !ti.nullable,
186  encoding,
187  ti.comp_param,
188  ti.is_array ? type : kNULLT);
189  if (type == kDECIMAL || type == kNUMERIC) {
190  internal_ti.set_precision(ti.precision);
191  internal_ti.set_scale(ti.scale);
192  } else if (type == kTIMESTAMP) {
193  internal_ti.set_precision(ti.precision);
194  }
195  if (IS_GEO(type)) {
196  internal_ti.set_subtype(static_cast<SQLTypes>(ti.precision));
197  internal_ti.set_input_srid(ti.scale);
198  internal_ti.set_output_srid(ti.scale);
199  }
200  internal_ti.set_size(ti.size);
201  return internal_ti.get_type_name();
202 }
EncodingType thrift_to_encoding(const TEncodingType::type tEncodingType)
SQLTypes thrift_to_type(const TDatumType::type &type)
#define IS_GEO(T)
Definition: sqltypes.h:298

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypes thrift_to_type ( const TDatumType::type &  type)
inline

Definition at line 85 of file ThriftTypesConvert.h.

References kBIGINT, kBOOLEAN, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kGEOGRAPHY, kGEOMETRY, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, and kTINYINT.

Referenced by thrift_to_encoding_name(), thrift_to_name(), and type_info_from_thrift().

85  {
86  switch (type) {
87  case TDatumType::BOOL:
88  return kBOOLEAN;
89  case TDatumType::TINYINT:
90  return kTINYINT;
91  case TDatumType::SMALLINT:
92  return kSMALLINT;
93  case TDatumType::INT:
94  return kINT;
95  case TDatumType::BIGINT:
96  return kBIGINT;
97  case TDatumType::FLOAT:
98  return kFLOAT;
99  case TDatumType::DECIMAL:
100  return kDECIMAL;
101  case TDatumType::DOUBLE:
102  return kDOUBLE;
103  case TDatumType::STR:
104  return kTEXT;
105  case TDatumType::TIME:
106  return kTIME;
107  case TDatumType::TIMESTAMP:
108  return kTIMESTAMP;
109  case TDatumType::DATE:
110  return kDATE;
111  case TDatumType::INTERVAL_DAY_TIME:
112  return kINTERVAL_DAY_TIME;
113  case TDatumType::INTERVAL_YEAR_MONTH:
114  return kINTERVAL_YEAR_MONTH;
115  case TDatumType::POINT:
116  return kPOINT;
117  case TDatumType::MULTIPOINT:
118  return kMULTIPOINT;
119  case TDatumType::LINESTRING:
120  return kLINESTRING;
121  case TDatumType::MULTILINESTRING:
122  return kMULTILINESTRING;
123  case TDatumType::POLYGON:
124  return kPOLYGON;
125  case TDatumType::MULTIPOLYGON:
126  return kMULTIPOLYGON;
127  case TDatumType::GEOMETRY:
128  return kGEOMETRY;
129  case TDatumType::GEOGRAPHY:
130  return kGEOGRAPHY;
131  default:
132  break;
133  }
134  abort();
135 }
Definition: sqltypes.h:64
Definition: sqltypes.h:67
Definition: sqltypes.h:68
Definition: sqltypes.h:60

+ Here is the caller graph for this function:

SQLTypeInfo type_info_from_thrift ( const TTypeInfo &  thrift_ti,
const bool  strip_geo_encoding = false 
)
inline

Definition at line 217 of file ThriftTypesConvert.h.

References CHECK_LT, IS_GEO, kARRAY, kENCODING_NONE, kNULLT, kSQLTYPE_LAST, thrift_to_encoding(), and thrift_to_type().

Referenced by ThriftSerializers::target_info_from_thrift(), and ThriftSerializers::target_meta_infos_from_thrift().

218  {
219  const auto ti = thrift_to_type(thrift_ti.type);
220  if (IS_GEO(ti)) {
221  const auto base_type = static_cast<SQLTypes>(thrift_ti.precision);
222  CHECK_LT(base_type, kSQLTYPE_LAST);
223  return SQLTypeInfo(
224  ti,
225  thrift_ti.scale,
226  thrift_ti.scale,
227  !thrift_ti.nullable,
228  strip_geo_encoding ? kENCODING_NONE : thrift_to_encoding(thrift_ti.encoding),
229  thrift_ti.comp_param,
230  base_type);
231  }
232  if (thrift_ti.is_array) {
233  auto ati = SQLTypeInfo(kARRAY,
234  thrift_ti.precision,
235  thrift_ti.scale,
236  !thrift_ti.nullable,
237  thrift_to_encoding(thrift_ti.encoding),
238  thrift_ti.comp_param,
239  ti);
240  ati.set_size(thrift_ti.size);
241  return ati;
242  }
243  return SQLTypeInfo(ti,
244  thrift_ti.precision,
245  thrift_ti.scale,
246  !thrift_ti.nullable,
247  thrift_to_encoding(thrift_ti.encoding),
248  thrift_ti.comp_param,
249  kNULLT);
250 }
SQLTypes
Definition: sqltypes.h:53
EncodingType thrift_to_encoding(const TEncodingType::type tEncodingType)
SQLTypes thrift_to_type(const TDatumType::type &type)
#define CHECK_LT(x, y)
Definition: Logger.h:299
#define IS_GEO(T)
Definition: sqltypes.h:298

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TDatumType::type type_to_thrift ( const SQLTypeInfo type_info)
inline

Definition at line 26 of file ThriftTypesConvert.h.

References SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), kARRAY, kBIGINT, kBOOLEAN, kCHAR, kCOLUMN, kCOLUMN_LIST, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kGEOGRAPHY, kGEOMETRY, kINT, kINTERVAL_DAY_TIME, kINTERVAL_YEAR_MONTH, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, and run_benchmark_import::type.

Referenced by DBHandler::detect_column_types(), DBHandler::populateThriftColumnType(), ThriftSerializers::target_meta_info_to_thrift(), and ThriftSerializers::type_info_to_thrift().

26  {
27  SQLTypes type = type_info.get_type();
28  if (type == kARRAY || type == kCOLUMN || type == kCOLUMN_LIST) {
29  type = type_info.get_subtype();
30  }
31  switch (type) {
32  case kBOOLEAN:
33  return TDatumType::BOOL;
34  case kTINYINT:
35  return TDatumType::TINYINT;
36  case kSMALLINT:
37  return TDatumType::SMALLINT;
38  case kINT:
39  return TDatumType::INT;
40  case kBIGINT:
41  return TDatumType::BIGINT;
42  case kFLOAT:
43  return TDatumType::FLOAT;
44  case kNUMERIC:
45  case kDECIMAL:
46  return TDatumType::DECIMAL;
47  case kDOUBLE:
48  return TDatumType::DOUBLE;
49  case kTEXT:
50  case kVARCHAR:
51  case kCHAR:
52  return TDatumType::STR;
53  case kTIME:
54  return TDatumType::TIME;
55  case kTIMESTAMP:
56  return TDatumType::TIMESTAMP;
57  case kDATE:
58  return TDatumType::DATE;
59  case kINTERVAL_DAY_TIME:
60  return TDatumType::INTERVAL_DAY_TIME;
62  return TDatumType::INTERVAL_YEAR_MONTH;
63  case kPOINT:
64  return TDatumType::POINT;
65  case kMULTIPOINT:
66  return TDatumType::MULTIPOINT;
67  case kLINESTRING:
68  return TDatumType::LINESTRING;
69  case kMULTILINESTRING:
70  return TDatumType::MULTILINESTRING;
71  case kPOLYGON:
72  return TDatumType::POLYGON;
73  case kMULTIPOLYGON:
74  return TDatumType::MULTIPOLYGON;
75  case kGEOMETRY:
76  return TDatumType::GEOMETRY;
77  case kGEOGRAPHY:
78  return TDatumType::GEOGRAPHY;
79  default:
80  break;
81  }
82  abort();
83 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:381
Definition: sqltypes.h:64
SQLTypes
Definition: sqltypes.h:53
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
Definition: sqltypes.h:67
Definition: sqltypes.h:68
Definition: sqltypes.h:56
Definition: sqltypes.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function: