aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs/huffman_codec.cpp
diff options
context:
space:
mode:
authoraprudaev <aprudaev@yandex-team.ru>2022-02-10 16:49:58 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:58 +0300
commit042dfdfd1388209ce3aa06dca56bd52ec63d40b2 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/codecs/huffman_codec.cpp
parent29e66fe2ab37743577f88e6ab770defc4e6c1002 (diff)
downloadydb-042dfdfd1388209ce3aa06dca56bd52ec63d40b2.tar.gz
Restoring authorship annotation for <aprudaev@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/codecs/huffman_codec.cpp')
-rw-r--r--library/cpp/codecs/huffman_codec.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/library/cpp/codecs/huffman_codec.cpp b/library/cpp/codecs/huffman_codec.cpp
index 8882615aaf..650fe7cdfd 100644
--- a/library/cpp/codecs/huffman_codec.cpp
+++ b/library/cpp/codecs/huffman_codec.cpp
@@ -58,15 +58,15 @@ namespace NCodecs {
tree.back().Char = i;
tree.back().Freq = freqs[i];
}
-
+
StableSort(tree.begin(), tree.end(), TTreeEntry::ByFreq);
- }
-
+ }
+
void InitTree(TCodeTree& tree, ISequenceReader* in) {
using namespace NPrivate;
ui64 freqs[256];
Zero(freqs);
-
+
TStringBuf r;
while (in->NextRegion(r)) {
for (ui64 i = 0; i < r.size(); ++i)
@@ -466,24 +466,24 @@ namespace NCodecs {
ui64 freqsArray[256];
Zero(freqsArray);
-
+
for (const auto& freq : freqs)
freqsArray[static_cast<ui8>(freq.first)] += freq.second;
-
+
InitTreeByFreqs(tree, freqsArray);
CalculateCodeLengths(tree);
-
+
Y_ENSURE(!tree.empty(), " ");
-
+
GenerateEncoder(tree);
BuildDecoder();
}
-
+
void Save(IOutputStream* out) {
::Save(out, Invalid.CodeLength);
Encoder.Save(out);
}
-
+
void Load(IInputStream* in) {
::Load(in, Invalid.CodeLength);
Encoder.Load(in);
@@ -589,4 +589,4 @@ namespace NCodecs {
Trained = true;
}
-}
+}