aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authoralexcrush <alexcrush@yandex-team.ru>2022-02-10 16:50:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:33 +0300
commit34f0683c2d7731f2f9f59966c12e602f405fa0d6 (patch)
tree9af7dd74efcfa3d8aa7b40bd757ad8f2d89f6902 /util
parenta1d67d6a31f789aa011250c3edce5751c0cadad2 (diff)
downloadydb-34f0683c2d7731f2f9f59966c12e602f405fa0d6.tar.gz
Restoring authorship annotation for <alexcrush@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/stream/zlib.cpp32
-rw-r--r--util/stream/zlib.h20
-rw-r--r--util/stream/zlib_ut.cpp62
3 files changed, 57 insertions, 57 deletions
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 60f4e9439f..cb45dd1e39 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -97,10 +97,10 @@ public:
inflateEnd(Z());
}
- void SetAllowMultipleStreams(bool allowMultipleStreams) {
- AllowMultipleStreams_ = allowMultipleStreams;
- }
-
+ void SetAllowMultipleStreams(bool allowMultipleStreams) {
+ AllowMultipleStreams_ = allowMultipleStreams;
+ }
+
inline size_t Read(void* buf, size_t size) {
Z()->next_out = (unsigned char*)buf;
Z()->avail_out = size;
@@ -119,12 +119,12 @@ public:
}
case Z_STREAM_END: {
- if (AllowMultipleStreams_) {
- if (inflateReset(Z()) != Z_OK) {
- ythrow TZLibDecompressorError() << "inflate reset error(" << GetErrMsg() << ")";
- }
- } else {
- return size - Z()->avail_out;
+ if (AllowMultipleStreams_) {
+ if (inflateReset(Z()) != Z_OK) {
+ ythrow TZLibDecompressorError() << "inflate reset error(" << GetErrMsg() << ")";
+ }
+ } else {
+ return size - Z()->avail_out;
}
[[fallthrough]];
@@ -150,14 +150,14 @@ private:
inline bool FillInputBuffer() {
return Next(&Z()->next_in, &Z()->avail_in);
}
-
+
void SetDict() {
if (inflateSetDictionary(Z(), (const Bytef*)Dict.data(), Dict.size()) != Z_OK) {
ythrow TZLibCompressorError() << "can not set inflate dictionary";
}
}
- bool AllowMultipleStreams_ = true;
+ bool AllowMultipleStreams_ = true;
TStringBuf Dict;
};
@@ -328,10 +328,10 @@ TZLibDecompress::TZLibDecompress(IInputStream* input, ZLib::StreamType type, siz
{
}
-void TZLibDecompress::SetAllowMultipleStreams(bool allowMultipleStreams) {
- Impl_->SetAllowMultipleStreams(allowMultipleStreams);
-}
-
+void TZLibDecompress::SetAllowMultipleStreams(bool allowMultipleStreams) {
+ Impl_->SetAllowMultipleStreams(allowMultipleStreams);
+}
+
TZLibDecompress::~TZLibDecompress() = default;
size_t TZLibDecompress::DoRead(void* buf, size_t size) {
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index e7de7c81b7..02192b8dc2 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -51,17 +51,17 @@ public:
TZLibDecompress(IInputStream* input, ZLib::StreamType type = ZLib::Auto, size_t buflen = ZLib::ZLIB_BUF_LEN,
TStringBuf dict = {});
- /**
- * Allows/disallows multiple sequential compressed streams. Allowed by default.
- *
- * If multiple streams are allowed, their decompressed content will be concatenated.
- * If multiple streams are disabled, then only first stream is decompressed. After that end
+ /**
+ * Allows/disallows multiple sequential compressed streams. Allowed by default.
+ *
+ * If multiple streams are allowed, their decompressed content will be concatenated.
+ * If multiple streams are disabled, then only first stream is decompressed. After that end
* of IInputStream will have happen, i.e. method Read() will return 0.
- *
- * @param allowMultipleStreams - flag to allow (true) or disable (false) multiple streams.
- */
- void SetAllowMultipleStreams(bool allowMultipleStreams);
-
+ *
+ * @param allowMultipleStreams - flag to allow (true) or disable (false) multiple streams.
+ */
+ void SetAllowMultipleStreams(bool allowMultipleStreams);
+
~TZLibDecompress() override;
protected:
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index 2290b4a9de..b8a9e03dae 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
}
}
-
+
Y_UNIT_TEST(Dictionary) {
static constexpr TStringBuf data = "<html><body></body></html>";
static constexpr TStringBuf dict = "</<html><body>";
@@ -91,26 +91,26 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
}
Y_UNIT_TEST(DecompressTwoStreams) {
- // Check that Decompress(Compress(X) + Compress(Y)) == X + Y
- TTempFile tmpFile(ZDATA);
- {
+ // Check that Decompress(Compress(X) + Compress(Y)) == X + Y
+ TTempFile tmpFile(ZDATA);
+ {
TUnbufferedFileOutput o(ZDATA);
- TZLibCompress c1(&o, ZLib::ZLib);
+ TZLibCompress c1(&o, ZLib::ZLib);
c1.Write(DATA.data(), DATA.size());
- c1.Finish();
- TZLibCompress c2(&o, ZLib::ZLib);
+ c1.Finish();
+ TZLibCompress c2(&o, ZLib::ZLib);
c2.Write(DATA2.data(), DATA2.size());
- c2.Finish();
- o.Finish();
- }
- {
+ c2.Finish();
+ o.Finish();
+ }
+ {
TUnbufferedFileInput i(ZDATA);
- TZLibDecompress d(&i);
-
+ TZLibDecompress d(&i);
+
UNIT_ASSERT_EQUAL(d.ReadAll(), DATA + DATA2);
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(CompressionExceptionSegfault) {
TVector<char> buf(512 * 1024);
EntropyPool().Load(buf.data(), buf.size());
@@ -127,26 +127,26 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
}
Y_UNIT_TEST(DecompressFirstOfTwoStreams) {
- // Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed
- TTempFile tmpFile(ZDATA);
- {
+ // Check that Decompress(Compress(X) + Compress(Y)) == X when single stream is allowed
+ TTempFile tmpFile(ZDATA);
+ {
TUnbufferedFileOutput o(ZDATA);
- TZLibCompress c1(&o, ZLib::ZLib);
+ TZLibCompress c1(&o, ZLib::ZLib);
c1.Write(DATA.data(), DATA.size());
- c1.Finish();
- TZLibCompress c2(&o, ZLib::ZLib);
+ c1.Finish();
+ TZLibCompress c2(&o, ZLib::ZLib);
c2.Write(DATA2.data(), DATA2.size());
- c2.Finish();
- o.Finish();
- }
- {
+ c2.Finish();
+ o.Finish();
+ }
+ {
TUnbufferedFileInput i(ZDATA);
- TZLibDecompress d(&i);
- d.SetAllowMultipleStreams(false);
-
+ TZLibDecompress d(&i);
+ d.SetAllowMultipleStreams(false);
+
UNIT_ASSERT_EQUAL(d.ReadAll(), DATA);
- }
- }
+ }
+ }
Y_UNIT_TEST(CompressFlush) {
TString data = "";