OmniSciDB  085a039ca4
 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 989 of file DdlCommandExecutor.cpp.

References CHECK.

989  {
990  int size = -1;
991  if (isArray(data_type)) {
992  CHECK(data_type.HasMember("array"));
993  CHECK(data_type["array"].IsObject());
994 
995  const auto& array = data_type["array"].GetObject();
996  if (array.HasMember("size") && !array["size"].IsNull()) {
997  CHECK(array["size"].IsInt());
998  size = array["size"].GetInt();
999  }
1000  }
1001  return size;
1002 }
static bool isArray(const rapidjson::Value &data_type)
#define CHECK(condition)
Definition: Logger.h:223
int JsonColumnSqlType::getParam1 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 955 of file DdlCommandExecutor.cpp.

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

955  {
956  int param1 = -1;
957  CHECK(data_type.IsObject());
958  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
959  CHECK(data_type["precision"].IsInt());
960  param1 = data_type["precision"].GetInt();
961  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
962  param1 = static_cast<int>(kGEOMETRY);
963  }
964  return param1;
965 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:223
#define IS_GEO(T)
Definition: sqltypes.h:251
int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 967 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, and run_benchmark_import::type.

967  {
968  int param2 = 0;
969  CHECK(data_type.IsObject());
970  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
971  CHECK(data_type["scale"].IsInt());
972  param2 = data_type["scale"].GetInt();
973  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
974  data_type.HasMember("coordinateSystem") &&
975  !data_type["coordinateSystem"].IsNull()) {
976  CHECK(data_type["coordinateSystem"].IsInt());
977  param2 = data_type["coordinateSystem"].GetInt();
978  }
979  return param2;
980 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:223
#define IS_GEO(T)
Definition: sqltypes.h:251
SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 884 of file DdlCommandExecutor.cpp.

References CHECK, and run_benchmark_import::type.

884  {
885  CHECK(data_type.IsObject());
886  CHECK(data_type.HasMember("type"));
887  CHECK(data_type["type"].IsString());
888 
889  std::string type = data_type["type"].GetString();
890  if (boost::iequals(type, "ARRAY")) {
891  CHECK(data_type.HasMember("array"));
892  CHECK(data_type["array"].IsObject());
893 
894  const auto& array = data_type["array"].GetObject();
895  CHECK(array.HasMember("elementType"));
896  CHECK(array["elementType"].IsString());
897  type = array["elementType"].GetString();
898  }
899  return getSqlType(type);
900 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:223
SQLTypes JsonColumnSqlType::getSqlType ( const std::string &  type)
staticprivate

Definition at line 902 of file DdlCommandExecutor.cpp.

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

902  {
903  if (boost::iequals(type, "BIGINT")) {
904  return kBIGINT;
905  }
906  if (boost::iequals(type, "BOOLEAN")) {
907  return kBOOLEAN;
908  }
909  if (boost::iequals(type, "DATE")) {
910  return kDATE;
911  }
912  if (boost::iequals(type, "DECIMAL")) {
913  return kDECIMAL;
914  }
915  if (boost::iequals(type, "DOUBLE")) {
916  return kDOUBLE;
917  }
918  if (boost::iequals(type, "FLOAT")) {
919  return kFLOAT;
920  }
921  if (boost::iequals(type, "INTEGER")) {
922  return kINT;
923  }
924  if (boost::iequals(type, "LINESTRING")) {
925  return kLINESTRING;
926  }
927  if (boost::iequals(type, "MULTIPOLYGON")) {
928  return kMULTIPOLYGON;
929  }
930  if (boost::iequals(type, "POINT")) {
931  return kPOINT;
932  }
933  if (boost::iequals(type, "POLYGON")) {
934  return kPOLYGON;
935  }
936  if (boost::iequals(type, "SMALLINT")) {
937  return kSMALLINT;
938  }
939  if (boost::iequals(type, "TEXT")) {
940  return kTEXT;
941  }
942  if (boost::iequals(type, "TIME")) {
943  return kTIME;
944  }
945  if (boost::iequals(type, "TIMESTAMP")) {
946  return kTIMESTAMP;
947  }
948  if (boost::iequals(type, "TINYINT")) {
949  return kTINYINT;
950  }
951 
952  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
953 }
Definition: sqltypes.h:49
SQLTypes type
Definition: DdlUtils.h:54
Definition: sqltypes.h:52
Definition: sqltypes.h:53
Definition: sqltypes.h:45
bool JsonColumnSqlType::isArray ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 982 of file DdlCommandExecutor.cpp.

References CHECK.

982  {
983  CHECK(data_type.IsObject());
984  CHECK(data_type.HasMember("type"));
985  CHECK(data_type["type"].IsString());
986  return boost::iequals(data_type["type"].GetString(), "ARRAY");
987 }
#define CHECK(condition)
Definition: Logger.h:223

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