23#ifndef DD_SERIALIZE_IMPL_H_INCLUDED
24#define DD_SERIALIZE_IMPL_H_INCLUDED
29#include <rapidjson/document.h>
30#include <rapidjson/prettywriter.h>
215template <
typename T,
size_t PREALLOC = 16>
240template <
typename GV>
254template <
typename GV>
268template <
typename GV>
282template <
typename GV>
284 if (!gv.IsUint64()) {
287 *ap = gv.GetUint64();
296template <
typename GV>
298 if (!gv.IsUint64()) {
301 *ap = gv.GetUint64();
307 w->String(a.c_str(), a.size());
310template <
typename GV>
312 if (!gv.IsString()) {
333template <
typename W,
typename T>
334void write(W *w,
const T &t,
const char *
key,
size_t key_sz) {
335 w->String(
key, key_sz);
339template <
typename T,
typename GV>
340bool read(T *ap,
const GV &gv,
const char *
key) {
341 if (!gv.HasMember(
key)) {
360template <
typename W,
typename ENUM_T>
365template <
typename ENUM_T,
typename GV>
371 *ep =
static_cast<ENUM_T
>(v);
377 const char *
key,
size_t keysz) {
378 int binsz =
static_cast<int>(b.size());
385 w->String(
key, keysz);
389template <
typename GV>
392 if (!gv.HasMember(
key)) {
396 const GV &a_gv = gv[
key];
398 if (!a_gv.IsString()) {
402 const char *b64 = a_gv.GetString();
403 size_t b64sz = a_gv.GetStringLength();
412template <
typename W,
typename PP>
417template <
typename PP,
typename GV>
420 if (
read(&raw_string, gv,
key)) {
423 p->insert_values(raw_string);
427template <
typename W,
typename PP>
431 assert(
p->ordinal_position() > 0);
432 opx =
p->ordinal_position() - 1;
437template <
typename PP,
typename GV>
448template <
typename GV>
450 const GV &gv,
const char *
key) {
452 return (
read(&schema_name, gv,
key) ||
468 if (tablespace_name.empty()) {
471 write(w, tablespace_name,
key, keysz);
474template <
typename GV>
476 const GV &gv,
const char *
key) {
478 if (
read(&tablespace_name, gv,
key)) {
484template <
typename W,
typename C>
486 const char *
key,
size_t keysz) {
487 w->String(
key, keysz);
489 for (
const C *vp : cp) {
490 vp->serialize(wctx, w);
492 w->EndArray(cp.
size());
495template <
typename ADD_BINDER,
typename GV>
497 const GV &obj_gv,
const char *
key) {
498 if (!obj_gv.HasMember(
key)) {
502 const GV &array_gv = obj_gv[
key];
503 if (!array_gv.IsArray()) {
507 const typename GV::ConstValueIterator
end = array_gv.End();
508 for (
typename GV::ConstValueIterator it = array_gv.Begin(); it !=
end; ++it) {
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:70
Definition: collection.h:43
size_t size() const
Definition: collection.h:228
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:73
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:230
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:128
const char * p
Definition: ctype-mb.cc:1234
bool read(T *ap, const GV &gv, const char *key)
Definition: sdi_impl.h:340
void write(W *w, const T &t, const char *key, size_t key_sz)
Definition: sdi_impl.h:334
dd::String_type binary_t
Definition: sdi_impl.h:214
dd_vector< char, 32 > Byte_buffer
Definition: sdi_impl.h:221
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
bool deserialize(THD *thd, const Sdi_type &sdi, Table *dst_table, SdiCompatibilityChecker comp_checker, String_type *deser_schema_name)
Deserialize a dd::Table object.
Definition: sdi.cc:474
bool read_properties(PP *p, const GV &gv, const char *key)
Definition: sdi_impl.h:418
void serialize_each(dd::Sdi_wcontext *wctx, W *w, const dd::Collection< C * > &cp, const char *key, size_t keysz)
Definition: sdi_impl.h:485
bool read_opx_reference(dd::Sdi_rcontext *rctx, PP *p, const GV &gv, const char *key)
Definition: sdi_impl.h:438
bool deserialize_each(dd::Sdi_rcontext *rctx, ADD_BINDER add_binder, const GV &obj_gv, const char *key)
Definition: sdi_impl.h:496
bool read_enum(ENUM_T *ep, const GV &gv, const char *key)
Definition: sdi_impl.h:366
void write_binary(dd::Sdi_wcontext *wctx, W *w, const binary_t &b, const char *key, size_t keysz)
Definition: sdi_impl.h:376
bool deserialize_schema_ref(dd::Sdi_rcontext *rctx, dd::Object_id *p, const GV &gv, const char *key)
Definition: sdi_impl.h:449
bool deserialize_tablespace_ref(dd::Sdi_rcontext *rctx, dd::Object_id *p, const GV &gv, const char *key)
Definition: sdi_impl.h:475
void serialize_tablespace_ref(dd::Sdi_wcontext *wctx, W *w, dd::Object_id tablespace_id, const char *key, size_t keysz)
Definition: sdi_impl.h:457
void write_opx_reference(W *w, const PP &p, const char *key, size_t keysz)
Definition: sdi_impl.h:428
bool read_binary(dd::Sdi_rcontext *rctx, binary_t *b, const GV &gv, const char *key)
Definition: sdi_impl.h:390
void write_enum(W *w, ENUM_T enum_val, const char *key, size_t keysz)
Definition: sdi_impl.h:361
void write_properties(W *w, const PP &p, const char *key, size_t keysz)
Definition: sdi_impl.h:413
bool read_value(bool *ap, const GV &gv)
Definition: sdi_impl.h:241
void write_value(W *w, bool a)
Definition: sdi_impl.h:236
static uint64 base64_needed_decoded_length(uint64 length_of_encoded_data)
Definition: base64.h:234
static uint64 base64_needed_encoded_length(uint64 length_of_data)
Definition: base64.h:202
static int64 base64_decode(const char *src_base, size_t len, void *dst, const char **end_ptr, int flags)
Decode a base64 string The base64-encoded data in the range ['src','*end_ptr') will be decoded and st...
Definition: base64.h:315
static int base64_encode(const void *src, size_t src_len, char *dst)
Definition: base64.h:254
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Define rapidjson::SizeType to be std::size_t.
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1063
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
const String_type & lookup_tablespace_name(Sdi_wcontext *wctx, dd::Object_id id)
Look up the tablespace name for a tablespace id.
Definition: sdi.cc:188
Index * get_by_opx(dd::Sdi_rcontext *sdictx, const Index *, uint opx)
Return an non-owning raw pointer to the deserialized Index object with ordinal position index opx (or...
Definition: sdi.cc:297
unsigned long long Object_id
Definition: object_id.h:30
bool lookup_schema_ref(Sdi_rcontext *sdictx, const String_type &name, dd::Object_id *idp)
Return the the Object_id of a schema name in the current data dictionary.
Definition: sdi.cc:340
const String_type & lookup_schema_name(Sdi_wcontext *wctx)
Returns const reference to string holding schema name to use in SDI.
Definition: sdi.cc:156
char * buf_handle(Sdi_wcontext *wctx, size_t sz)
Return a non-owning pointer to a char buffer which can be used for e.g.
Definition: sdi.cc:152
const Object_id INVALID_OBJECT_ID
The default object ID which represents that the DD object is new and not persistent in dictionary tab...
Definition: object_id.h:36
bool lookup_tablespace_ref(Sdi_rcontext *sdictx, const String_type &name, Object_id *idp)
Return the the Object_id of a tablespace name in the current data dictionary.
Definition: sdi.cc:347
void track_object(Sdi_rcontext *sdictx, Column *column_object)
Register Column objects being deserialized so that it will be possible to resolve references to it af...
Definition: sdi.cc:289
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Properties * parse_properties(const String_type &str)
Factory function for creating a Property object from String_type.
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
required string key
Definition: replication_asynchronous_connection_failover.proto:59
case opt name
Definition: sslopt-case.h:32
Definition: sdi_impl.h:216
dd_vector(PSI_memory_key psi_key=0)
Definition: sdi_impl.h:217