rippled
|
Convert a NodeObject from in-memory to database format. More...
Public Member Functions | |
EncodedBlob (std::shared_ptr< NodeObject > const &obj) | |
~EncodedBlob () | |
void const * | getKey () const noexcept |
std::size_t | getSize () const noexcept |
void const * | getData () const noexcept |
Private Attributes | |
std::array< std::uint8_t, 32 > | key_ |
The 32-byte key of the serialized object. More... | |
std::array< std::uint8_t, boost::alignment::align_up(9+1024, alignof(std::uint32_t))> | payload_ |
A pre-allocated buffer for the serialized object. More... | |
std::uint32_t | size_ |
The size of the serialized data. More... | |
std::uint8_t *const | ptr_ |
A pointer to the serialized data. More... | |
Convert a NodeObject from in-memory to database format.
The (suboptimal) database format consists of:
We leverage that fact to preallocate enough memory to handle most payloads as part of this object, eliminating the need for dynamic allocation. As of this writing ~94% of objects require fewer than 1024 payload bytes.
Definition at line 54 of file EncodedBlob.h.
|
explicit |
Definition at line 81 of file EncodedBlob.h.
ripple::NodeStore::EncodedBlob::~EncodedBlob | ( | ) |
Definition at line 101 of file EncodedBlob.h.
|
noexcept |
Definition at line 112 of file EncodedBlob.h.
|
noexcept |
Definition at line 118 of file EncodedBlob.h.
|
noexcept |
Definition at line 124 of file EncodedBlob.h.
|
private |
The 32-byte key of the serialized object.
Definition at line 57 of file EncodedBlob.h.
|
private |
A pre-allocated buffer for the serialized object.
The buffer is large enough for the 9 byte prefix and at least 1024 more bytes. The precise size is calculated automatically at compile time so as to avoid wasting space on padding bytes.
Definition at line 68 of file EncodedBlob.h.
|
private |
The size of the serialized data.
Definition at line 71 of file EncodedBlob.h.
|
private |
A pointer to the serialized data.
This may point to the pre-allocated buffer (if it is sufficiently large) or to a dynamically allocated buffer.
Definition at line 78 of file EncodedBlob.h.