OmniSciDB  c1a53651b2
 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 214 of file DdlCommandExecutor.cpp.

Constructor & Destructor Documentation

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

Definition at line 216 of file DdlCommandExecutor.cpp.

217  : ddl_utils::SqlType(getSqlType(data_type),
218  getParam1(data_type),
219  getParam2(data_type),
220  isArray(data_type),
221  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 1114 of file DdlCommandExecutor.cpp.

References CHECK.

1114  {
1115  int size = -1;
1116  if (isArray(data_type)) {
1117  CHECK(data_type.HasMember("array"));
1118  CHECK(data_type["array"].IsObject());
1119 
1120  const auto& array = data_type["array"].GetObject();
1121  if (array.HasMember("size") && !array["size"].IsNull()) {
1122  CHECK(array["size"].IsInt());
1123  size = array["size"].GetInt();
1124  }
1125  }
1126  return size;
1127 }
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 1080 of file DdlCommandExecutor.cpp.

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

1080  {
1081  int param1 = -1;
1082  CHECK(data_type.IsObject());
1083  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
1084  CHECK(data_type["precision"].IsInt());
1085  param1 = data_type["precision"].GetInt();
1086  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
1087  param1 = static_cast<int>(kGEOMETRY);
1088  }
1089  return param1;
1090 }
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:300
int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1092 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, and run_benchmark_import::type.

1092  {
1093  int param2 = 0;
1094  CHECK(data_type.IsObject());
1095  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
1096  CHECK(data_type["scale"].IsInt());
1097  param2 = data_type["scale"].GetInt();
1098  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
1099  data_type.HasMember("coordinateSystem") &&
1100  !data_type["coordinateSystem"].IsNull()) {
1101  CHECK(data_type["coordinateSystem"].IsInt());
1102  param2 = data_type["coordinateSystem"].GetInt();
1103  }
1104  return param2;
1105 }
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:300
SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1003 of file DdlCommandExecutor.cpp.

References CHECK, and run_benchmark_import::type.

1003  {
1004  CHECK(data_type.IsObject());
1005  CHECK(data_type.HasMember("type"));
1006  CHECK(data_type["type"].IsString());
1007 
1008  std::string type = data_type["type"].GetString();
1009  if (boost::iequals(type, "ARRAY")) {
1010  CHECK(data_type.HasMember("array"));
1011  CHECK(data_type["array"].IsObject());
1012 
1013  const auto& array = data_type["array"].GetObject();
1014  CHECK(array.HasMember("elementType"));
1015  CHECK(array["elementType"].IsString());
1016  type = array["elementType"].GetString();
1017  }
1018  return getSqlType(type);
1019 }
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 1021 of file DdlCommandExecutor.cpp.

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

1021  {
1022  if (boost::iequals(type, "BIGINT")) {
1023  return kBIGINT;
1024  }
1025  if (boost::iequals(type, "BOOLEAN")) {
1026  return kBOOLEAN;
1027  }
1028  if (boost::iequals(type, "DATE")) {
1029  return kDATE;
1030  }
1031  if (boost::iequals(type, "DECIMAL")) {
1032  return kDECIMAL;
1033  }
1034  if (boost::iequals(type, "DOUBLE")) {
1035  return kDOUBLE;
1036  }
1037  if (boost::iequals(type, "FLOAT")) {
1038  return kFLOAT;
1039  }
1040  if (boost::iequals(type, "INTEGER")) {
1041  return kINT;
1042  }
1043  if (boost::iequals(type, "LINESTRING")) {
1044  return kLINESTRING;
1045  }
1046  if (boost::iequals(type, "MULTILINESTRING")) {
1047  return kMULTILINESTRING;
1048  }
1049  if (boost::iequals(type, "MULTIPOLYGON")) {
1050  return kMULTIPOLYGON;
1051  }
1052  if (boost::iequals(type, "POINT")) {
1053  return kPOINT;
1054  }
1055  if (boost::iequals(type, "MULTIPOINT")) {
1056  return kMULTIPOINT;
1057  }
1058  if (boost::iequals(type, "POLYGON")) {
1059  return kPOLYGON;
1060  }
1061  if (boost::iequals(type, "SMALLINT")) {
1062  return kSMALLINT;
1063  }
1064  if (boost::iequals(type, "TEXT")) {
1065  return kTEXT;
1066  }
1067  if (boost::iequals(type, "TIME")) {
1068  return kTIME;
1069  }
1070  if (boost::iequals(type, "TIMESTAMP")) {
1071  return kTIMESTAMP;
1072  }
1073  if (boost::iequals(type, "TINYINT")) {
1074  return kTINYINT;
1075  }
1076 
1077  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
1078 }
Definition: sqltypes.h:66
SQLTypes type
Definition: DdlUtils.h:54
Definition: sqltypes.h:69
Definition: sqltypes.h:70
Definition: sqltypes.h:62
bool JsonColumnSqlType::isArray ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 1107 of file DdlCommandExecutor.cpp.

References CHECK.

1107  {
1108  CHECK(data_type.IsObject());
1109  CHECK(data_type.HasMember("type"));
1110  CHECK(data_type["type"].IsString());
1111  return boost::iequals(data_type["type"].GetString(), "ARRAY");
1112 }
#define CHECK(condition)
Definition: Logger.h:291

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