aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorputilin <putilin@yandex-team.ru>2022-02-10 16:49:29 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:29 +0300
commitd85af01a101a46c4381ba0c8d5785a43c8273afd (patch)
tree955ec4a6a051440017d27a47b877dc44311daa50 /library/cpp
parentc03ef37690111076e93822dbfa59fd672fa45c33 (diff)
downloadydb-d85af01a101a46c4381ba0c8d5785a43c8273afd.tar.gz
Restoring authorship annotation for <putilin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/binsaver/bin_saver.h24
-rw-r--r--library/cpp/compproto/bit.h36
-rw-r--r--library/cpp/compproto/compproto_ut.cpp556
-rw-r--r--library/cpp/compproto/huff.h2
-rw-r--r--library/cpp/compproto/metainfo.h10
5 files changed, 314 insertions, 314 deletions
diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h
index 412424889f..67aa835079 100644
--- a/library/cpp/binsaver/bin_saver.h
+++ b/library/cpp/binsaver/bin_saver.h
@@ -411,20 +411,20 @@ public:
}
return 0;
}
-
- template <size_t N>
+
+ template <size_t N>
int Add(const chunk_id, std::bitset<N>* pData) {
- if (IsReading()) {
- std::string s;
- Add(1, &s);
- *pData = std::bitset<N>(s);
- } else {
+ if (IsReading()) {
+ std::string s;
+ Add(1, &s);
+ *pData = std::bitset<N>(s);
+ } else {
std::string s = pData->template to_string<char, std::char_traits<char>, std::allocator<char>>();
- Add(1, &s);
- }
- return 0;
- }
-
+ Add(1, &s);
+ }
+ return 0;
+ }
+
int Add(const chunk_id, TDynBitMap* pData) {
if (IsReading()) {
ui64 count = 0;
diff --git a/library/cpp/compproto/bit.h b/library/cpp/compproto/bit.h
index 6a421b65f7..917771b90d 100644
--- a/library/cpp/compproto/bit.h
+++ b/library/cpp/compproto/bit.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/generic/array_ref.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <util/stream/output.h>
#include <util/stream/input.h>
@@ -25,7 +25,7 @@ namespace NCompProto {
ui8 shift = position & 7;
return ((1ULL << size) - 1) & (outCode >> shift);
}
-
+
ui64 Read(ui64 position, size_t size) {
return Read(&Out[0], position, size);
}
@@ -68,12 +68,12 @@ namespace NCompProto {
size_t ByteLength() const {
return (Position + 7) / 8;
}
-
+
void ResetPosition() {
Position = 0;
Size = 0;
}
-
+
void Clear() {
Counter = 0;
Position = 0;
@@ -81,12 +81,12 @@ namespace NCompProto {
Out.clear();
Junk();
}
-
+
TArrayRef<const char> AsDataRegion() const {
return TArrayRef<const char>(reinterpret_cast<const char*>(Out.data()), ByteLength());
}
};
-
+
struct THuff {
TCoder Coder;
ui64 Position;
@@ -165,7 +165,7 @@ namespace NCompProto {
// TODO: why not const TString& ???
void Save(IOutputStream& /*stream*/, TString /*offset*/) {
}
-
+
void Add(ui32 value, TEmpty& /*empty*/) {
Accum.Add(value);
}
@@ -235,18 +235,18 @@ namespace NCompProto {
size_t index = 0;
while (scalarMask) {
if (mask & 1) {
- ui32 val = table->Scalar[index].Decompress(codes, offset);
+ ui32 val = table->Scalar[index].Decompress(codes, offset);
Self.SetScalar(index, val);
} else if (table->Default[index].Type == TScalarDefaultValue::Fixed) {
Self.SetScalar(index, table->Default[index].Value);
- }
+ }
mask = mask >> 1;
scalarMask = scalarMask >> 1;
++index;
- }
+ }
Self.EndElement();
- }
-
+ }
+
public:
void Decompress(const TMetaInfo<TTable>* table, const ui8* codes, ui64& offset) override {
ui64 locOffset = offset;
@@ -263,11 +263,11 @@ namespace NCompProto {
repeatedIndex += table->Index.Decompress(codes, locOffset);
DecompressSingleScalarsOnly(repeatedIndex, table, codes, locOffset);
}
- }
+ }
offset = locOffset;
Self.EndSelf();
- }
-
+ }
+
// XXX: iterator needed?
//
// Following two functions serves the purpose of decompressing outer repeated-structure(such structure is mandatory now).
@@ -276,12 +276,12 @@ namespace NCompProto {
table->Index.Decompress(codes, offset);
DecompressSingle(prevIndex, table, codes, offset);
}
-
+
ui32 DecompressCount(const TMetaInfo<TTable>* table, const ui8* codes, ui64& offset) {
return table->Count.Decompress(codes, offset);
}
};
-
+
template <class X>
struct TParentHold {
TMetaIterator<X>* Parent;
@@ -344,5 +344,5 @@ namespace NCompProto {
THuffToTable::Build(table, huff);
}
};
-
+
}
diff --git a/library/cpp/compproto/compproto_ut.cpp b/library/cpp/compproto/compproto_ut.cpp
index 9393be967a..85d1e1f51d 100644
--- a/library/cpp/compproto/compproto_ut.cpp
+++ b/library/cpp/compproto/compproto_ut.cpp
@@ -2,12 +2,12 @@
#include "metainfo.h"
#include "bit.h"
-#include <util/generic/vector.h>
-#include <util/generic/map.h>
+#include <util/generic/vector.h>
+#include <util/generic/map.h>
#include <util/system/protect.h>
#include <library/cpp/testing/unittest/registar.h>
-
+
static ui64 gSeed = 42;
static void FlushPseudoRandom() {
@@ -20,8 +20,8 @@ static ui32 PseudoRandom(ui32 max) {
gSeed *= 419;
gSeed = gSeed ^ (ui64(max) << 17);
return gSeed % max;
-};
-
+};
+
enum ECompMode {
CM_SINGLEPASS,
CM_TWOPASS
@@ -43,28 +43,28 @@ void TestSaveLoadMeta(NCompProto::TMetaInfo<X>& src) {
UNIT_ASSERT_EQUAL(ss.Str(), data);
}
-template <typename TDecompressor, template <typename, typename> class TSerialize>
+template <typename TDecompressor, template <typename, typename> class TSerialize>
void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestParams& params) {
using namespace NCompProto;
FlushPseudoRandom();
-
+
TStringInput stream(metainfo);
THolder<TMetaInfo<THuff>> meta;
if (mode == CM_TWOPASS) {
- TMetaInfo<THist> hist(stream);
- TEmpty empty;
+ TMetaInfo<THist> hist(stream);
+ TEmpty empty;
TSerialize<THist, TEmpty>::Serialize(hist, empty, params);
- meta.Reset(new TMetaInfo<THuff>(hist, THistToHuff::Instance()));
- } else {
- meta.Reset(new TMetaInfo<THuff>(stream));
- }
+ meta.Reset(new TMetaInfo<THuff>(hist, THistToHuff::Instance()));
+ } else {
+ meta.Reset(new TMetaInfo<THuff>(stream));
+ }
TestSaveLoadMeta(*meta.Get());
-
- TBitBuffer buffer;
+
+ TBitBuffer buffer;
TSerialize<THuff, TBitBuffer>::Serialize(*meta, buffer, params);
-
- ui64 codedSize = buffer.Position;
+
+ ui64 codedSize = buffer.Position;
TMetaInfo<TTable> decompressor(*meta, THuffToTable::Instance());
@@ -86,16 +86,16 @@ void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestPa
// memory copying should be performed without any problems
memcpy(dataStart, buffer.Out.data(), byteSize);
- ui64 position = 0;
+ ui64 position = 0;
TMetaIterator<TDecompressor> instance;
// we should not read beyond dataEnd here
instance.Decompress(&decompressor, dataStart, position);
const ui64 decodedSize = position;
- UNIT_ASSERT_EQUAL(codedSize, decodedSize);
+ UNIT_ASSERT_EQUAL(codedSize, decodedSize);
// unprotect memory
ProtectMemory(dataEnd, PAGESIZEX, PM_READ | PM_WRITE | PM_EXEC);
-}
-
+}
+
template <typename TDecompressor, template <typename, typename> class TSerialize>
void Test(const TString& metainfo, const ECompMode mode) {
for (size_t ds = 3; ds < 42; ds += (3 + PseudoRandom(5))) {
@@ -107,72 +107,72 @@ void Test(const TString& metainfo, const ECompMode mode) {
}
}
}
-
+
Y_UNIT_TEST_SUITE(CompProtoTestBasic) {
using namespace NCompProto;
const TString metainfo =
"\n\
- repeated data id 0\n\
- scalar clicks id 0 default const 0\n\
- scalar shows id 1 default const 0\n\
- repeated regClicks id 2\n\
- scalar clicks id 0 default const 0\n\
- scalar shows id 1 default const 0\n\
- end\n\
+ repeated data id 0\n\
+ scalar clicks id 0 default const 0\n\
+ scalar shows id 1 default const 0\n\
+ repeated regClicks id 2\n\
+ scalar clicks id 0 default const 0\n\
+ scalar shows id 1 default const 0\n\
+ end\n\
scalar extra id 31 default const 0\n\
- end\n";
-
+ end\n";
+
struct TRegInfo {
ui32 Clicks;
ui32 Shows;
- };
-
+ };
+
struct TData {
ui32 Clicks;
ui32 Shows;
ui32 Extra;
TMap<ui32, TRegInfo> RegClicks;
- };
-
+ };
+
TVector<TData> data;
-
+
template <class TMeta, class TFunctor>
struct TSerialize {
static void Serialize(TMetaInfo<TMeta>& meta, TFunctor& functor, const TTestParams& params) {
FlushPseudoRandom();
- meta.BeginSelf(functor);
- data.clear();
+ meta.BeginSelf(functor);
+ data.clear();
data.resize(params.DataSize);
for (ui32 i = 0; i < params.DataSize; ++i) {
- meta.BeginElement(i, functor);
-
+ meta.BeginElement(i, functor);
+
data[i].Clicks = PseudoRandom(16) + 100;
data[i].Shows = PseudoRandom(500) * PseudoRandom(16);
data[i].Extra = PseudoRandom(500) + (1UL << 31); // test also saving of big values
meta.SetScalar(0, data[i].Clicks, functor);
meta.SetScalar(1, data[i].Shows, functor);
-
+
TMetaInfo<TMeta>& regClicks = meta.BeginRepeated(2, functor);
for (ui32 j = 0; j < PseudoRandom(200); j += 1 + PseudoRandom(10)) {
- regClicks.BeginElement(j, functor);
+ regClicks.BeginElement(j, functor);
TRegInfo& r = data[i].RegClicks[j];
-
+
r.Clicks = PseudoRandom(2);
r.Shows = PseudoRandom(800) * PseudoRandom(8) + 56;
regClicks.SetScalar(0, r.Clicks, functor);
regClicks.SetScalar(1, r.Shows, functor);
-
- regClicks.EndElement(functor);
- }
- regClicks.EndRepeated(functor);
+
+ regClicks.EndElement(functor);
+ }
+ regClicks.EndRepeated(functor);
meta.SetScalar(31, data[i].Extra, functor);
- meta.EndElement(functor);
- }
- meta.EndRepeated(functor);
- }
- };
-
+ meta.EndElement(functor);
+ }
+ meta.EndRepeated(functor);
+ }
+ };
+
struct TMultiDecompressor: public TParentHold<TMultiDecompressor> {
struct TRegClicks: public TParentHold<TRegClicks> {
const TData* Data;
@@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) {
, Elem(nullptr)
{
}
- void BeginSelf(ui32 /*count*/, ui32 /*id*/) {
+ void BeginSelf(ui32 /*count*/, ui32 /*id*/) {
}
void EndSelf() {
}
@@ -209,7 +209,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) {
const TData* Elem;
TMetaIterator<TRegClicks> RegClicks;
- void BeginSelf(ui32 /*count*/, ui32 /*id*/) {
+ void BeginSelf(ui32 /*count*/, ui32 /*id*/) {
}
void EndSelf() {
}
@@ -242,125 +242,125 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) {
};
struct TVerifyingDecompressor: public TParentHold<TVerifyingDecompressor> {
- enum EState {
+ enum EState {
Startstop,
OutDataElem,
InDataElem,
InRegClicks,
- };
- EState State;
-
- ui32 DataInd;
+ };
+ EState State;
+
+ ui32 DataInd;
TMap<ui32, TRegInfo>::iterator RegIter;
-
+
TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) {
Y_UNUSED(index);
return *Parent;
}
- TVerifyingDecompressor()
- : State(Startstop)
- , DataInd(0)
+ TVerifyingDecompressor()
+ : State(Startstop)
+ , DataInd(0)
{
}
- void BeginSelf(ui32 /*count*/, ui32 id) {
- switch (State) {
- case Startstop:
- UNIT_ASSERT_EQUAL(id, 0);
- State = OutDataElem;
- break;
- case OutDataElem:
- UNIT_ASSERT(0);
- case InDataElem:
- UNIT_ASSERT_EQUAL(id, 2);
- State = InRegClicks;
+ void BeginSelf(ui32 /*count*/, ui32 id) {
+ switch (State) {
+ case Startstop:
+ UNIT_ASSERT_EQUAL(id, 0);
+ State = OutDataElem;
+ break;
+ case OutDataElem:
+ UNIT_ASSERT(0);
+ case InDataElem:
+ UNIT_ASSERT_EQUAL(id, 2);
+ State = InRegClicks;
RegIter = data[DataInd].RegClicks.begin();
- break;
- case InRegClicks:
- UNIT_ASSERT(0);
- default:
- UNIT_ASSERT(0);
- }
- }
- void EndSelf() {
- switch (State) {
- case Startstop:
- UNIT_ASSERT(0);
- case OutDataElem:
- State = Startstop;
- break;
- case InDataElem:
- UNIT_ASSERT(0);
- case InRegClicks:
+ break;
+ case InRegClicks:
+ UNIT_ASSERT(0);
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ void EndSelf() {
+ switch (State) {
+ case Startstop:
+ UNIT_ASSERT(0);
+ case OutDataElem:
+ State = Startstop;
+ break;
+ case InDataElem:
+ UNIT_ASSERT(0);
+ case InRegClicks:
UNIT_ASSERT_EQUAL(RegIter, data[DataInd].RegClicks.end());
- State = InDataElem;
- break;
- default:
- UNIT_ASSERT(0);
- }
- }
- void BeginElement(ui32 element) {
- switch (State) {
- case Startstop:
- UNIT_ASSERT(0);
- case OutDataElem:
- UNIT_ASSERT(element < data.size());
- State = InDataElem;
- break;
- case InDataElem:
- UNIT_ASSERT(0);
- case InRegClicks:
- UNIT_ASSERT_EQUAL(element, RegIter->first);
+ State = InDataElem;
+ break;
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ void BeginElement(ui32 element) {
+ switch (State) {
+ case Startstop:
+ UNIT_ASSERT(0);
+ case OutDataElem:
+ UNIT_ASSERT(element < data.size());
+ State = InDataElem;
+ break;
+ case InDataElem:
+ UNIT_ASSERT(0);
+ case InRegClicks:
+ UNIT_ASSERT_EQUAL(element, RegIter->first);
+ break;
+ }
+ }
+ void EndElement() {
+ switch (State) {
+ case Startstop:
+ UNIT_ASSERT(0);
+ case OutDataElem:
+ UNIT_ASSERT(0);
+ case InDataElem:
+ State = OutDataElem;
+ ++DataInd;
break;
- }
- }
- void EndElement() {
- switch (State) {
- case Startstop:
- UNIT_ASSERT(0);
- case OutDataElem:
- UNIT_ASSERT(0);
- case InDataElem:
- State = OutDataElem;
- ++DataInd;
- break;
- case InRegClicks:
- ++RegIter;
- break;
- }
- }
-
- void SetScalar(size_t index, ui32 val) {
- switch (State) {
- case OutDataElem:
- UNIT_ASSERT(0);
- case InDataElem:
- if (index == 0)
+ case InRegClicks:
+ ++RegIter;
+ break;
+ }
+ }
+
+ void SetScalar(size_t index, ui32 val) {
+ switch (State) {
+ case OutDataElem:
+ UNIT_ASSERT(0);
+ case InDataElem:
+ if (index == 0)
UNIT_ASSERT_EQUAL(val, data[DataInd].Clicks);
- if (index == 1)
+ if (index == 1)
UNIT_ASSERT_EQUAL(val, data[DataInd].Shows);
if (index == 31)
UNIT_ASSERT_EQUAL(val, data[DataInd].Extra);
- break;
- case InRegClicks:
- if (index == 0)
+ break;
+ case InRegClicks:
+ if (index == 0)
UNIT_ASSERT_EQUAL(val, RegIter->second.Clicks);
- if (index == 1)
+ if (index == 1)
UNIT_ASSERT_EQUAL(val, RegIter->second.Shows);
- break;
- default:
- UNIT_ASSERT(0);
- }
- }
- };
-
+ break;
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ };
+
Y_UNIT_TEST(VerifyDecompression) {
Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS);
- }
-
+ }
+
Y_UNIT_TEST(VerifyHistDecompression) {
Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS);
- }
+ }
Y_UNIT_TEST(VerifyDecompressionMulti) {
Test<TMultiDecompressor, TSerialize>(metainfo, CM_SINGLEPASS);
@@ -369,175 +369,175 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) {
Y_UNIT_TEST(VerifyHistDecompressionMulti) {
Test<TMultiDecompressor, TSerialize>(metainfo, CM_TWOPASS);
}
-}
-
+}
+
Y_UNIT_TEST_SUITE(CompProtoTestExtended) {
using namespace NCompProto;
const TString metainfo =
"\n\
- repeated data id 0\n\
- repeated second id 3\n\
- scalar inner2 id 0 default const 0\n\
- end\n\
- repeated first id 2\n\
- scalar inner id 0 default const 0\n\
- end\n\
- end\n";
+ repeated data id 0\n\
+ repeated second id 3\n\
+ scalar inner2 id 0 default const 0\n\
+ end\n\
+ repeated first id 2\n\
+ scalar inner id 0 default const 0\n\
+ end\n\
+ end\n";
TVector<std::pair<TVector<ui32>, TVector<ui32>>> data;
-
+
template <class TMeta, class TFunctor>
struct TSerialize {
static void Serialize(TMetaInfo<TMeta>& meta, TFunctor& functor, const TTestParams& params) {
FlushPseudoRandom();
- meta.BeginSelf(functor);
- data.clear();
+ meta.BeginSelf(functor);
+ data.clear();
data.resize(params.DataSize);
for (size_t i = 0; i < params.DataSize; ++i) {
- meta.BeginElement(i, functor);
+ meta.BeginElement(i, functor);
TMetaInfo<TMeta>& first = meta.BeginRepeated(2, functor);
data[i].first.resize(params.ValueArraySize);
for (ui32 j = 0; j < params.ValueArraySize; j++) {
- first.BeginElement(j, functor);
-
+ first.BeginElement(j, functor);
+
ui32 val = PseudoRandom(42 * 42 * 42);
- first.SetScalar(0, val, functor);
+ first.SetScalar(0, val, functor);
data[i].first[j] = val;
-
- first.EndElement(functor);
- }
- first.EndRepeated(functor);
-
+
+ first.EndElement(functor);
+ }
+ first.EndRepeated(functor);
+
TMetaInfo<TMeta>& second = meta.BeginRepeated(3, functor);
data[i].second.resize(params.ValueArraySize);
for (ui32 j = 0; j < params.ValueArraySize; j++) {
- second.BeginElement(j, functor);
-
+ second.BeginElement(j, functor);
+
ui32 val = PseudoRandom(42 * 42 * 42);
- second.SetScalar(0, val, functor);
+ second.SetScalar(0, val, functor);
data[i].second[j] = val;
-
- second.EndElement(functor);
- }
- second.EndRepeated(functor);
- meta.EndElement(functor);
- }
- meta.EndRepeated(functor);
- }
- };
-
+
+ second.EndElement(functor);
+ }
+ second.EndRepeated(functor);
+ meta.EndElement(functor);
+ }
+ meta.EndRepeated(functor);
+ }
+ };
+
struct TVerifyingDecompressor: public TParentHold<TVerifyingDecompressor> {
- enum EState {
+ enum EState {
Startstop,
OutDataElem,
InDataElemBeforeSecond,
InDataElemSecond,
InFirst,
InSecond,
- };
- EState State;
-
- ui32 DataInd;
- ui32 ArrayInd;
-
- TVerifyingDecompressor()
- : State(Startstop)
- , DataInd(0)
- , ArrayInd(0)
+ };
+ EState State;
+
+ ui32 DataInd;
+ ui32 ArrayInd;
+
+ TVerifyingDecompressor()
+ : State(Startstop)
+ , DataInd(0)
+ , ArrayInd(0)
{
}
-
+
TMetaIterator<TVerifyingDecompressor>& GetDecompressor(size_t index) {
Y_UNUSED(index);
return *Parent;
}
- void BeginSelf(ui32 /*count*/, ui32 id) {
- switch (State) {
- case Startstop:
- UNIT_ASSERT_EQUAL(id, 0);
- State = OutDataElem;
- break;
- case InDataElemBeforeSecond:
- UNIT_ASSERT_EQUAL(id, 2);
- State = InFirst;
- ArrayInd = 0;
- break;
- case InDataElemSecond:
- UNIT_ASSERT_EQUAL(id, 3);
- State = InSecond;
- ArrayInd = 0;
- break;
- default:
- UNIT_ASSERT(0);
- }
- }
- void EndSelf() {
- switch (State) {
- case OutDataElem:
- State = Startstop;
- break;
- case InFirst:
- State = InDataElemSecond;
- break;
- case InSecond:
- State = InDataElemSecond;
- break;
- default:
- UNIT_ASSERT(0);
- }
- }
- void BeginElement(ui32 element) {
- switch (State) {
- case OutDataElem:
- UNIT_ASSERT(element < data.size());
- State = InDataElemBeforeSecond;
- break;
- case InFirst:
+ void BeginSelf(ui32 /*count*/, ui32 id) {
+ switch (State) {
+ case Startstop:
+ UNIT_ASSERT_EQUAL(id, 0);
+ State = OutDataElem;
+ break;
+ case InDataElemBeforeSecond:
+ UNIT_ASSERT_EQUAL(id, 2);
+ State = InFirst;
+ ArrayInd = 0;
+ break;
+ case InDataElemSecond:
+ UNIT_ASSERT_EQUAL(id, 3);
+ State = InSecond;
+ ArrayInd = 0;
+ break;
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ void EndSelf() {
+ switch (State) {
+ case OutDataElem:
+ State = Startstop;
+ break;
+ case InFirst:
+ State = InDataElemSecond;
+ break;
+ case InSecond:
+ State = InDataElemSecond;
+ break;
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ void BeginElement(ui32 element) {
+ switch (State) {
+ case OutDataElem:
+ UNIT_ASSERT(element < data.size());
+ State = InDataElemBeforeSecond;
+ break;
+ case InFirst:
UNIT_ASSERT(element < data[DataInd].first.size());
- break;
- case InSecond:
+ break;
+ case InSecond:
UNIT_ASSERT(element < data[DataInd].second.size());
- break;
- default:
- Cerr << (ui32)State << Endl;
- UNIT_ASSERT(0);
- }
- }
- void EndElement() {
- switch (State) {
- case InFirst:
- case InSecond:
- ++ArrayInd;
- break;
- case InDataElemSecond:
- ++DataInd;
- State = OutDataElem;
- break;
- default:
- Cerr << (ui32)State << Endl;
- UNIT_ASSERT(0);
- }
- }
-
- void SetScalar(size_t index, ui32 val) {
- UNIT_ASSERT_EQUAL(index, 0);
- switch (State) {
- case InFirst:
+ break;
+ default:
+ Cerr << (ui32)State << Endl;
+ UNIT_ASSERT(0);
+ }
+ }
+ void EndElement() {
+ switch (State) {
+ case InFirst:
+ case InSecond:
+ ++ArrayInd;
+ break;
+ case InDataElemSecond:
+ ++DataInd;
+ State = OutDataElem;
+ break;
+ default:
+ Cerr << (ui32)State << Endl;
+ UNIT_ASSERT(0);
+ }
+ }
+
+ void SetScalar(size_t index, ui32 val) {
+ UNIT_ASSERT_EQUAL(index, 0);
+ switch (State) {
+ case InFirst:
UNIT_ASSERT_EQUAL(val, data[DataInd].first[ArrayInd]);
- break;
- case InSecond:
+ break;
+ case InSecond:
UNIT_ASSERT_EQUAL(val, data[DataInd].second[ArrayInd]);
- break;
- default:
- UNIT_ASSERT(0);
- }
- }
- };
+ break;
+ default:
+ UNIT_ASSERT(0);
+ }
+ }
+ };
Y_UNIT_TEST(VerifyDecompression) {
Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_SINGLEPASS);
- }
-
+ }
+
Y_UNIT_TEST(VerifyHistDecompression) {
Test<TVerifyingDecompressor, TSerialize>(metainfo, CM_TWOPASS);
- }
-}
+ }
+}
diff --git a/library/cpp/compproto/huff.h b/library/cpp/compproto/huff.h
index fa5c139189..d3d211e9df 100644
--- a/library/cpp/compproto/huff.h
+++ b/library/cpp/compproto/huff.h
@@ -114,7 +114,7 @@ namespace NCompProto {
}
}
for (size_t i = 0; i < 16; ++i) {
- if (Tables[i].Get()) {
+ if (Tables[i].Get()) {
Tables[i]->GenerateFreqs(codes, depth + 4, termDepth, code + (i << (28 - depth)), cnt);
}
}
diff --git a/library/cpp/compproto/metainfo.h b/library/cpp/compproto/metainfo.h
index 6e68f86e12..3c044c9311 100644
--- a/library/cpp/compproto/metainfo.h
+++ b/library/cpp/compproto/metainfo.h
@@ -24,7 +24,7 @@ namespace NCompProto {
};
EType Type;
ui32 Value;
- };
+ };
template <class X>
struct TMetaInfo {
@@ -34,7 +34,7 @@ namespace NCompProto {
X Scalar[MAX_ELEMENTS];
TAtomicSharedPtr<TMetaInfo> Repeated[MAX_ELEMENTS];
TScalarDefaultValue Default[MAX_ELEMENTS];
-
+
ui32 ScalarMask;
ui32 RepeatedMask;
size_t Size;
@@ -146,7 +146,7 @@ namespace NCompProto {
Mask.BeginElement(functor);
Serializer.LastIndex = index;
++Serializer.Count;
- }
+ }
template <class TFunctor>
void Iterate(TFunctor& functor) {
@@ -236,7 +236,7 @@ namespace NCompProto {
stream << step << offset << "table "
<< "id " << i << Endl;
Scalar[i].Save(stream, step + offset);
- }
+ }
}
stream << offset << "end" << Endl;
}
@@ -296,7 +296,7 @@ namespace NCompProto {
}
} else if (name == "end" /* || stream.IsEOF()*/) {
return;
- }
+ }
}
}
};