diff options
author | iddqd <iddqd@yandex-team.com> | 2024-06-05 13:17:15 +0300 |
---|---|---|
committer | iddqd <iddqd@yandex-team.com> | 2024-06-05 13:27:30 +0300 |
commit | b942cd0f5ca4da903e5e203a90084fecc88076d0 (patch) | |
tree | 10e412736e495d78da1cc11837927787e7a07f3d /library/cpp/streams/lz/lz4/block.h | |
parent | 64fd7c655b5e03378dbd4225db5deae4493bc347 (diff) | |
download | ydb-b942cd0f5ca4da903e5e203a90084fecc88076d0.tar.gz |
temporary add library/cpp/streams/factory/open_by_signature to export
e7cda406ffefb716562a9a7ba46607dff026f1c1
Diffstat (limited to 'library/cpp/streams/lz/lz4/block.h')
-rw-r--r-- | library/cpp/streams/lz/lz4/block.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/library/cpp/streams/lz/lz4/block.h b/library/cpp/streams/lz/lz4/block.h new file mode 100644 index 0000000000..9a912c0be2 --- /dev/null +++ b/library/cpp/streams/lz/lz4/block.h @@ -0,0 +1,35 @@ +#pragma once + +#include <library/cpp/streams/lz/common/compressor.h> + +#include <contrib/libs/lz4/lz4.h> + +/* + * LZ4 + */ +class TLZ4 { +public: + static constexpr char signature[]= "LZ.4"; + + static inline size_t Hint(size_t len) noexcept { + return Max<size_t>((size_t)(len * 1.06), 100); + } + + inline size_t Compress(const char* data, size_t len, char* ptr, size_t dstMaxSize) { + return LZ4_compress_default(data, ptr, len, dstMaxSize); + } + + inline size_t Decompress(const char* data, size_t len, char* ptr, size_t max) { + int res = LZ4_decompress_safe(data, ptr, len, max); + if (res < 0) + ythrow TDecompressorError(); + return res; + } + + inline void InitFromStream(IInputStream*) const noexcept { + } + + static inline bool SaveIncompressibleChunks() noexcept { + return false; + } +}; |