aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams/lz
diff options
context:
space:
mode:
authoryazevnul <yazevnul@yandex-team.ru>2022-02-10 16:46:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:46 +0300
commit8cbc307de0221f84c80c42dcbe07d40727537e2c (patch)
tree625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/streams/lz
parent30d1ef3941e0dc835be7609de5ebee66958f215a (diff)
downloadydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/streams/lz')
-rw-r--r--library/cpp/streams/lz/lz.cpp70
-rw-r--r--library/cpp/streams/lz/lz.h52
-rw-r--r--library/cpp/streams/lz/lz_ut.cpp42
3 files changed, 82 insertions, 82 deletions
diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp
index b65bb3ed96..2bfa93a4aa 100644
--- a/library/cpp/streams/lz/lz.cpp
+++ b/library/cpp/streams/lz/lz.cpp
@@ -32,7 +32,7 @@ const size_t SIGNATURE_SIZE = 4;
template <class TCompressor, class TBase>
class TCompressorBase: public TAdditionalStorage<TCompressorBase<TCompressor, TBase>>, public TCompressor, public TCommonData {
public:
- inline TCompressorBase(IOutputStream* slave, ui16 blockSize)
+ inline TCompressorBase(IOutputStream* slave, ui16 blockSize)
: Slave_(slave)
, BlockSize_(blockSize)
{
@@ -76,7 +76,7 @@ public:
}
template <class T>
- static inline void Save(T t, IOutputStream* out) {
+ static inline void Save(T t, IOutputStream* out) {
t = HostToLittle(t);
out->Write(&t, sizeof(t));
@@ -97,14 +97,14 @@ private:
}
inline void WriteBlock(const void* ptr, ui16 len) {
- Y_ASSERT(len <= this->BlockSize());
+ Y_ASSERT(len <= this->BlockSize());
ui8 compressed = false;
if (len) {
const size_t out = this->Compress((const char*)ptr, len, (char*)Block(), this->AdditionalDataLength());
// catch compressor buffer overrun (e.g. SEARCH-2043)
- //Y_VERIFY(out <= this->Hint(this->BlockSize()));
+ //Y_VERIFY(out <= this->Hint(this->BlockSize()));
if (out < len || TCompressor::SaveIncompressibleChunks()) {
compressed = true;
@@ -119,7 +119,7 @@ private:
this->Save(len, &header);
this->Save(compressed, &header);
- using TPart = IOutputStream::TPart;
+ using TPart = IOutputStream::TPart;
if (ptr) {
const TPart parts[] = {
TPart(tmp, sizeof(tmp)),
@@ -133,12 +133,12 @@ private:
}
private:
- IOutputStream* Slave_;
+ IOutputStream* Slave_;
const ui16 BlockSize_;
};
template <class T>
-static inline T GLoad(IInputStream* input) {
+static inline T GLoad(IInputStream* input) {
T t;
if (input->Load(&t, sizeof(t)) != sizeof(t)) {
@@ -150,7 +150,7 @@ static inline T GLoad(IInputStream* input) {
class TDecompressSignature {
public:
- inline TDecompressSignature(IInputStream* input) {
+ inline TDecompressSignature(IInputStream* input) {
if (input->Load(Buffer_, SIGNATURE_SIZE) != SIGNATURE_SIZE) {
ythrow TDecompressorError() << "can not load stream signature";
}
@@ -167,7 +167,7 @@ private:
};
template <class TDecompressor>
-static inline IInputStream* ConsumeSignature(IInputStream* input) {
+static inline IInputStream* ConsumeSignature(IInputStream* input) {
TDecompressSignature sign(input);
if (!sign.Check<TDecompressor>()) {
ythrow TDecompressorError() << "incorrect signature";
@@ -186,7 +186,7 @@ public:
return v;
}
- inline TDecompressorBaseImpl(IInputStream* slave)
+ inline TDecompressorBaseImpl(IInputStream* slave)
: Slave_(slave)
, Input_(nullptr, 0)
, Eof_(false)
@@ -265,7 +265,7 @@ public:
}
protected:
- IInputStream* Slave_;
+ IInputStream* Slave_;
TMemoryInput Input_;
bool Eof_;
const ui32 Version_;
@@ -279,7 +279,7 @@ protected:
template <class TDecompressor, class TBase>
class TDecompressorBase: public TDecompressorBaseImpl<TDecompressor> {
public:
- inline TDecompressorBase(IInputStream* slave)
+ inline TDecompressorBase(IInputStream* slave)
: TDecompressorBaseImpl<TDecompressor>(ConsumeSignature<TDecompressor>(slave))
{
}
@@ -323,12 +323,12 @@ public:
#define DEF_COMPRESSOR(rname, name) \
class rname::TImpl: public TCompressorBase<name, TImpl> { \
public: \
- inline TImpl(IOutputStream* out, ui16 blockSize) \
+ inline TImpl(IOutputStream* out, ui16 blockSize) \
: TCompressorBase<name, TImpl>(out, blockSize) { \
} \
}; \
\
- rname::rname(IOutputStream* slave, ui16 blockSize) \
+ rname::rname(IOutputStream* slave, ui16 blockSize) \
: Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize)) { \
} \
\
@@ -337,12 +337,12 @@ public:
#define DEF_DECOMPRESSOR(rname, name) \
class rname::TImpl: public TDecompressorBase<name, TImpl> { \
public: \
- inline TImpl(IInputStream* in) \
+ inline TImpl(IInputStream* in) \
: TDecompressorBase<name, TImpl>(in) { \
} \
}; \
\
- rname::rname(IInputStream* slave) \
+ rname::rname(IInputStream* slave) \
: Impl_(new TImpl(slave)) { \
} \
\
@@ -420,7 +420,7 @@ public:
return ret;
}
- inline void InitFromStream(IInputStream*) const noexcept {
+ inline void InitFromStream(IInputStream*) const noexcept {
}
};
@@ -446,7 +446,7 @@ public:
return fastlz_decompress(data, len, ptr, max);
}
- inline void InitFromStream(IInputStream*) const noexcept {
+ inline void InitFromStream(IInputStream*) const noexcept {
}
static inline bool SaveIncompressibleChunks() noexcept {
@@ -481,7 +481,7 @@ public:
return res;
}
- inline void InitFromStream(IInputStream*) const noexcept {
+ inline void InitFromStream(IInputStream*) const noexcept {
}
static inline bool SaveIncompressibleChunks() noexcept {
@@ -518,7 +518,7 @@ public:
return srclen;
}
- inline void InitFromStream(IInputStream*) const noexcept {
+ inline void InitFromStream(IInputStream*) const noexcept {
}
static inline bool SaveIncompressibleChunks() noexcept {
@@ -586,7 +586,7 @@ public:
return Table_->Decompress(data, ptr, (char*)Mem_.Get());
}
- inline void InitFromStream(IInputStream* in) {
+ inline void InitFromStream(IInputStream* in) {
const ui8 ver = ::GLoad<ui8>(in);
const ui8 lev = ::GLoad<ui8>(in);
const ui8 mod = ::GLoad<ui8>(in);
@@ -597,7 +597,7 @@ public:
class TLzqCompress::TImpl: public TCompressorBase<TQuickLZCompress, TImpl> {
public:
- inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode)
+ inline TImpl(IOutputStream* out, ui16 blockSize, EVersion ver, unsigned level, EMode mode)
: TCompressorBase<TQuickLZCompress, TImpl>(out, blockSize)
{
memset(AdditionalData(), 0, AdditionalDataLength());
@@ -610,7 +610,7 @@ public:
}
};
-TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode)
+TLzqCompress::TLzqCompress(IOutputStream* slave, ui16 blockSize, EVersion ver, unsigned level, EMode mode)
: Impl_(new (TImpl::Hint(blockSize)) TImpl(slave, blockSize, ver, level, mode))
{
}
@@ -639,7 +639,7 @@ namespace {
// Decompressing input streams without signature verification
template <class TInput, class TDecompressor>
- class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream {
+ class TLzDecompressInput: public TInputHolder<TInput>, public IInputStream {
public:
inline TLzDecompressInput(TInput in)
: Impl_(this->Set(in))
@@ -657,7 +657,7 @@ namespace {
}
template <class T>
-static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) {
+static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature& s, T input) {
if (s.Check<TLZ4>())
return new TLzDecompressInput<T, TLZ4>(input);
@@ -677,7 +677,7 @@ static TAutoPtr<IInputStream> TryOpenLzDecompressorX(const TDecompressSignature&
}
template <class T>
-static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) {
+static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf& signature, T input) {
if (signature.size() == SIGNATURE_SIZE) {
TMemoryInput mem(signature.data(), signature.size());
TDecompressSignature s(&mem);
@@ -689,15 +689,15 @@ static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(const TStringBuf&
}
template <class T>
-static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) {
+static inline TAutoPtr<IInputStream> TryOpenLzDecompressorImpl(T input) {
TDecompressSignature s(&*input);
return TryOpenLzDecompressorX(s, input);
}
template <class T>
-static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) {
- TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input);
+static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) {
+ TAutoPtr<IInputStream> ret = TryOpenLzDecompressorImpl(input);
if (!ret) {
ythrow TDecompressorError() << "Unknown compression format";
@@ -706,26 +706,26 @@ static inline TAutoPtr<IInputStream> OpenLzDecompressorImpl(T input) {
return ret;
}
-TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) {
+TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input) {
return OpenLzDecompressorImpl(input);
}
-TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) {
+TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input) {
return TryOpenLzDecompressorImpl(input);
}
-TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) {
+TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input) {
return TryOpenLzDecompressorImpl(signature, input);
}
-TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) {
+TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) {
return OpenLzDecompressorImpl(input);
}
-TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) {
+TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input) {
return TryOpenLzDecompressorImpl(input);
}
-TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) {
+TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input) {
return TryOpenLzDecompressorImpl(signature, input);
}
diff --git a/library/cpp/streams/lz/lz.h b/library/cpp/streams/lz/lz.h
index 3a2eaad88b..2207a46fe5 100644
--- a/library/cpp/streams/lz/lz.h
+++ b/library/cpp/streams/lz/lz.h
@@ -30,9 +30,9 @@ struct TDecompressorError: public yexception {
*
* @see http://code.google.com/p/lz4/
*/
-class TLz4Compress: public IOutputStream {
+class TLz4Compress: public IOutputStream {
public:
- TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
+ TLz4Compress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
~TLz4Compress() override;
private:
@@ -50,9 +50,9 @@ private:
*
* @see http://code.google.com/p/lz4/
*/
-class TLz4Decompress: public IInputStream {
+class TLz4Decompress: public IInputStream {
public:
- TLz4Decompress(IInputStream* slave);
+ TLz4Decompress(IInputStream* slave);
~TLz4Decompress() override;
private:
@@ -68,9 +68,9 @@ private:
*
* @see http://code.google.com/p/snappy/
*/
-class TSnappyCompress: public IOutputStream {
+class TSnappyCompress: public IOutputStream {
public:
- TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
+ TSnappyCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
~TSnappyCompress() override;
private:
@@ -88,9 +88,9 @@ private:
*
* @see http://code.google.com/p/snappy/
*/
-class TSnappyDecompress: public IInputStream {
+class TSnappyDecompress: public IInputStream {
public:
- TSnappyDecompress(IInputStream* slave);
+ TSnappyDecompress(IInputStream* slave);
~TSnappyDecompress() override;
private:
@@ -104,9 +104,9 @@ private:
/**
* MiniLZO compressing stream.
*/
-class TLzoCompress: public IOutputStream {
+class TLzoCompress: public IOutputStream {
public:
- TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
+ TLzoCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
~TLzoCompress() override;
private:
@@ -122,9 +122,9 @@ private:
/**
* MiniLZO decompressing stream.
*/
-class TLzoDecompress: public IInputStream {
+class TLzoDecompress: public IInputStream {
public:
- TLzoDecompress(IInputStream* slave);
+ TLzoDecompress(IInputStream* slave);
~TLzoDecompress() override;
private:
@@ -138,9 +138,9 @@ private:
/**
* FastLZ compressing stream.
*/
-class TLzfCompress: public IOutputStream {
+class TLzfCompress: public IOutputStream {
public:
- TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
+ TLzfCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15);
~TLzfCompress() override;
private:
@@ -156,9 +156,9 @@ private:
/**
* FastLZ decompressing stream.
*/
-class TLzfDecompress: public IInputStream {
+class TLzfDecompress: public IInputStream {
public:
- TLzfDecompress(IInputStream* slave);
+ TLzfDecompress(IInputStream* slave);
~TLzfDecompress() override;
private:
@@ -172,7 +172,7 @@ private:
/**
* QuickLZ compressing stream.
*/
-class TLzqCompress: public IOutputStream {
+class TLzqCompress: public IOutputStream {
public:
enum EVersion {
V_1_31 = 0,
@@ -189,7 +189,7 @@ public:
M_1000000 = 2
};
- TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15,
+ TLzqCompress(IOutputStream* slave, ui16 maxBlockSize = 1 << 15,
EVersion ver = V_1_31,
unsigned level = 0,
EMode mode = M_0);
@@ -208,9 +208,9 @@ private:
/**
* QuickLZ decompressing stream.
*/
-class TLzqDecompress: public IInputStream {
+class TLzqDecompress: public IInputStream {
public:
- TLzqDecompress(IInputStream* slave);
+ TLzqDecompress(IInputStream* slave);
~TLzqDecompress() override;
private:
@@ -233,10 +233,10 @@ private:
* @param input Stream to decompress.
* @return Decompressing proxy input stream.
*/
-TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input);
-TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input);
-TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input);
+TAutoPtr<IInputStream> OpenLzDecompressor(IInputStream* input);
+TAutoPtr<IInputStream> TryOpenLzDecompressor(IInputStream* input);
+TAutoPtr<IInputStream> TryOpenLzDecompressor(const TStringBuf& signature, IInputStream* input);
-TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input);
-TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input);
-TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input);
+TAutoPtr<IInputStream> OpenOwnedLzDecompressor(TAutoPtr<IInputStream> input);
+TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(TAutoPtr<IInputStream> input);
+TAutoPtr<IInputStream> TryOpenOwnedLzDecompressor(const TStringBuf& signature, TAutoPtr<IInputStream> input);
diff --git a/library/cpp/streams/lz/lz_ut.cpp b/library/cpp/streams/lz/lz_ut.cpp
index 6876f070fc..ffa0065f46 100644
--- a/library/cpp/streams/lz/lz_ut.cpp
+++ b/library/cpp/streams/lz/lz_ut.cpp
@@ -31,7 +31,7 @@ namespace {
seed += 1;
}
} while (!sym);
- Y_ASSERT(sym);
+ Y_ASSERT(sym);
j = (j + 1) % entropy.size();
result += char(sym + entropy[j]);
}
@@ -75,7 +75,7 @@ static const TVector<size_t> bufferSizes = {
namespace {
template <TLzqCompress::EVersion Ver, int Level, TLzqCompress::EMode Mode>
struct TLzqCompressX: public TLzqCompress {
- inline TLzqCompressX(IOutputStream* out, size_t bufLen)
+ inline TLzqCompressX(IOutputStream* out, size_t bufLen)
: TLzqCompress(out, bufLen, Ver, Level, Mode)
{
}
@@ -160,9 +160,9 @@ static inline void TestDecompress() {
}
}
-class TMixedDecompress: public IInputStream {
+class TMixedDecompress: public IInputStream {
public:
- TMixedDecompress(IInputStream* input)
+ TMixedDecompress(IInputStream* input)
: Slave_(OpenLzDecompressor(input).Release())
{
}
@@ -173,7 +173,7 @@ private:
}
private:
- THolder<IInputStream> Slave_;
+ THolder<IInputStream> Slave_;
};
template <class C>
@@ -188,63 +188,63 @@ static inline void TestDecompressError() {
UNIT_ASSERT_EXCEPTION(TestDecompress<D>(), TDecompressorError);
}
-Y_UNIT_TEST_SUITE(TLzTest) {
- Y_UNIT_TEST(TestLzo) {
+Y_UNIT_TEST_SUITE(TLzTest) {
+ Y_UNIT_TEST(TestLzo) {
TestCompress<TLzoCompress>();
TestDecompress<TLzoDecompress>();
}
- Y_UNIT_TEST(TestLzf) {
+ Y_UNIT_TEST(TestLzf) {
TestCompress<TLzfCompress>();
TestDecompress<TLzfDecompress>();
}
- Y_UNIT_TEST(TestLzq) {
+ Y_UNIT_TEST(TestLzq) {
TestCompress<TLzqCompress>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq151_1) {
+ Y_UNIT_TEST(TestLzq151_1) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 1, TLzqCompress::M_0>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq151_2) {
+ Y_UNIT_TEST(TestLzq151_2) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 2, TLzqCompress::M_100000>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq151_3) {
+ Y_UNIT_TEST(TestLzq151_3) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_51, 3, TLzqCompress::M_1000000>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq140_1) {
+ Y_UNIT_TEST(TestLzq140_1) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 1, TLzqCompress::M_0>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq140_2) {
+ Y_UNIT_TEST(TestLzq140_2) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 2, TLzqCompress::M_100000>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLzq140_3) {
+ Y_UNIT_TEST(TestLzq140_3) {
TestCompress<TLzqCompressX<TLzqCompress::V_1_40, 3, TLzqCompress::M_1000000>>();
TestDecompress<TLzqDecompress>();
}
- Y_UNIT_TEST(TestLz4) {
+ Y_UNIT_TEST(TestLz4) {
TestCompress<TLz4Compress>();
TestDecompress<TLz4Decompress>();
}
- Y_UNIT_TEST(TestSnappy) {
+ Y_UNIT_TEST(TestSnappy) {
TestCompress<TSnappyCompress>();
TestDecompress<TSnappyDecompress>();
}
- Y_UNIT_TEST(TestGeneric) {
+ Y_UNIT_TEST(TestGeneric) {
TestMixedDecompress<TLzoCompress>();
TestMixedDecompress<TLzfCompress>();
TestMixedDecompress<TLzqCompress>();
@@ -252,7 +252,7 @@ Y_UNIT_TEST_SUITE(TLzTest) {
TestMixedDecompress<TSnappyCompress>();
}
- Y_UNIT_TEST(TestDecompressorError) {
+ Y_UNIT_TEST(TestDecompressorError) {
TestDecompressError<TLzoDecompress, TLzfCompress>();
TestDecompressError<TLzfDecompress, TLzqCompress>();
TestDecompressError<TLzqDecompress, TLz4Compress>();
@@ -261,7 +261,7 @@ Y_UNIT_TEST_SUITE(TLzTest) {
TestDecompressError<TMixedDecompress, TBufferedOutput>();
}
- Y_UNIT_TEST(TestFactory) {
+ Y_UNIT_TEST(TestFactory) {
TStringStream ss;
{
@@ -271,7 +271,7 @@ Y_UNIT_TEST_SUITE(TLzTest) {
c.Finish();
}
- TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str())));
+ TAutoPtr<IInputStream> is(OpenOwnedLzDecompressor(new TStringInput(ss.Str())));
UNIT_ASSERT_EQUAL(is->ReadAll(), "123456789");
}