24#ifndef DD_SERIALIZE_IMPL_H_INCLUDED 
   25#define DD_SERIALIZE_IMPL_H_INCLUDED 
   30#include <rapidjson/document.h>       
   31#include <rapidjson/prettywriter.h>   
  216template <
typename T, 
size_t PREALLOC = 16>
 
  241template <
typename GV>
 
  255template <
typename GV>
 
  269template <
typename GV>
 
  283template <
typename GV>
 
  285  if (!gv.IsUint64()) {
 
  288  *ap = gv.GetUint64();
 
  297template <
typename GV>
 
  299  if (!gv.IsUint64()) {
 
  302  *ap = gv.GetUint64();
 
  308  w->String(a.c_str(), a.size());
 
  311template <
typename GV>
 
  313  if (!gv.IsString()) {
 
  334template <
typename W, 
typename T>
 
  335void write(W *w, 
const T &t, 
const char *
key, 
size_t key_sz) {
 
  336  w->String(
key, key_sz);
 
  340template <
typename T, 
typename GV>
 
  342  if (!gv.HasMember(
key)) {
 
  361template <
typename W, 
typename ENUM_T>
 
  366template <
typename ENUM_T, 
typename GV>
 
  372  *ep = 
static_cast<ENUM_T
>(v);
 
  378                  const char *
key, 
size_t keysz) {
 
  379  int binsz = 
static_cast<int>(b.size());
 
  386  w->String(
key, keysz);
 
  390template <
typename GV>
 
  393  if (!gv.HasMember(
key)) {
 
  397  const GV &a_gv = gv[
key];
 
  399  if (!a_gv.IsString()) {
 
  403  const char *b64 = a_gv.GetString();
 
  404  size_t b64sz = a_gv.GetStringLength();
 
  413template <
typename W, 
typename PP>
 
  418template <
typename PP, 
typename GV>
 
  421  if (
read(&raw_string, gv, 
key)) {
 
  424  p->insert_values(raw_string);
 
  428template <
typename W, 
typename PP>
 
  432    assert(
p->ordinal_position() > 0);
 
  433    opx = 
p->ordinal_position() - 1;
 
  438template <
typename PP, 
typename GV>
 
  449template <
typename GV>
 
  451                            const GV &gv, 
const char *
key) {
 
  453  return (
read(&schema_name, gv, 
key) ||
 
  469  if (tablespace_name.empty()) {
 
  472  write(w, tablespace_name, 
key, keysz);
 
  475template <
typename GV>
 
  477                                const GV &gv, 
const char *
key) {
 
  479  if (
read(&tablespace_name, gv, 
key)) {
 
  485template <
typename W, 
typename C>
 
  487                    const char *
key, 
size_t keysz) {
 
  488  w->String(
key, keysz);
 
  490  for (
const C *vp : cp) {
 
  491    vp->serialize(wctx, w);
 
  493  w->EndArray(cp.
size());
 
  496template <
typename ADD_BINDER, 
typename GV>
 
  498                      const GV &obj_gv, 
const char *
key) {
 
  499  if (!obj_gv.HasMember(
key)) {
 
  503  const GV &array_gv = obj_gv[
key];
 
  504  if (!array_gv.IsArray()) {
 
  508  const typename GV::ConstValueIterator 
end = array_gv.End();
 
  509  for (
typename GV::ConstValueIterator it = array_gv.Begin(); it != 
end; ++it) {
 
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
 
Definition: collection.h:44
 
size_t size() const
Definition: collection.h:229
 
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
 
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:231
 
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:129
 
const char * p
Definition: ctype-mb.cc:1227
 
bool read(T *ap, const GV &gv, const char *key)
Definition: sdi_impl.h:341
 
void write(W *w, const T &t, const char *key, size_t key_sz)
Definition: sdi_impl.h:335
 
dd::String_type binary_t
Definition: sdi_impl.h:215
 
dd_vector< char, 32 > Byte_buffer
Definition: sdi_impl.h:222
 
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
 
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:475
 
bool read_properties(PP *p, const GV &gv, const char *key)
Definition: sdi_impl.h:419
 
void serialize_each(dd::Sdi_wcontext *wctx, W *w, const dd::Collection< C * > &cp, const char *key, size_t keysz)
Definition: sdi_impl.h:486
 
bool read_opx_reference(dd::Sdi_rcontext *rctx, PP *p, const GV &gv, const char *key)
Definition: sdi_impl.h:439
 
bool deserialize_each(dd::Sdi_rcontext *rctx, ADD_BINDER add_binder, const GV &obj_gv, const char *key)
Definition: sdi_impl.h:497
 
bool read_enum(ENUM_T *ep, const GV &gv, const char *key)
Definition: sdi_impl.h:367
 
void write_binary(dd::Sdi_wcontext *wctx, W *w, const binary_t &b, const char *key, size_t keysz)
Definition: sdi_impl.h:377
 
bool deserialize_schema_ref(dd::Sdi_rcontext *rctx, dd::Object_id *p, const GV &gv, const char *key)
Definition: sdi_impl.h:450
 
bool deserialize_tablespace_ref(dd::Sdi_rcontext *rctx, dd::Object_id *p, const GV &gv, const char *key)
Definition: sdi_impl.h:476
 
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:458
 
void write_opx_reference(W *w, const PP &p, const char *key, size_t keysz)
Definition: sdi_impl.h:429
 
bool read_binary(dd::Sdi_rcontext *rctx, binary_t *b, const GV &gv, const char *key)
Definition: sdi_impl.h:391
 
void write_enum(W *w, ENUM_T enum_val, const char *key, size_t keysz)
Definition: sdi_impl.h:362
 
void write_properties(W *w, const PP &p, const char *key, size_t keysz)
Definition: sdi_impl.h:414
 
bool read_value(bool *ap, const GV &gv)
Definition: sdi_impl.h:242
 
void write_value(W *w, bool a)
Definition: sdi_impl.h:237
 
static uint64 base64_needed_decoded_length(uint64 length_of_encoded_data)
Definition: base64.h:227
 
static uint64 base64_needed_encoded_length(uint64 length_of_data)
Definition: base64.h:203
 
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:304
 
static int base64_encode(const void *src, size_t src_len, char *dst)
Definition: base64.h:243
 
#define T
Definition: jit_executor_value.cc:373
 
unsigned long long int ulonglong
Definition: my_inttypes.h:56
 
Define rapidjson::SizeType to be std::uint64_t.
 
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1078
 
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
 
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:189
 
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:298
 
unsigned long long Object_id
Definition: object_id.h:31
 
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:341
 
const String_type & lookup_schema_name(Sdi_wcontext *wctx)
Returns const reference to string holding schema name to use in SDI.
Definition: sdi.cc:157
 
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:153
 
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:37
 
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:348
 
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:290
 
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
 
Properties * parse_properties(const String_type &str)
Factory function for creating a Property object from String_type.
 
entry::Column Column
Definition: select.h:53
 
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
 
required string key
Definition: replication_asynchronous_connection_failover.proto:60
 
case opt name
Definition: sslopt-case.h:29
 
Definition: sdi_impl.h:217
 
dd_vector(PSI_memory_key psi_key=0)
Definition: sdi_impl.h:218