OmniSciDB  471d68cefb
 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 215 of file DdlCommandExecutor.cpp.

Constructor & Destructor Documentation

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

Definition at line 217 of file DdlCommandExecutor.cpp.

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

References CHECK.

944  {
945  int size = -1;
946  if (isArray(data_type)) {
947  CHECK(data_type.HasMember("array"));
948  CHECK(data_type["array"].IsObject());
949 
950  const auto& array = data_type["array"].GetObject();
951  if (array.HasMember("size") && !array["size"].IsNull()) {
952  CHECK(array["size"].IsInt());
953  size = array["size"].GetInt();
954  }
955  }
956  return size;
957 }
static bool isArray(const rapidjson::Value &data_type)
#define CHECK(condition)
Definition: Logger.h:209
int JsonColumnSqlType::getParam1 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 910 of file DdlCommandExecutor.cpp.

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

910  {
911  int param1 = -1;
912  CHECK(data_type.IsObject());
913  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
914  CHECK(data_type["precision"].IsInt());
915  param1 = data_type["precision"].GetInt();
916  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
917  param1 = static_cast<int>(kGEOMETRY);
918  }
919  return param1;
920 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:209
#define IS_GEO(T)
Definition: sqltypes.h:251
int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 922 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, and run_benchmark_import::type.

922  {
923  int param2 = 0;
924  CHECK(data_type.IsObject());
925  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
926  CHECK(data_type["scale"].IsInt());
927  param2 = data_type["scale"].GetInt();
928  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
929  data_type.HasMember("coordinateSystem") &&
930  !data_type["coordinateSystem"].IsNull()) {
931  CHECK(data_type["coordinateSystem"].IsInt());
932  param2 = data_type["coordinateSystem"].GetInt();
933  }
934  return param2;
935 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:209
#define IS_GEO(T)
Definition: sqltypes.h:251
SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 839 of file DdlCommandExecutor.cpp.

References CHECK, and run_benchmark_import::type.

839  {
840  CHECK(data_type.IsObject());
841  CHECK(data_type.HasMember("type"));
842  CHECK(data_type["type"].IsString());
843 
844  std::string type = data_type["type"].GetString();
845  if (boost::iequals(type, "ARRAY")) {
846  CHECK(data_type.HasMember("array"));
847  CHECK(data_type["array"].IsObject());
848 
849  const auto& array = data_type["array"].GetObject();
850  CHECK(array.HasMember("elementType"));
851  CHECK(array["elementType"].IsString());
852  type = array["elementType"].GetString();
853  }
854  return getSqlType(type);
855 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:209
SQLTypes JsonColumnSqlType::getSqlType ( const std::string &  type)
staticprivate

Definition at line 857 of file DdlCommandExecutor.cpp.

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

857  {
858  if (boost::iequals(type, "BIGINT")) {
859  return kBIGINT;
860  }
861  if (boost::iequals(type, "BOOLEAN")) {
862  return kBOOLEAN;
863  }
864  if (boost::iequals(type, "DATE")) {
865  return kDATE;
866  }
867  if (boost::iequals(type, "DECIMAL")) {
868  return kDECIMAL;
869  }
870  if (boost::iequals(type, "DOUBLE")) {
871  return kDOUBLE;
872  }
873  if (boost::iequals(type, "FLOAT")) {
874  return kFLOAT;
875  }
876  if (boost::iequals(type, "INTEGER")) {
877  return kINT;
878  }
879  if (boost::iequals(type, "LINESTRING")) {
880  return kLINESTRING;
881  }
882  if (boost::iequals(type, "MULTIPOLYGON")) {
883  return kMULTIPOLYGON;
884  }
885  if (boost::iequals(type, "POINT")) {
886  return kPOINT;
887  }
888  if (boost::iequals(type, "POLYGON")) {
889  return kPOLYGON;
890  }
891  if (boost::iequals(type, "SMALLINT")) {
892  return kSMALLINT;
893  }
894  if (boost::iequals(type, "TEXT")) {
895  return kTEXT;
896  }
897  if (boost::iequals(type, "TIME")) {
898  return kTIME;
899  }
900  if (boost::iequals(type, "TIMESTAMP")) {
901  return kTIMESTAMP;
902  }
903  if (boost::iequals(type, "TINYINT")) {
904  return kTINYINT;
905  }
906 
907  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
908 }
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 937 of file DdlCommandExecutor.cpp.

References CHECK.

937  {
938  CHECK(data_type.IsObject());
939  CHECK(data_type.HasMember("type"));
940  CHECK(data_type["type"].IsString());
941  return boost::iequals(data_type["type"].GetString(), "ARRAY");
942 }
#define CHECK(condition)
Definition: Logger.h:209

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