diff options
author | iddqd <iddqd@yandex-team.com> | 2024-06-10 10:07:19 +0300 |
---|---|---|
committer | iddqd <iddqd@yandex-team.com> | 2024-06-10 11:40:16 +0300 |
commit | 0f8b43a2792f618dce8711696ce5e394e7f3933d (patch) | |
tree | b3b1b6c020161e906fde4712471c07d9e18ff5ef /library/cpp/streams/lz/lz4/block.h | |
parent | 520001ecb8d8d5362f41e7db2b4ad5aab5afd8e6 (diff) | |
download | ydb-0f8b43a2792f618dce8711696ce5e394e7f3933d.tar.gz |
Do not use minilzo and quicklz in open source. Export it to github.
d4d08d59dfff0c48a950a3faa36be4ac7e060912
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; + } +}; |