aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs/huffman_codec.h
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/codecs/huffman_codec.h
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/codecs/huffman_codec.h')
-rw-r--r--library/cpp/codecs/huffman_codec.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/library/cpp/codecs/huffman_codec.h b/library/cpp/codecs/huffman_codec.h
new file mode 100644
index 0000000000..559545b90d
--- /dev/null
+++ b/library/cpp/codecs/huffman_codec.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "codecs.h"
+
+#include <util/generic/ptr.h>
+#include <util/string/cast.h>
+
+namespace NCodecs {
+ // for types greater than char, pipeline with TFreqCodec.
+
+ class THuffmanCodec: public ICodec {
+ class TImpl;
+ TIntrusivePtr<TImpl> Impl;
+
+ public:
+ THuffmanCodec();
+ ~THuffmanCodec() override;
+
+ static TStringBuf MyName() {
+ return "huffman";
+ }
+
+ TString GetName() const override {
+ return ToString(MyName());
+ }
+
+ ui8 Encode(TStringBuf in, TBuffer& bbb) const override;
+
+ void Decode(TStringBuf in, TBuffer& bbb) const override;
+
+ void LearnByFreqs(const TArrayRef<std::pair<char, ui64>>& freqs);
+
+ protected:
+ void DoLearn(ISequenceReader& in) override;
+ void Save(IOutputStream* out) const override;
+ void Load(IInputStream* in) override;
+ };
+
+}