aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams/lz/lz4/block.h
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
committerqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/streams/lz/lz4/block.h
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
downloadydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz
validate canons without yatest_common
Diffstat (limited to 'library/cpp/streams/lz/lz4/block.h')
-rw-r--r--library/cpp/streams/lz/lz4/block.h35
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;
+ }
+};