diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-02 01:45:21 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-02 02:42:50 +0300 |
commit | 9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c (patch) | |
tree | 9f88a486917d371d099cd712efd91b4c122d209d /library/cpp/on_disk/multi_blob/multiblob.h | |
parent | 32fb6dda1feb24f9ab69ece5df0cb9ec238ca5e6 (diff) | |
download | ydb-9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp/on_disk/multi_blob/multiblob.h')
-rw-r--r-- | library/cpp/on_disk/multi_blob/multiblob.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/library/cpp/on_disk/multi_blob/multiblob.h b/library/cpp/on_disk/multi_blob/multiblob.h new file mode 100644 index 0000000000..b40a5ae6af --- /dev/null +++ b/library/cpp/on_disk/multi_blob/multiblob.h @@ -0,0 +1,77 @@ +#pragma once + +#include <util/generic/vector.h> +#include <util/memory/blob.h> + +#define BLOBMETASIG 0x3456789Au + +enum E_Multiblob_Flags { + // if EMF_INTERLAY is clear + // multiblob format + // HeaderSize() bytes for TMultiBlobHeader + // Count*sizeof(ui64) bytes for blob sizes + // blob1 + // (alignment) + // blob2 + // (alignment) + // ... + // (alignment) + // blobn + // if EMF_INTERLAY is set + // multiblob format + // HeaderSize() bytes for TMultiBlobHeader + // size1 ui64, the size of 1st blob + // blob1 + // (alignment) + // size2 ui64, the size of 2nd blob + // blob2 + // (alignment) + // ... + // (alignment) + // sizen ui64, the size of n'th blob + // blobn + EMF_INTERLAY = 1, + + // Means that multiblob contains blocks in TChunkedDataReader format + // Legacy, use it only for old files, created for TChunkedDataReader + EMF_CHUNKED_DATA_READER = 2, + + // Flags that may be configured for blobbuilder in client code + EMF_WRITEABLE = EMF_INTERLAY, +}; + +struct TMultiBlobHeader { + // data + ui32 BlobMetaSig; + ui32 BlobRecordSig; + ui64 Count; // count of sub blobs + ui32 Align; // alignment for every subblob + ui32 Flags; + static const ui32 RecordSig = 0x23456789; + static inline size_t HeaderSize() { + return 4 * sizeof(ui64); + } + inline const ui64* Sizes(const void* Data) const { + return (const ui64*)((const char*)Data + HeaderSize()); + } +}; + +class TSubBlobs: public TVector<TBlob> { +public: + TSubBlobs() { + } + TSubBlobs(const TBlob& multi) { + ReadMultiBlob(multi); + } + void ReadMultiBlob(const TBlob& multi); + const TMultiBlobHeader* GetHeader() const { + return (const TMultiBlobHeader*)&Header; + } + +protected: + TMultiBlobHeader Header; + TBlob Multi; + +private: + bool ReadChunkedData(const TBlob& multi) noexcept; +}; |