OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
json_utils Namespace Reference

Functions

void set_value (rapidjson::Value &json_val, const ColumnDescriptor &column_desc, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, ColumnDescriptor &column_desc)
 
std::string get_type_as_string (const rapidjson::Value &object)
 
void set_value (rapidjson::Value &json_val, const size_t &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, size_t &value)
 
void set_value (rapidjson::Value &json_val, const int &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, int &value)
 
void set_value (rapidjson::Value &json_val, const std::string &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, std::string &value)
 
void set_value (rapidjson::Value &json_val, const int64_t &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, int64_t &value)
 
void set_value (rapidjson::Value &json_val, const bool &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, bool &value)
 
void set_value (rapidjson::Value &json_val, const SQLTypes &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, SQLTypes &value)
 
void set_value (rapidjson::Value &json_val, const EncodingType &value, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, EncodingType &value)
 
void set_value (rapidjson::Value &json_obj, const shared::StringDictKey &dict_key, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_obj, shared::StringDictKey &dict_key)
 
void set_value (rapidjson::Value &json_val, const SQLTypeInfo &type_info, rapidjson::Document::AllocatorType &allocator)
 
void get_value (const rapidjson::Value &json_val, SQLTypeInfo &type_info)
 
rapidjson::Document read_from_file (const std::string &file_path)
 
void write_to_file (const rapidjson::Document &document, const std::string &filepath)
 
std::string write_to_string (const rapidjson::Document &document)
 
std::optional< std::string > get_optional_string_value_from_object (const rapidjson::Value &object, const std::string &key)
 
template<class T >
void add_value_to_object (rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
 
template<class T >
void get_value_from_object (const rapidjson::Value &object, T &value, const std::string &name)
 
template<typename T , typename MemberFunc >
void get_value_from_object (const rapidjson::Value &json_val, MemberFunc mem_fn, SQLTypeInfo &type_info, const std::string &key)
 
template<class T >
void set_value (rapidjson::Value &json_val, const std::vector< T > &vector_value, rapidjson::Document::AllocatorType &allocator)
 
template<class T >
void get_value (const rapidjson::Value &json_val, std::vector< T > &vector_value)
 
template<class T >
void set_value (rapidjson::Value &json_val, const std::list< T > &list_value, rapidjson::Document::AllocatorType &allocator)
 
template<class T >
void get_value (const rapidjson::Value &json_val, std::list< T > &list_value)
 
template<class T , class V >
void set_value (rapidjson::Value &json_val, const std::vector< std::pair< T, V >> &vector_value, rapidjson::Document::AllocatorType &allocator)
 
template<class T , class V >
void get_value (const rapidjson::Value &json_val, std::vector< std::pair< T, V >> &vector_value)
 
template<class T , class V >
void set_value (rapidjson::Value &json_val, const std::list< std::pair< T, V >> &list_value, rapidjson::Document::AllocatorType &allocator)
 
template<class T , class V >
void get_value (const rapidjson::Value &json_val, std::list< std::pair< T, V >> &list_value)
 
template<class T , class V >
void set_value (rapidjson::Value &json_val, const std::map< T, V > &map_value, rapidjson::Document::AllocatorType &allocator)
 
template<class T , class V >
void get_value (const rapidjson::Value &json_val, std::map< T, V > &map_value)
 

Function Documentation

template<class T >
void json_utils::add_value_to_object ( rapidjson::Value &  object,
const T &  value,
const std::string &  name,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 255 of file JsonUtils.h.

References CHECK, setup::name, and set_value().

Referenced by foreign_storage::ParquetDataWrapper::getSerializedDataWrapper(), foreign_storage::AbstractTextFileDataWrapper::getSerializedDataWrapper(), foreign_storage::SingleTextFileReader::serialize(), foreign_storage::CompressedFileReader::serialize(), foreign_storage::MultiFileReader::serialize(), AlterTableAlterColumnCommandRecoveryMgr::serializeRecoveryInformation(), foreign_storage::set_value(), and set_value().

258  {
259  CHECK(object.IsObject());
260  CHECK(!object.HasMember(name)) << "Found unexpected member: " << name;
261  rapidjson::Value json_val;
262  set_value(json_val, value, allocator);
263  rapidjson::Value json_name;
264  json_name.SetString(name, allocator);
265  object.AddMember(json_name, json_val, allocator);
266 }
void set_value(rapidjson::Value &json_val, const ColumnDescriptor &column_desc, rapidjson::Document::AllocatorType &allocator)
#define CHECK(condition)
Definition: Logger.h:291
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::optional< std::string > json_utils::get_optional_string_value_from_object ( const rapidjson::Value &  object,
const std::string &  key 
)

Definition at line 232 of file JsonUtils.cpp.

Referenced by foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_data_sources().

234  {
235  if (object.IsObject() && object.HasMember(key) && object[key].IsString()) {
236  return object[key].GetString();
237  }
238  return {};
239 }

+ Here is the caller graph for this function:

std::string json_utils::get_type_as_string ( const rapidjson::Value &  object)

Definition at line 29 of file JsonUtils.cpp.

29  {
30  if (object.IsArray()) {
31  return "array";
32  } else if (object.IsBool()) {
33  return "bool";
34  } else if (object.IsDouble()) {
35  return "double";
36  } else if (object.IsFloat()) {
37  return "float";
38  } else if (object.IsInt64()) {
39  return "int64";
40  } else if (object.IsInt()) {
41  return "int";
42  } else if (object.IsNull()) {
43  return "null";
44  } else if (object.IsNumber()) {
45  return "number";
46  } else if (object.IsObject()) {
47  return "object";
48  } else if (object.IsString()) {
49  return "string";
50  } else if (object.IsUint64()) {
51  return "uint64";
52  } else if (object.IsUint()) {
53  return "uint";
54  }
55  return "unknown";
56 }
void json_utils::get_value ( const rapidjson::Value &  json_val,
size_t &  value 
)

Definition at line 64 of file JsonUtils.cpp.

References CHECK.

64  {
65  CHECK(json_val.IsUint64());
66  value = json_val.GetUint64();
67 }
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_val,
int &  value 
)

Definition at line 75 of file JsonUtils.cpp.

References CHECK.

75  {
76  CHECK(json_val.IsInt());
77  value = json_val.GetInt();
78 }
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::string &  value 
)

Definition at line 87 of file JsonUtils.cpp.

References CHECK.

87  {
88  CHECK(json_val.IsString());
89  value = json_val.GetString();
90 }
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_val,
int64_t &  value 
)

Definition at line 98 of file JsonUtils.cpp.

References CHECK.

98  {
99  CHECK(json_val.IsInt64());
100  value = json_val.GetInt64();
101 }
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_val,
bool &  value 
)

Definition at line 110 of file JsonUtils.cpp.

References CHECK.

110  {
111  CHECK(json_val.IsBool());
112  value = json_val.GetBool();
113 }
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_val,
SQLTypes value 
)

Definition at line 122 of file JsonUtils.cpp.

References CHECK.

122  {
123  CHECK(json_val.IsInt64());
124  value = static_cast<SQLTypes>(json_val.GetInt64());
125 }
SQLTypes
Definition: sqltypes.h:65
#define CHECK(condition)
Definition: Logger.h:291
template<class T >
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::vector< T > &  vector_value 
)

Definition at line 131 of file JsonUtils.h.

References CHECK, CHECK_EQ, get_value(), and heavydb.dtypes::T.

131  {
132  CHECK(json_val.IsArray());
133  CHECK_EQ(vector_value.size(), size_t(0));
134  for (const auto& json_obj : json_val.GetArray()) {
135  T val;
136  get_value(json_obj, val);
137  vector_value.push_back(val);
138  }
139 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void get_value(const rapidjson::Value &json_val, ColumnDescriptor &column_desc)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void json_utils::get_value ( const rapidjson::Value &  json_val,
EncodingType value 
)

Definition at line 134 of file JsonUtils.cpp.

References CHECK.

134  {
135  CHECK(json_val.IsInt64());
136  value = static_cast<EncodingType>(json_val.GetInt64());
137 }
EncodingType
Definition: sqltypes.h:240
#define CHECK(condition)
Definition: Logger.h:291
void json_utils::get_value ( const rapidjson::Value &  json_obj,
shared::StringDictKey dict_key 
)

Definition at line 148 of file JsonUtils.cpp.

References CHECK, shared::StringDictKey::db_id, shared::StringDictKey::dict_id, and get_value_from_object().

148  {
149  CHECK(json_obj.IsObject());
150  get_value_from_object(json_obj, dict_key.db_id, "db_id");
151  get_value_from_object(json_obj, dict_key.dict_id, "dict_id");
152 }
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

template<class T >
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::list< T > &  list_value 
)

Definition at line 155 of file JsonUtils.h.

References CHECK, CHECK_EQ, get_value(), and heavydb.dtypes::T.

155  {
156  CHECK(json_val.IsArray());
157  CHECK_EQ(list_value.size(), size_t(0));
158  for (const auto& json_obj : json_val.GetArray()) {
159  T val;
160  get_value(json_obj, val);
161  list_value.push_back(val);
162  }
163 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void get_value(const rapidjson::Value &json_val, ColumnDescriptor &column_desc)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void json_utils::get_value ( const rapidjson::Value &  json_val,
SQLTypeInfo type_info 
)

Definition at line 175 of file JsonUtils.cpp.

References CHECK, SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_compression(), SQLTypeInfo::set_dimension(), SQLTypeInfo::set_notnull(), SQLTypeInfo::set_scale(), SQLTypeInfo::set_size(), SQLTypeInfo::set_subtype(), SQLTypeInfo::set_type(), and SQLTypeInfo::setStringDictKeySkipCompParamCheck().

175  {
176  CHECK(json_val.IsObject());
177  get_value_from_object<SQLTypes>(
178  json_val, std::mem_fn(&SQLTypeInfo::set_type), type_info, "type");
179  get_value_from_object<SQLTypes>(
180  json_val, std::mem_fn(&SQLTypeInfo::set_subtype), type_info, "sub_type");
181  get_value_from_object<int>(
182  json_val, std::mem_fn(&SQLTypeInfo::set_dimension), type_info, "dimension");
183  get_value_from_object<int>(
184  json_val, std::mem_fn(&SQLTypeInfo::set_scale), type_info, "scale");
185  get_value_from_object<bool>(
186  json_val, std::mem_fn(&SQLTypeInfo::set_notnull), type_info, "notnull");
187  get_value_from_object<EncodingType>(
188  json_val, std::mem_fn(&SQLTypeInfo::set_compression), type_info, "compression");
189  get_value_from_object<int>(
190  json_val, std::mem_fn(&SQLTypeInfo::set_comp_param), type_info, "comp_param");
191  get_value_from_object<int>(
192  json_val, std::mem_fn(&SQLTypeInfo::set_size), type_info, "size");
193  get_value_from_object<shared::StringDictKey>(
194  json_val,
195  // Deserialize StringDictKey without any checks.
197  type_info,
198  "string_dict_key");
199 }
void set_compression(EncodingType c)
Definition: sqltypes.h:479
void set_size(int s)
Definition: sqltypes.h:476
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:469
void setStringDictKeySkipCompParamCheck(const shared::StringDictKey &dict_key)
Definition: sqltypes.h:1072
void set_scale(int s)
Definition: sqltypes.h:473
void set_comp_param(int p)
Definition: sqltypes.h:480
void set_dimension(int d)
Definition: sqltypes.h:470
void set_notnull(bool n)
Definition: sqltypes.h:475
#define CHECK(condition)
Definition: Logger.h:291
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:468

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::vector< std::pair< T, V >> &  vector_value 
)

Definition at line 181 of file JsonUtils.h.

References CHECK, CHECK_EQ, get_value_from_object(), and heavydb.dtypes::T.

182  {
183  CHECK(json_val.IsArray());
184  CHECK_EQ(vector_value.size(), size_t(0));
185  for (const auto& json_obj : json_val.GetArray()) {
186  CHECK(json_obj.IsObject());
187  T key;
188  V value;
189  get_value_from_object(json_obj, key, "key");
190  get_value_from_object(json_obj, value, "value");
191  vector_value.emplace_back(std::make_pair(key, value));
192  }
193 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::list< std::pair< T, V >> &  list_value 
)

Definition at line 211 of file JsonUtils.h.

References CHECK, CHECK_EQ, get_value_from_object(), and heavydb.dtypes::T.

211  {
212  CHECK(json_val.IsArray());
213  CHECK_EQ(list_value.size(), size_t(0));
214  for (const auto& json_obj : json_val.GetArray()) {
215  CHECK(json_obj.IsObject());
216  T key;
217  V value;
218  get_value_from_object(json_obj, key, "key");
219  get_value_from_object(json_obj, value, "value");
220  list_value.emplace_back(std::make_pair(key, value));
221  }
222 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::get_value ( const rapidjson::Value &  json_val,
std::map< T, V > &  map_value 
)

Definition at line 240 of file JsonUtils.h.

References CHECK, CHECK_EQ, get_value_from_object(), and heavydb.dtypes::T.

240  {
241  CHECK(json_val.IsArray());
242  CHECK_EQ(map_value.size(), size_t(0));
243  for (const auto& json_obj : json_val.GetArray()) {
244  CHECK(json_obj.IsObject());
245  T key;
246  V value;
247  get_value_from_object(json_obj, key, "key");
248  get_value_from_object(json_obj, value, "value");
249  map_value[key] = value;
250  }
251 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void json_utils::get_value ( const rapidjson::Value &  json_val,
ColumnDescriptor column_desc 
)

Definition at line 578 of file AlterColumnRecovery.cpp.

References CHECK, ColumnDescriptor::chunks, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, ColumnDescriptor::db_id, ColumnDescriptor::default_value, get_value_from_object(), ColumnDescriptor::isDeletedCol, ColumnDescriptor::isGeoPhyCol, ColumnDescriptor::isSystemCol, ColumnDescriptor::isVirtualCol, ColumnDescriptor::sourceName, ColumnDescriptor::tableId, and ColumnDescriptor::virtualExpr.

Referenced by get_value(), and get_value_from_object().

578  {
579  CHECK(json_val.IsObject());
580 
581  bool has_default_value;
582  get_value_from_object(json_val, has_default_value, "has_default_value");
583  if (has_default_value) {
584  std::string default_value;
585  get_value_from_object(json_val, default_value, "default_value_literal");
586  column_desc.default_value = default_value;
587  } else {
588  column_desc.default_value = std::nullopt;
589  }
590 
591  get_value_from_object(json_val, column_desc.chunks, "chunks");
592  get_value_from_object(json_val, column_desc.columnId, "column_id");
593  get_value_from_object(json_val, column_desc.columnName, "column_name");
594  get_value_from_object(json_val, column_desc.db_id, "db_id");
595  get_value_from_object(json_val, column_desc.isDeletedCol, "is_deleted_col");
596  get_value_from_object(json_val, column_desc.isGeoPhyCol, "is_geo_phy_col");
597  get_value_from_object(json_val, column_desc.isSystemCol, "is_system_col");
598  get_value_from_object(json_val, column_desc.isVirtualCol, "is_virtual_col");
599  get_value_from_object(json_val, column_desc.sourceName, "source_name");
600  get_value_from_object(json_val, column_desc.tableId, "table_id");
601  get_value_from_object(json_val, column_desc.virtualExpr, "virtual_expr");
602  get_value_from_object(json_val, column_desc.columnType, "column_type");
603 }
std::string virtualExpr
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270
std::string sourceName
std::string chunks
std::optional< std::string > default_value
#define CHECK(condition)
Definition: Logger.h:291
SQLTypeInfo columnType
std::string columnName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void json_utils::get_value_from_object ( const rapidjson::Value &  object,
T &  value,
const std::string &  name 
)

Definition at line 270 of file JsonUtils.h.

References CHECK, get_value(), and setup::name.

Referenced by foreign_storage::CompressedFileReader::CompressedFileReader(), AlterTableAlterColumnCommandRecoveryMgr::deserializeRecoveryInformation(), foreign_storage::get_value(), get_value(), get_value_from_object(), foreign_storage::MultiFileReader::MultiFileReader(), foreign_storage::ParquetDataWrapper::restoreDataWrapperInternals(), foreign_storage::AbstractTextFileDataWrapper::restoreDataWrapperInternals(), and foreign_storage::SingleTextFileReader::SingleTextFileReader().

272  {
273  CHECK(object.IsObject());
274  CHECK(object.HasMember(name)) << "Could not find member: " << name;
275  get_value(object[name], value);
276 }
void get_value(const rapidjson::Value &json_val, ColumnDescriptor &column_desc)
#define CHECK(condition)
Definition: Logger.h:291
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T , typename MemberFunc >
void json_utils::get_value_from_object ( const rapidjson::Value &  json_val,
MemberFunc  mem_fn,
SQLTypeInfo type_info,
const std::string &  key 
)

Definition at line 105 of file JsonUtils.h.

References get_value_from_object(), and heavydb.dtypes::T.

108  {
109  T value;
110  auto setter = std::bind(mem_fn, &type_info, std::placeholders::_1);
111  get_value_from_object(json_val, value, key);
112  setter(value);
113 }
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: JsonUtils.h:270

+ Here is the call graph for this function:

rapidjson::Document json_utils::read_from_file ( const std::string &  file_path)

Definition at line 201 of file JsonUtils.cpp.

Referenced by AlterTableAlterColumnCommandRecoveryMgr::deserializeRecoveryInformation(), foreign_storage::ParquetDataWrapper::restoreDataWrapperInternals(), and foreign_storage::AbstractTextFileDataWrapper::restoreDataWrapperInternals().

201  {
202  std::ifstream ifs(file_path);
203  if (!ifs) {
204  throw std::runtime_error{"Error trying to open file \"" + file_path +
205  "\". The error was: " + std::strerror(errno)};
206  }
207 
208  rapidjson::IStreamWrapper isw(ifs);
209  rapidjson::Document d;
210  d.ParseStream(isw);
211  return d;
212 }

+ Here is the caller graph for this function:

void json_utils::set_value ( rapidjson::Value &  json_val,
const size_t &  value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 59 of file JsonUtils.cpp.

61  {
62  json_val.SetUint64(value);
63 }
void json_utils::set_value ( rapidjson::Value &  json_val,
const int &  value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 69 of file JsonUtils.cpp.

71  {
72  json_val.SetInt(value);
73 }
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::string &  value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 80 of file JsonUtils.cpp.

82  {
83  json_val.SetString(value, allocator);
84 }
void json_utils::set_value ( rapidjson::Value &  json_val,
const int64_t &  value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 92 of file JsonUtils.cpp.

94  {
95  json_val.SetInt64(value);
96 }
void json_utils::set_value ( rapidjson::Value &  json_val,
const bool &  value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 104 of file JsonUtils.cpp.

106  {
107  json_val.SetBool(value);
108 }
void json_utils::set_value ( rapidjson::Value &  json_val,
const SQLTypes value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 116 of file JsonUtils.cpp.

118  {
119  json_val.SetInt64(static_cast<int64_t>(value));
120 }
template<class T >
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::vector< T > &  vector_value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 119 of file JsonUtils.h.

References set_value().

121  {
122  json_val.SetArray();
123  for (const auto& value : vector_value) {
124  rapidjson::Value json_obj;
125  set_value(json_obj, value, allocator);
126  json_val.PushBack(json_obj, allocator);
127  }
128 }
void set_value(rapidjson::Value &json_val, const ColumnDescriptor &column_desc, rapidjson::Document::AllocatorType &allocator)

+ Here is the call graph for this function:

void json_utils::set_value ( rapidjson::Value &  json_val,
const EncodingType value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 128 of file JsonUtils.cpp.

130  {
131  json_val.SetInt64(static_cast<int64_t>(value));
132 }
void json_utils::set_value ( rapidjson::Value &  json_obj,
const shared::StringDictKey dict_key,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 140 of file JsonUtils.cpp.

References add_value_to_object(), shared::StringDictKey::db_id, and shared::StringDictKey::dict_id.

142  {
143  json_obj.SetObject();
144  add_value_to_object(json_obj, dict_key.db_id, "db_id", allocator);
145  add_value_to_object(json_obj, dict_key.dict_id, "dict_id", allocator);
146 }
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255

+ Here is the call graph for this function:

template<class T >
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::list< T > &  list_value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 143 of file JsonUtils.h.

References set_value().

145  {
146  json_val.SetArray();
147  for (const auto& value : list_value) {
148  rapidjson::Value json_obj;
149  set_value(json_obj, value, allocator);
150  json_val.PushBack(json_obj, allocator);
151  }
152 }
void set_value(rapidjson::Value &json_val, const ColumnDescriptor &column_desc, rapidjson::Document::AllocatorType &allocator)

+ Here is the call graph for this function:

void json_utils::set_value ( rapidjson::Value &  json_val,
const SQLTypeInfo type_info,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 155 of file JsonUtils.cpp.

References add_value_to_object(), SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_size(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), and SQLTypeInfo::getStringDictKeySkipCompParamCheck().

157  {
158  json_val.SetObject();
159  add_value_to_object(json_val, type_info.get_type(), "type", allocator);
160  add_value_to_object(json_val, type_info.get_subtype(), "sub_type", allocator);
161  add_value_to_object(json_val, type_info.get_dimension(), "dimension", allocator);
162  add_value_to_object(json_val, type_info.get_scale(), "scale", allocator);
163  add_value_to_object(json_val, type_info.get_notnull(), "notnull", allocator);
164  add_value_to_object(json_val, type_info.get_compression(), "compression", allocator);
165  add_value_to_object(json_val, type_info.get_comp_param(), "comp_param", allocator);
166  add_value_to_object(json_val, type_info.get_size(), "size", allocator);
167  add_value_to_object(json_val,
168  // Serialize StringDictKey without any checks, since the string
169  // dictionary ID may not be set at this point.
171  "string_dict_key",
172  allocator);
173 }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:392
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
const shared::StringDictKey & getStringDictKeySkipCompParamCheck() const
Definition: sqltypes.h:1068
HOST DEVICE int get_scale() const
Definition: sqltypes.h:396
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:393
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::vector< std::pair< T, V >> &  vector_value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 167 of file JsonUtils.h.

References add_value_to_object().

169  {
170  json_val.SetArray();
171  for (const auto& pair : vector_value) {
172  rapidjson::Value pair_obj;
173  pair_obj.SetObject();
174  add_value_to_object(pair_obj, pair.first, "key", allocator);
175  add_value_to_object(pair_obj, pair.second, "value", allocator);
176  json_val.PushBack(pair_obj, allocator);
177  }
178 }
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::list< std::pair< T, V >> &  list_value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 197 of file JsonUtils.h.

References add_value_to_object().

199  {
200  json_val.SetArray();
201  for (const auto& pair : list_value) {
202  rapidjson::Value pair_obj;
203  pair_obj.SetObject();
204  add_value_to_object(pair_obj, pair.first, "key", allocator);
205  add_value_to_object(pair_obj, pair.second, "value", allocator);
206  json_val.PushBack(pair_obj, allocator);
207  }
208 }
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255

+ Here is the call graph for this function:

template<class T , class V >
void json_utils::set_value ( rapidjson::Value &  json_val,
const std::map< T, V > &  map_value,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 226 of file JsonUtils.h.

References add_value_to_object().

228  {
229  json_val.SetArray();
230  for (const auto& pair : map_value) {
231  rapidjson::Value pair_obj;
232  pair_obj.SetObject();
233  add_value_to_object(pair_obj, pair.first, "key", allocator);
234  add_value_to_object(pair_obj, pair.second, "value", allocator);
235  json_val.PushBack(pair_obj, allocator);
236  }
237 }
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255

+ Here is the call graph for this function:

void json_utils::set_value ( rapidjson::Value &  json_val,
const ColumnDescriptor column_desc,
rapidjson::Document::AllocatorType &  allocator 
)

Definition at line 552 of file AlterColumnRecovery.cpp.

References add_value_to_object(), ColumnDescriptor::chunks, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, ColumnDescriptor::db_id, ColumnDescriptor::default_value, ColumnDescriptor::isDeletedCol, ColumnDescriptor::isGeoPhyCol, ColumnDescriptor::isSystemCol, ColumnDescriptor::isVirtualCol, ColumnDescriptor::sourceName, ColumnDescriptor::tableId, and ColumnDescriptor::virtualExpr.

Referenced by add_value_to_object(), and set_value().

554  {
555  json_val.SetObject();
556  auto default_value = column_desc.default_value;
557  if (default_value.has_value()) {
558  add_value_to_object(json_val, true, "has_default_value", allocator);
560  json_val, default_value.value(), "default_value_literal", allocator);
561  } else {
562  add_value_to_object(json_val, false, "has_default_value", allocator);
563  }
564  add_value_to_object(json_val, column_desc.chunks, "chunks", allocator);
565  add_value_to_object(json_val, column_desc.columnId, "column_id", allocator);
566  add_value_to_object(json_val, column_desc.columnName, "column_name", allocator);
567  add_value_to_object(json_val, column_desc.columnType, "column_type", allocator);
568  add_value_to_object(json_val, column_desc.db_id, "db_id", allocator);
569  add_value_to_object(json_val, column_desc.isDeletedCol, "is_deleted_col", allocator);
570  add_value_to_object(json_val, column_desc.isGeoPhyCol, "is_geo_phy_col", allocator);
571  add_value_to_object(json_val, column_desc.isSystemCol, "is_system_col", allocator);
572  add_value_to_object(json_val, column_desc.isVirtualCol, "is_virtual_col", allocator);
573  add_value_to_object(json_val, column_desc.sourceName, "source_name", allocator);
574  add_value_to_object(json_val, column_desc.tableId, "table_id", allocator);
575  add_value_to_object(json_val, column_desc.virtualExpr, "virtual_expr", allocator);
576 }
std::string virtualExpr
std::string sourceName
std::string chunks
std::optional< std::string > default_value
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: JsonUtils.h:255
SQLTypeInfo columnType
std::string columnName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void json_utils::write_to_file ( const rapidjson::Document &  document,
const std::string &  filepath 
)

Definition at line 214 of file JsonUtils.cpp.

214  {
215  std::ofstream ofs(filepath);
216  if (!ofs) {
217  throw std::runtime_error{"Error trying to create file \"" + filepath +
218  "\". The error was: " + std::strerror(errno)};
219  }
220  rapidjson::OStreamWrapper osw(ofs);
221  rapidjson::Writer<rapidjson::OStreamWrapper> writer(osw);
222  document.Accept(writer);
223 }
std::string json_utils::write_to_string ( const rapidjson::Document &  document)

Definition at line 225 of file JsonUtils.cpp.

Referenced by foreign_storage::ParquetDataWrapper::getSerializedDataWrapper(), foreign_storage::AbstractTextFileDataWrapper::getSerializedDataWrapper(), and AlterTableAlterColumnCommandRecoveryMgr::serializeRecoveryInformation().

225  {
226  rapidjson::StringBuffer buffer;
227  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
228  document.Accept(writer);
229  return buffer.GetString();
230 }

+ Here is the caller graph for this function: