aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs/comptable_codec.cpp
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/codecs/comptable_codec.cpp
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
downloadydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs/comptable_codec.cpp')
-rw-r--r--library/cpp/codecs/comptable_codec.cpp190
1 files changed, 95 insertions, 95 deletions
diff --git a/library/cpp/codecs/comptable_codec.cpp b/library/cpp/codecs/comptable_codec.cpp
index 476b8ada80..1eca4354c6 100644
--- a/library/cpp/codecs/comptable_codec.cpp
+++ b/library/cpp/codecs/comptable_codec.cpp
@@ -1,108 +1,108 @@
-#include "comptable_codec.h"
-
+#include "comptable_codec.h"
+
#include <library/cpp/comptable/comptable.h>
#include <util/string/cast.h>
-
-namespace NCodecs {
+
+namespace NCodecs {
class TCompTableCodec::TImpl: public TAtomicRefCount<TImpl> {
- public:
- TImpl(EQuality q)
- : Quality(q)
+ public:
+ TImpl(EQuality q)
+ : Quality(q)
{
}
-
- void Init() {
- Compressor.Reset(new NCompTable::TChunkCompressor{(bool)Quality, Table});
- Decompressor.Reset(new NCompTable::TChunkDecompressor{(bool)Quality, Table});
- }
-
- ui8 Encode(TStringBuf in, TBuffer& out) const {
- out.Clear();
- if (!in) {
- return 0;
- }
-
+
+ void Init() {
+ Compressor.Reset(new NCompTable::TChunkCompressor{(bool)Quality, Table});
+ Decompressor.Reset(new NCompTable::TChunkDecompressor{(bool)Quality, Table});
+ }
+
+ ui8 Encode(TStringBuf in, TBuffer& out) const {
+ out.Clear();
+ if (!in) {
+ return 0;
+ }
+
TVector<char> result;
- Compressor->Compress(in, &result);
- out.Assign(&result[0], result.size());
- return 0;
- }
-
- void Decode(TStringBuf in, TBuffer& out) const {
- out.Clear();
- if (!in) {
- return;
- }
-
+ Compressor->Compress(in, &result);
+ out.Assign(&result[0], result.size());
+ return 0;
+ }
+
+ void Decode(TStringBuf in, TBuffer& out) const {
+ out.Clear();
+ if (!in) {
+ return;
+ }
+
TVector<char> result;
- Decompressor->Decompress(in, &result);
- out.Assign(&result[0], result.size());
- }
-
- void DoLearn(ISequenceReader& in) {
- NCompTable::TDataSampler sampler;
- TStringBuf region;
- while (in.NextRegion(region)) {
- if (!region) {
- continue;
- }
-
- sampler.AddStat(region);
- }
-
- sampler.BuildTable(Table);
- Init();
- }
-
+ Decompressor->Decompress(in, &result);
+ out.Assign(&result[0], result.size());
+ }
+
+ void DoLearn(ISequenceReader& in) {
+ NCompTable::TDataSampler sampler;
+ TStringBuf region;
+ while (in.NextRegion(region)) {
+ if (!region) {
+ continue;
+ }
+
+ sampler.AddStat(region);
+ }
+
+ sampler.BuildTable(Table);
+ Init();
+ }
+
void Save(IOutputStream* out) const {
- ::Save(out, Table);
- }
-
+ ::Save(out, Table);
+ }
+
void Load(IInputStream* in) {
- ::Load(in, Table);
- Init();
- }
-
- NCompTable::TCompressorTable Table;
- THolder<NCompTable::TChunkCompressor> Compressor;
- THolder<NCompTable::TChunkDecompressor> Decompressor;
- const EQuality Quality;
- static const ui32 SampleSize = Max(NCompTable::TDataSampler::Size * 4, (1 << 22) * 5);
- };
-
- TCompTableCodec::TCompTableCodec(EQuality q)
- : Impl(new TImpl{q})
- {
- MyTraits.NeedsTraining = true;
- MyTraits.SizeOnEncodeMultiplier = 2;
- MyTraits.SizeOnDecodeMultiplier = 10;
- MyTraits.RecommendedSampleSize = TImpl::SampleSize;
- }
-
- TCompTableCodec::~TCompTableCodec() = default;
-
+ ::Load(in, Table);
+ Init();
+ }
+
+ NCompTable::TCompressorTable Table;
+ THolder<NCompTable::TChunkCompressor> Compressor;
+ THolder<NCompTable::TChunkDecompressor> Decompressor;
+ const EQuality Quality;
+ static const ui32 SampleSize = Max(NCompTable::TDataSampler::Size * 4, (1 << 22) * 5);
+ };
+
+ TCompTableCodec::TCompTableCodec(EQuality q)
+ : Impl(new TImpl{q})
+ {
+ MyTraits.NeedsTraining = true;
+ MyTraits.SizeOnEncodeMultiplier = 2;
+ MyTraits.SizeOnDecodeMultiplier = 10;
+ MyTraits.RecommendedSampleSize = TImpl::SampleSize;
+ }
+
+ TCompTableCodec::~TCompTableCodec() = default;
+
TString TCompTableCodec::GetName() const {
return ToString(Impl->Quality ? MyNameHQ() : MyNameLQ());
- }
-
- ui8 TCompTableCodec::Encode(TStringBuf in, TBuffer& out) const {
- return Impl->Encode(in, out);
- }
-
- void TCompTableCodec::Decode(TStringBuf in, TBuffer& out) const {
- Impl->Decode(in, out);
- }
-
- void TCompTableCodec::DoLearn(ISequenceReader& in) {
- Impl->DoLearn(in);
- }
-
+ }
+
+ ui8 TCompTableCodec::Encode(TStringBuf in, TBuffer& out) const {
+ return Impl->Encode(in, out);
+ }
+
+ void TCompTableCodec::Decode(TStringBuf in, TBuffer& out) const {
+ Impl->Decode(in, out);
+ }
+
+ void TCompTableCodec::DoLearn(ISequenceReader& in) {
+ Impl->DoLearn(in);
+ }
+
void TCompTableCodec::Save(IOutputStream* out) const {
- Impl->Save(out);
- }
-
+ Impl->Save(out);
+ }
+
void TCompTableCodec::Load(IInputStream* in) {
- Impl->Load(in);
- }
-
-}
+ Impl->Load(in);
+ }
+
+}