MySQL 8.3.0
Source Code Documentation
Json_diff_vector Class Reference

Vector of logical diffs describing changes to a JSON column. More...

#include <json_diff.h>

Public Types

typedef Mem_root_allocator< Json_diffallocator_type
 Type of the allocator for the underlying invector. More...
 
typedef std::vector< Json_diff, allocator_typevector
 Type of the underlying vector. More...
 
typedef vector::iterator iterator
 Type of iterator over the underlying vector. More...
 
typedef vector::const_iterator const_iterator
 Type of iterator over the underlying vector. More...
 

Public Member Functions

 Json_diff_vector (allocator_type arg)
 Constructor. More...
 
void add_diff (Json_diff diff)
 Append a new diff at the end of this vector. More...
 
void add_diff (const Json_seekable_path &path, enum_json_diff_operation operation, std::unique_ptr< Json_dom > dom)
 Append a new diff at the end of this vector. More...
 
void add_diff (const Json_seekable_path &path, enum_json_diff_operation operation)
 Append a new diff at the end of this vector when operation == REMOVE. More...
 
void clear ()
 Clear the vector. More...
 
size_t size () const
 Return the number of elements in the vector. More...
 
Json_diffat (size_t pos)
 Return the element at the given position. More...
 
const_iterator begin () const
 
const_iterator end () const
 
size_t binary_length (bool include_metadata=true) const
 Return the length of the binary representation of this Json_diff_vector. More...
 
bool write_binary (String *to) const
 Serialize this Json_diff_vector into the given String. More...
 
bool read_binary (const char **from, const struct TABLE *table, const char *field_name)
 De-serialize Json_diff objects from the given String into this Json_diff_vector. More...
 

Static Public Attributes

static const Json_diff_vector EMPTY_JSON_DIFF_VECTOR
 An empty diff vector (having no diffs). More...
 

Private Attributes

vector m_vector
 
size_t m_binary_length
 Length in bytes of the binary representation, not counting the 4 bytes length. More...
 

Static Private Attributes

static const size_t ENCODED_LENGTH_BYTES = 4
 The length of the field where the total length is encoded. More...
 

Detailed Description

Vector of logical diffs describing changes to a JSON column.

Member Typedef Documentation

◆ allocator_type

Type of the allocator for the underlying invector.

◆ const_iterator

typedef vector::const_iterator Json_diff_vector::const_iterator

Type of iterator over the underlying vector.

◆ iterator

typedef vector::iterator Json_diff_vector::iterator

Type of iterator over the underlying vector.

◆ vector

Type of the underlying vector.

Constructor & Destructor Documentation

◆ Json_diff_vector()

Json_diff_vector::Json_diff_vector ( allocator_type  arg)
explicit

Constructor.

Parameters
argMem_root_allocator to use for the vector

Member Function Documentation

◆ add_diff() [1/3]

void Json_diff_vector::add_diff ( const Json_seekable_path path,
enum_json_diff_operation  operation 
)

Append a new diff at the end of this vector when operation == REMOVE.

Parameters
pathPath to update
operationOperation

◆ add_diff() [2/3]

void Json_diff_vector::add_diff ( const Json_seekable_path path,
enum_json_diff_operation  operation,
std::unique_ptr< Json_dom dom 
)

Append a new diff at the end of this vector.

Parameters
pathPath to update
operationOperation
domNew value to insert

◆ add_diff() [3/3]

void Json_diff_vector::add_diff ( Json_diff  diff)

Append a new diff at the end of this vector.

Parameters
diffThe diff to add.

◆ at()

Json_diff & Json_diff_vector::at ( size_t  pos)
inline

Return the element at the given position.

Parameters
posPosition
Returns
the pos'th element

◆ begin()

const_iterator Json_diff_vector::begin ( ) const
inline

◆ binary_length()

size_t Json_diff_vector::binary_length ( bool  include_metadata = true) const

Return the length of the binary representation of this Json_diff_vector.

The binary format has this form:

+--------+--------+--------+     +--------+
| length | diff_1 | diff_2 | ... | diff_N |
+--------+--------+--------+     +--------+

This function returns the length of only the diffs, if include_metadata==false. It returns the length of the 'length' field plus the length of the diffs, if include_metadata=true. The value of the 'length' field is exactly the return value from this function when include_metadata=false.

Parameters
include_metadataif true, include the length of the length field in the computation, otherwise don't.
Returns
The computed length

◆ clear()

void Json_diff_vector::clear ( )

Clear the vector.

◆ end()

const_iterator Json_diff_vector::end ( ) const
inline

◆ read_binary()

bool Json_diff_vector::read_binary ( const char **  from,
const struct TABLE table,
const char *  field_name 
)

De-serialize Json_diff objects from the given String into this Json_diff_vector.

Parameters
[in,out]fromPointer to buffer to read from. The function will move this to point to the next byte to read after those that were read.
[in]tableTable structure (used for error messages).
[in]field_nameField name (used for error messages).
Return values
falseSuccess
trueFailure (bad format or out of memory)

◆ size()

size_t Json_diff_vector::size ( ) const
inline

Return the number of elements in the vector.

◆ write_binary()

bool Json_diff_vector::write_binary ( String to) const

Serialize this Json_diff_vector into the given String.

Parameters
toString to which the vector will be appended
Return values
falseSuccess
trueFailure (out of memory)

Member Data Documentation

◆ EMPTY_JSON_DIFF_VECTOR

const Json_diff_vector Json_diff_vector::EMPTY_JSON_DIFF_VECTOR
static
Initial value:
{
Mem_root_allocator is a C++ STL memory allocator based on MEM_ROOT.
Definition: mem_root_allocator.h:67
static MEM_ROOT empty_json_diff_vector_mem_root(PSI_NOT_INSTRUMENTED, 256)

An empty diff vector (having no diffs).

◆ ENCODED_LENGTH_BYTES

const size_t Json_diff_vector::ENCODED_LENGTH_BYTES = 4
staticprivate

The length of the field where the total length is encoded.

◆ m_binary_length

size_t Json_diff_vector::m_binary_length
private

Length in bytes of the binary representation, not counting the 4 bytes length.

◆ m_vector

vector Json_diff_vector::m_vector
private

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