OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 216 of file DdlCommandExecutor.cpp.

Constructor & Destructor Documentation

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

Definition at line 218 of file DdlCommandExecutor.cpp.

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

References CHECK.

818  {
819  int size = -1;
820  if (isArray(data_type)) {
821  CHECK(data_type.HasMember("array"));
822  CHECK(data_type["array"].IsObject());
823 
824  const auto& array = data_type["array"].GetObject();
825  if (array.HasMember("size") && !array["size"].IsNull()) {
826  CHECK(array["size"].IsInt());
827  size = array["size"].GetInt();
828  }
829  }
830  return size;
831 }
static bool isArray(const rapidjson::Value &data_type)
#define CHECK(condition)
Definition: Logger.h:203
int JsonColumnSqlType::getParam1 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 784 of file DdlCommandExecutor.cpp.

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

784  {
785  int param1 = -1;
786  CHECK(data_type.IsObject());
787  if (data_type.HasMember("precision") && !data_type["precision"].IsNull()) {
788  CHECK(data_type["precision"].IsInt());
789  param1 = data_type["precision"].GetInt();
790  } else if (auto type = getSqlType(data_type); IS_GEO(type)) {
791  param1 = static_cast<int>(kGEOMETRY);
792  }
793  return param1;
794 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:203
#define IS_GEO(T)
Definition: sqltypes.h:245
int JsonColumnSqlType::getParam2 ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 796 of file DdlCommandExecutor.cpp.

References CHECK, IS_GEO, and run_benchmark_import::type.

796  {
797  int param2 = 0;
798  CHECK(data_type.IsObject());
799  if (data_type.HasMember("scale") && !data_type["scale"].IsNull()) {
800  CHECK(data_type["scale"].IsInt());
801  param2 = data_type["scale"].GetInt();
802  } else if (auto type = getSqlType(data_type); IS_GEO(type) &&
803  data_type.HasMember("coordinateSystem") &&
804  !data_type["coordinateSystem"].IsNull()) {
805  CHECK(data_type["coordinateSystem"].IsInt());
806  param2 = data_type["coordinateSystem"].GetInt();
807  }
808  return param2;
809 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:203
#define IS_GEO(T)
Definition: sqltypes.h:245
SQLTypes JsonColumnSqlType::getSqlType ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 713 of file DdlCommandExecutor.cpp.

References CHECK, and run_benchmark_import::type.

713  {
714  CHECK(data_type.IsObject());
715  CHECK(data_type.HasMember("type"));
716  CHECK(data_type["type"].IsString());
717 
718  std::string type = data_type["type"].GetString();
719  if (boost::iequals(type, "ARRAY")) {
720  CHECK(data_type.HasMember("array"));
721  CHECK(data_type["array"].IsObject());
722 
723  const auto& array = data_type["array"].GetObject();
724  CHECK(array.HasMember("elementType"));
725  CHECK(array["elementType"].IsString());
726  type = array["elementType"].GetString();
727  }
728  return getSqlType(type);
729 }
static SQLTypes getSqlType(const rapidjson::Value &data_type)
SQLTypes type
Definition: DdlUtils.h:54
#define CHECK(condition)
Definition: Logger.h:203
SQLTypes JsonColumnSqlType::getSqlType ( const std::string &  type)
staticprivate

Definition at line 731 of file DdlCommandExecutor.cpp.

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

731  {
732  if (boost::iequals(type, "BIGINT")) {
733  return kBIGINT;
734  }
735  if (boost::iequals(type, "BOOLEAN")) {
736  return kBOOLEAN;
737  }
738  if (boost::iequals(type, "DATE")) {
739  return kDATE;
740  }
741  if (boost::iequals(type, "DECIMAL")) {
742  return kDECIMAL;
743  }
744  if (boost::iequals(type, "DOUBLE")) {
745  return kDOUBLE;
746  }
747  if (boost::iequals(type, "FLOAT")) {
748  return kFLOAT;
749  }
750  if (boost::iequals(type, "INTEGER")) {
751  return kINT;
752  }
753  if (boost::iequals(type, "LINESTRING")) {
754  return kLINESTRING;
755  }
756  if (boost::iequals(type, "MULTIPOLYGON")) {
757  return kMULTIPOLYGON;
758  }
759  if (boost::iequals(type, "POINT")) {
760  return kPOINT;
761  }
762  if (boost::iequals(type, "POLYGON")) {
763  return kPOLYGON;
764  }
765  if (boost::iequals(type, "SMALLINT")) {
766  return kSMALLINT;
767  }
768  if (boost::iequals(type, "TEXT")) {
769  return kTEXT;
770  }
771  if (boost::iequals(type, "TIME")) {
772  return kTIME;
773  }
774  if (boost::iequals(type, "TIMESTAMP")) {
775  return kTIMESTAMP;
776  }
777  if (boost::iequals(type, "TINYINT")) {
778  return kTINYINT;
779  }
780 
781  throw std::runtime_error{"Unsupported type \"" + type + "\" specified."};
782 }
Definition: sqltypes.h:48
SQLTypes type
Definition: DdlUtils.h:54
Definition: sqltypes.h:51
Definition: sqltypes.h:52
Definition: sqltypes.h:44
bool JsonColumnSqlType::isArray ( const rapidjson::Value &  data_type)
staticprivate

Definition at line 811 of file DdlCommandExecutor.cpp.

References CHECK.

811  {
812  CHECK(data_type.IsObject());
813  CHECK(data_type.HasMember("type"));
814  CHECK(data_type["type"].IsString());
815  return boost::iequals(data_type["type"].GetString(), "ARRAY");
816 }
#define CHECK(condition)
Definition: Logger.h:203

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