aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.ru>2022-02-10 16:49:22 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:22 +0300
commita6f6b22bda21d53d07bd2e0ff63a2b2abf69ede9 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/codecs
parentd7e4eaec9d325e188dabb3eb1949a32a5229e9ce (diff)
downloadydb-a6f6b22bda21d53d07bd2e0ff63a2b2abf69ede9.tar.gz
Restoring authorship annotation for <udovichenko-r@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/codecs')
-rw-r--r--library/cpp/codecs/codecs_registry.cpp4
-rw-r--r--library/cpp/codecs/solar_codec.h54
-rw-r--r--library/cpp/codecs/ut/codecs_ut.cpp12
3 files changed, 35 insertions, 35 deletions
diff --git a/library/cpp/codecs/codecs_registry.cpp b/library/cpp/codecs/codecs_registry.cpp
index bfc145bade..17d07062ab 100644
--- a/library/cpp/codecs/codecs_registry.cpp
+++ b/library/cpp/codecs/codecs_registry.cpp
@@ -27,8 +27,8 @@ namespace NCodecs {
Y_VERIFY(!Registry.contains(name), "already has %s", name.data());
Registry[name] = fac;
}
- }
-
+ }
+
TCodecPtr TCodecRegistry::GetCodec(TStringBuf name) const {
using namespace NPrivate;
diff --git a/library/cpp/codecs/solar_codec.h b/library/cpp/codecs/solar_codec.h
index f0093f82f9..7158ae7926 100644
--- a/library/cpp/codecs/solar_codec.h
+++ b/library/cpp/codecs/solar_codec.h
@@ -13,15 +13,15 @@ namespace NCodecs {
struct TVarIntTraits {
static const size_t MAX_VARINT32_BYTES = 5;
-
+
static void Write(ui32 value, TBuffer& b) {
while (value > 0x7F) {
b.Append(static_cast<ui8>(value) | 0x80);
value >>= 7;
}
b.Append(static_cast<ui8>(value) & 0x7F);
- }
-
+ }
+
static void Read(TStringBuf& r, ui32& value) {
ui32 result = 0;
for (ui32 count = 0; count < MAX_VARINT32_BYTES; ++count) {
@@ -34,22 +34,22 @@ namespace NCodecs {
} else if (Y_UNLIKELY(r.empty())) {
break;
}
- }
+ }
Y_ENSURE_EX(false, TCodecException() << "Bad data");
- }
+ }
};
-
+
struct TShortIntTraits {
static const size_t SHORTINT_SIZE_LIMIT = 0x8000;
-
+
Y_FORCE_INLINE static void Write(ui32 value, TBuffer& b) {
Y_ENSURE_EX(value < SHORTINT_SIZE_LIMIT, TCodecException() << "Bad write method");
if (value >= 0x80) {
b.Append(static_cast<ui8>(value >> 8) | 0x80);
}
b.Append(static_cast<ui8>(value));
- }
-
+ }
+
Y_FORCE_INLINE static void Read(TStringBuf& r, ui32& value) {
ui32 result = static_cast<ui8>(r[0]);
r.Skip(1);
@@ -59,9 +59,9 @@ namespace NCodecs {
r.Skip(1);
}
value = result;
- }
+ }
};
-
+
class TSolarCodec: public ICodec {
public:
static TStringBuf MyName8k() {
@@ -115,28 +115,28 @@ namespace NCodecs {
EncodeImpl<TVarIntTraits>(r, b);
return 0;
}
-
+
void Decode(TStringBuf r, TBuffer& b) const override {
DecodeImpl<TVarIntTraits>(r, b);
}
-
+
TString GetName() const override {
return ToString(MyName());
}
-
+
protected:
void DoLearn(ISequenceReader&) override;
void Save(IOutputStream*) const override;
void Load(IInputStream*) override;
-
+
Y_FORCE_INLINE TStringBuf SubStr(ui32 begoff, ui32 endoff) const {
return TStringBuf(Pool.Data() + begoff, endoff - begoff);
}
-
+
Y_FORCE_INLINE TStringBuf DoDecode(ui32 num) const {
return SubStr(Decoder[num - 1], Decoder[num]);
}
-
+
template <class TTraits>
Y_FORCE_INLINE void EncodeImpl(TStringBuf r, TBuffer& b) const {
b.Clear();
@@ -195,8 +195,8 @@ namespace NCodecs {
}
return 0;
- }
-
+ }
+
void Decode(TStringBuf r, TBuffer& b) const override {
if (CanUseShortInt()) {
DecodeImpl<TShortIntTraits>(r, b);
@@ -204,23 +204,23 @@ namespace NCodecs {
DecodeImpl<TVarIntTraits>(r, b);
}
}
-
+
TString GetName() const override {
if (CanUseShortInt()) {
return ToString(MyNameShortInt());
} else {
return ToString(MyName());
}
- }
+ }
};
-
+
class TSolarCodecShortInt: public TSolarCodec {
public:
explicit TSolarCodecShortInt(ui32 maxentries = 1 << 14, ui32 maxiter = 16, const NGreedyDict::TBuildSettings& s = NGreedyDict::TBuildSettings())
: TSolarCodec(maxentries, maxiter, s)
{
- }
-
+ }
+
ui8 /*free bits in last byte*/ Encode(TStringBuf r, TBuffer& b) const override {
EncodeImpl<TShortIntTraits>(r, b);
return 0;
@@ -229,16 +229,16 @@ namespace NCodecs {
void Decode(TStringBuf r, TBuffer& b) const override {
DecodeImpl<TShortIntTraits>(r, b);
}
-
+
TString GetName() const override {
return ToString(MyNameShortInt());
}
-
+
protected:
void Load(IInputStream* in) override {
TSolarCodec::Load(in);
Y_ENSURE_EX(CanUseShortInt(), TCodecException() << "Bad data");
}
};
-
+
}
diff --git a/library/cpp/codecs/ut/codecs_ut.cpp b/library/cpp/codecs/ut/codecs_ut.cpp
index 4bebbad08f..caf6089aef 100644
--- a/library/cpp/codecs/ut/codecs_ut.cpp
+++ b/library/cpp/codecs/ut/codecs_ut.cpp
@@ -1281,9 +1281,9 @@ private:
}
TestCodec<TSolarCodec, true>(learn, test, new TSolarCodec(512, 8));
- TestCodec<TAdaptiveSolarCodec, false>(learn, test, new TAdaptiveSolarCodec(512, 8));
- TestCodec<TAdaptiveSolarCodec, true>(learn, test, new TAdaptiveSolarCodec(512, 8));
- TestCodec<TSolarCodecShortInt, true>(learn, test, new TSolarCodecShortInt(512, 8));
+ TestCodec<TAdaptiveSolarCodec, false>(learn, test, new TAdaptiveSolarCodec(512, 8));
+ TestCodec<TAdaptiveSolarCodec, true>(learn, test, new TAdaptiveSolarCodec(512, 8));
+ TestCodec<TSolarCodecShortInt, true>(learn, test, new TSolarCodecShortInt(512, 8));
}
{
@@ -1302,9 +1302,9 @@ private:
}
TestCodec<TSolarCodec, true>(learn, test, new TSolarCodec(512, 8));
- TestCodec<TAdaptiveSolarCodec, false>(learn, test, new TAdaptiveSolarCodec(512, 8));
- TestCodec<TAdaptiveSolarCodec, true>(learn, test, new TAdaptiveSolarCodec(512, 8));
- TestCodec<TSolarCodecShortInt, true>(learn, test, new TSolarCodecShortInt(512, 8));
+ TestCodec<TAdaptiveSolarCodec, false>(learn, test, new TAdaptiveSolarCodec(512, 8));
+ TestCodec<TAdaptiveSolarCodec, true>(learn, test, new TAdaptiveSolarCodec(512, 8));
+ TestCodec<TSolarCodecShortInt, true>(learn, test, new TSolarCodecShortInt(512, 8));
}
}