diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 13:26:22 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 15:44:45 +0300 |
commit | 0a98fece5a9b54f16afeb3a94b3eb3105e9c3962 (patch) | |
tree | 291d72dbd7e9865399f668c84d11ed86fb190bbf /library/cpp/on_disk/multi_blob/multiblob_builder.h | |
parent | cb2c8d75065e5b3c47094067cb4aa407d4813298 (diff) | |
download | ydb-0a98fece5a9b54f16afeb3a94b3eb3105e9c3962.tar.gz |
YQ Connector:Use docker-compose in integrational tests
Diffstat (limited to 'library/cpp/on_disk/multi_blob/multiblob_builder.h')
-rw-r--r-- | library/cpp/on_disk/multi_blob/multiblob_builder.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/library/cpp/on_disk/multi_blob/multiblob_builder.h b/library/cpp/on_disk/multi_blob/multiblob_builder.h new file mode 100644 index 0000000000..a8e3c6d35e --- /dev/null +++ b/library/cpp/on_disk/multi_blob/multiblob_builder.h @@ -0,0 +1,64 @@ +#pragma once + +#include <util/system/align.h> +#include <util/stream/output.h> +#include <util/stream/file.h> +#include <util/draft/holder_vector.h> + +#include "multiblob.h" + +class IBlobSaverBase { +public: + virtual ~IBlobSaverBase() { + } + virtual void Save(IOutputStream& output, ui32 flags = 0) = 0; + virtual size_t GetLength() = 0; +}; + +inline void MultiBlobSave(IOutputStream& output, IBlobSaverBase& saver) { + saver.Save(output); +} + +class TBlobSaverMemory: public IBlobSaverBase { +public: + TBlobSaverMemory(const void* ptr, size_t size); + TBlobSaverMemory(const TBlob& blob); + void Save(IOutputStream& output, ui32 flags = 0) override; + size_t GetLength() override; + +private: + TBlob Blob; +}; + +class TBlobSaverFile: public IBlobSaverBase { +public: + TBlobSaverFile(TFile file); + TBlobSaverFile(const char* filename, EOpenMode oMode = RdOnly); + void Save(IOutputStream& output, ui32 flags = 0) override; + size_t GetLength() override; + +protected: + TFile File; +}; + +class TMultiBlobBuilder: public IBlobSaverBase { +protected: + // Data will be stored with default alignment DEVTOOLS-4548 + static const size_t ALIGN = 16; + +public: + typedef TVector<IBlobSaverBase*> TSavers; + + TMultiBlobBuilder(bool isOwn = true); + ~TMultiBlobBuilder() override; + void Save(IOutputStream& output, ui32 flags = 0) override; + size_t GetLength() override; + TSavers& GetBlobs(); + const TSavers& GetBlobs() const; + void AddBlob(IBlobSaverBase* blob); + void DeleteSubBlobs(); + +protected: + TSavers Blobs; + bool IsOwner; +}; |