OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType Class Reference

declare this class scoped local to avoid exposing rapidjson in the header file More...

+ Inheritance diagram for anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType:
+ Collaboration diagram for anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType:

Public Member Functions

 JsonColumnSqlType (const rapidjson::Value &data_type)
 
- Public Member Functions inherited from ddl_utils::SqlType
 SqlType (SQLTypes type, int param1, int param2, bool is_array, int array_size)
 
virtual SQLTypes get_type () const
 
virtual int get_param1 () const
 
virtual void set_param1 (int param)
 
virtual int get_param2 () const
 
virtual bool get_is_array () const
 
virtual void set_is_array (bool a)
 
virtual int get_array_size () const
 
virtual void set_array_size (int s)
 
virtual std::string to_string () const
 
virtual void check_type ()
 

Static Private Member Functions

static SQLTypes getSqlType (const rapidjson::Value &data_type)
 
static SQLTypes getSqlType (const std::string &type)
 
static int getParam1 (const rapidjson::Value &data_type)
 
static int getParam2 (const rapidjson::Value &data_type)
 
static bool isArray (const rapidjson::Value &data_type)
 
static int getArraySize (const rapidjson::Value &data_type)
 

Additional Inherited Members

- Protected Attributes inherited from ddl_utils::SqlType
SQLTypes type
 
int param1
 
int param2
 
bool is_array
 
int array_size
 

Detailed Description

declare this class scoped local to avoid exposing rapidjson in the header file

Definition at line 407 of file DdlCommandExecutor.cpp.

Constructor & Destructor Documentation

anonymous_namespace{DdlCommandExecutor.cpp}::JsonColumnSqlType::JsonColumnSqlType ( const rapidjson::Value &  data_type)
inline

Definition at line 409 of file DdlCommandExecutor.cpp.

410  : ddl_utils::SqlType(getSqlType(data_type),
411  getParam1(data_type),
412  getParam2(data_type),
413  isArray(data_type),
414  getArraySize(data_type)) {}
static bool isArray(const rapidjson::Value &data_type)
static SQLTypes getSqlType(const rapidjson::Value &data_type)
static int getParam1(const rapidjson::Value &data_type)
static int getArraySize(const rapidjson::Value &data_type)
static int getParam2(const rapidjson::Value &data_type)

Member Function Documentation

int JsonColumnSqlType::getArraySize ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1333 of file DdlCommandExecutor.cpp.

References CHECK.

1333  {
1334  int size = -1;
1335  if (isArray(data_type)) {
1336  CHECK(data_type.HasMember("array"));
1337  CHECK(data_type["array"].IsObject());
1338 
1339  const auto& array = data_type["array"].GetObject();
1340  if (array.HasMember("size") && !array["size"].IsNull()) {
1341  CHECK(array["size"].IsInt());
1342  size = array["size"].GetInt();
1343  }
1344  }
1345  return size;
1346 }
static bool isArray(const rapidjson::Value &data_type)
#define CHECK(condition)
Definition: Logger.h:291
int JsonColumnSqlType::getParam1 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1299 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, kGEOMETRY, and run_benchmark_import::type.

1299  {
1300  int param1 = -1;
1301  CHECK(data_type.IsObject());
1302  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
1303  CHECK(data_type["precision"].IsInt());
1304  param1 = data_type["precision"].GetInt();
1305  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
1306  param1 = static_cast<int>(kGEOMETRY);
1307  }
1308  return param1;
1309 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:291
#define IS_GEO(T)
Definition: sqltypes.h:310
int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1311 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, and run_benchmark_import::type.

1311  {
1312  int param2 = 0;
1313  CHECK(data_type.IsObject());
1314  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
1315  CHECK(data_type["scale"].IsInt());
1316  param2 = data_type["scale"].GetInt();
1317  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
1318  data_type.HasMember("coordinateSystem") &&
1319  !data_type["coordinateSystem"].IsNull()) {
1320  CHECK(data_type["coordinateSystem"].IsInt());
1321  param2 = data_type["coordinateSystem"].GetInt();
1322  }
1323  return param2;
1324 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:291
#define IS_GEO(T)
Definition: sqltypes.h:310
SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1222 of file DdlCommandExecutor.cpp.

References CHECK, and run_benchmark_import::type.

1222  {
1223  CHECK(data_type.IsObject());
1224  CHECK(data_type.HasMember("type"));
1225  CHECK(data_type["type"].IsString());
1226 
1227  std::string type = data_type["type"].GetString();
1228  if (boost::iequals(type, "ARRAY")) {
1229  CHECK(data_type.HasMember("array"));
1230  CHECK(data_type["array"].IsObject());
1231 
1232  const auto& array = data_type["array"].GetObject();
1233  CHECK(array.HasMember("elementType"));
1234  CHECK(array["elementType"].IsString());
1235  type = array["elementType"].GetString();
1236  }
1237  return getSqlType(type);
1238 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:291
SQLTypes JsonColumnSqlType::getSqlType ( const std::string &  type)
staticprivate

Definition at line 1240 of file DdlCommandExecutor.cpp.

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

1240  {
1241  if (boost::iequals(type, "BIGINT")) {
1242  return kBIGINT;
1243  }
1244  if (boost::iequals(type, "BOOLEAN")) {
1245  return kBOOLEAN;
1246  }
1247  if (boost::iequals(type, "DATE")) {
1248  return kDATE;
1249  }
1250  if (boost::iequals(type, "DECIMAL")) {
1251  return kDECIMAL;
1252  }
1253  if (boost::iequals(type, "DOUBLE")) {
1254  return kDOUBLE;
1255  }
1256  if (boost::iequals(type, "FLOAT")) {
1257  return kFLOAT;
1258  }
1259  if (boost::iequals(type, "INTEGER")) {
1260  return kINT;
1261  }
1262  if (boost::iequals(type, "LINESTRING")) {
1263  return kLINESTRING;
1264  }
1265  if (boost::iequals(type, "MULTILINESTRING")) {
1266  return kMULTILINESTRING;
1267  }
1268  if (boost::iequals(type, "MULTIPOLYGON")) {
1269  return kMULTIPOLYGON;
1270  }
1271  if (boost::iequals(type, "POINT")) {
1272  return kPOINT;
1273  }
1274  if (boost::iequals(type, "MULTIPOINT")) {
1275  return kMULTIPOINT;
1276  }
1277  if (boost::iequals(type, "POLYGON")) {
1278  return kPOLYGON;
1279  }
1280  if (boost::iequals(type, "SMALLINT")) {
1281  return kSMALLINT;
1282  }
1283  if (boost::iequals(type, "TEXT")) {
1284  return kTEXT;
1285  }
1286  if (boost::iequals(type, "TIME")) {
1287  return kTIME;
1288  }
1289  if (boost::iequals(type, "TIMESTAMP")) {
1290  return kTIMESTAMP;
1291  }
1292  if (boost::iequals(type, "TINYINT")) {
1293  return kTINYINT;
1294  }
1295 
1296  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
1297 }
Definition: sqltypes.h:76
SQLTypes type
Definition: DdlUtils.h:54
Definition: sqltypes.h:79
Definition: sqltypes.h:80
Definition: sqltypes.h:72
bool JsonColumnSqlType::isArray ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1326 of file DdlCommandExecutor.cpp.

References CHECK.

1326  {
1327  CHECK(data_type.IsObject());
1328  CHECK(data_type.HasMember("type"));
1329  CHECK(data_type["type"].IsString());
1330  return boost::iequals(data_type["type"].GetString(), "ARRAY");
1331 }
#define CHECK(condition)
Definition: Logger.h:291

The documentation for this class was generated from the following file: