aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream
diff options
context:
space:
mode:
authormyltsev <myltsev@yandex-team.ru>2022-02-10 16:46:03 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:03 +0300
commit9166d66c30c23c9e85a7c88185a068987148d23f (patch)
tree421bdcec5755d9e441c485560aab5ab8d74c7475 /util/stream
parent8d3a5ed3a188a34167eaee54f1691ce5c9edf2f3 (diff)
downloadydb-9166d66c30c23c9e85a7c88185a068987148d23f.tar.gz
Restoring authorship annotation for <myltsev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r--util/stream/file.cpp2
-rw-r--r--util/stream/file_ut.cpp30
-rw-r--r--util/stream/mem.cpp4
-rw-r--r--util/stream/str.h22
-rw-r--r--util/stream/zlib.cpp48
-rw-r--r--util/stream/zlib.h6
-rw-r--r--util/stream/zlib_ut.cpp26
7 files changed, 69 insertions, 69 deletions
diff --git a/util/stream/file.cpp b/util/stream/file.cpp
index dc5d2f6311..895e627966 100644
--- a/util/stream/file.cpp
+++ b/util/stream/file.cpp
@@ -20,7 +20,7 @@ TUnbufferedFileInput::TUnbufferedFileInput(const TFile& file)
}
size_t TUnbufferedFileInput::DoRead(void* buf, size_t len) {
- return File_.ReadOrFail(buf, len);
+ return File_.ReadOrFail(buf, len);
}
size_t TUnbufferedFileInput::DoSkip(size_t len) {
diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp
index ac0f09796e..7780a72e04 100644
--- a/util/stream/file_ut.cpp
+++ b/util/stream/file_ut.cpp
@@ -56,19 +56,19 @@ Y_UNIT_TEST_SUITE(TFileTest) {
UNIT_ASSERT(s.empty());
}
}
-
-#ifdef _unix_
- Y_UNIT_TEST(PipeReadLineTest) {
- int fds[2];
- UNIT_ASSERT(pipe(fds) == 0);
- TFile readEnd(fds[0]);
- TFileInput fileInput(readEnd);
- UNIT_ASSERT_VALUES_EQUAL(write(fds[1], "hello\n", 6), 6);
-
- TString line;
- UNIT_ASSERT(fileInput.ReadLine(line));
- UNIT_ASSERT_STRINGS_EQUAL(line, "hello");
- close(fds[1]);
- }
-#endif
+
+#ifdef _unix_
+ Y_UNIT_TEST(PipeReadLineTest) {
+ int fds[2];
+ UNIT_ASSERT(pipe(fds) == 0);
+ TFile readEnd(fds[0]);
+ TFileInput fileInput(readEnd);
+ UNIT_ASSERT_VALUES_EQUAL(write(fds[1], "hello\n", 6), 6);
+
+ TString line;
+ UNIT_ASSERT(fileInput.ReadLine(line));
+ UNIT_ASSERT_STRINGS_EQUAL(line, "hello");
+ close(fds[1]);
+ }
+#endif
}
diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp
index 22a3339e27..31b46e907f 100644
--- a/util/stream/mem.cpp
+++ b/util/stream/mem.cpp
@@ -18,8 +18,8 @@ TMemoryInput::TMemoryInput(const TStringBuf buf) noexcept
: Buf_(buf.data())
, Len_(buf.size())
{
-}
-
+}
+
TMemoryInput::~TMemoryInput() = default;
size_t TMemoryInput::DoNext(const void** ptr, size_t len) {
diff --git a/util/stream/str.h b/util/stream/str.h
index 028bd572c0..adac7ec4bc 100644
--- a/util/stream/str.h
+++ b/util/stream/str.h
@@ -26,7 +26,7 @@ public:
* this stream is in use.
*
* For reading data from `TStringBuf`s, see `TMemoryInput` (`util/stream/mem.h`).
- *
+ *
* @param s String to read from.
*/
inline TStringInput(const TString& s) noexcept
@@ -108,27 +108,27 @@ private:
* String input/output stream, similar to `std::stringstream`.
*/
class TStringStream: private TEmbedPolicy<TString>, public TStringInput, public TStringOutput {
- using TEmbeddedString = TEmbedPolicy<TString>;
+ using TEmbeddedString = TEmbedPolicy<TString>;
public:
inline TStringStream()
- : TEmbeddedString()
- , TStringInput(*TEmbeddedString::Ptr())
- , TStringOutput(*TEmbeddedString::Ptr())
+ : TEmbeddedString()
+ , TStringInput(*TEmbeddedString::Ptr())
+ , TStringOutput(*TEmbeddedString::Ptr())
{
}
inline TStringStream(const TString& string)
- : TEmbeddedString(string)
- , TStringInput(*TEmbeddedString::Ptr())
- , TStringOutput(*TEmbeddedString::Ptr())
+ : TEmbeddedString(string)
+ , TStringInput(*TEmbeddedString::Ptr())
+ , TStringOutput(*TEmbeddedString::Ptr())
{
}
inline TStringStream(const TStringStream& other)
- : TEmbeddedString(other.Str())
- , TStringInput(*TEmbeddedString::Ptr())
- , TStringOutput(*TEmbeddedString::Ptr())
+ : TEmbeddedString(other.Str())
+ , TStringInput(*TEmbeddedString::Ptr())
+ , TStringOutput(*TEmbeddedString::Ptr())
{
}
diff --git a/util/stream/zlib.cpp b/util/stream/zlib.cpp
index 60f4e9439f..a9fe352239 100644
--- a/util/stream/zlib.cpp
+++ b/util/stream/zlib.cpp
@@ -80,17 +80,17 @@ namespace {
class TZLibDecompress::TImpl: private TZLibCommon, public TChunkedZeroCopyInput {
public:
- inline TImpl(IZeroCopyInput* in, ZLib::StreamType type, TStringBuf dict)
+ inline TImpl(IZeroCopyInput* in, ZLib::StreamType type, TStringBuf dict)
: TChunkedZeroCopyInput(in)
- , Dict(dict)
+ , Dict(dict)
{
if (inflateInit2(Z(), opts[type]) != Z_OK) {
ythrow TZLibDecompressorError() << "can not init inflate engine";
}
-
- if (dict.size() && type == ZLib::Raw) {
- SetDict();
- }
+
+ if (dict.size() && type == ZLib::Raw) {
+ SetDict();
+ }
}
virtual ~TImpl() {
@@ -113,11 +113,11 @@ public:
}
switch (inflate(Z(), Z_SYNC_FLUSH)) {
- case Z_NEED_DICT: {
- SetDict();
- continue;
- }
-
+ case Z_NEED_DICT: {
+ SetDict();
+ continue;
+ }
+
case Z_STREAM_END: {
if (AllowMultipleStreams_) {
if (inflateReset(Z()) != Z_OK) {
@@ -151,21 +151,21 @@ private:
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";
- }
- }
-
+ void SetDict() {
+ if (inflateSetDictionary(Z(), (const Bytef*)Dict.data(), Dict.size()) != Z_OK) {
+ ythrow TZLibCompressorError() << "can not set inflate dictionary";
+ }
+ }
+
bool AllowMultipleStreams_ = true;
- TStringBuf Dict;
+ TStringBuf Dict;
};
namespace {
class TDecompressStream: public IZeroCopyInput, public TZLibDecompress::TImpl, public TAdditionalStorage<TDecompressStream> {
public:
- inline TDecompressStream(IInputStream* input, ZLib::StreamType type, TStringBuf dict)
- : TZLibDecompress::TImpl(this, type, dict)
+ inline TDecompressStream(IInputStream* input, ZLib::StreamType type, TStringBuf dict)
+ : TZLibDecompress::TImpl(this, type, dict)
, Stream_(input)
{
}
@@ -318,13 +318,13 @@ private:
THolder<gz_header> GZHeader_;
};
-TZLibDecompress::TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type, TStringBuf dict)
- : Impl_(new TZeroCopyDecompress(input, type, dict))
+TZLibDecompress::TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type, TStringBuf dict)
+ : Impl_(new TZeroCopyDecompress(input, type, dict))
{
}
-TZLibDecompress::TZLibDecompress(IInputStream* input, ZLib::StreamType type, size_t buflen, TStringBuf dict)
- : Impl_(new (buflen) TDecompressStream(input, type, dict))
+TZLibDecompress::TZLibDecompress(IInputStream* input, ZLib::StreamType type, size_t buflen, TStringBuf dict)
+ : Impl_(new (buflen) TDecompressStream(input, type, dict))
{
}
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index e7de7c81b7..ead8c1e013 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -47,9 +47,9 @@ namespace ZLib {
*/
class TZLibDecompress: public IInputStream {
public:
- TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type = ZLib::Auto, TStringBuf dict = {});
- TZLibDecompress(IInputStream* input, ZLib::StreamType type = ZLib::Auto, size_t buflen = ZLib::ZLIB_BUF_LEN,
- TStringBuf dict = {});
+ TZLibDecompress(IZeroCopyInput* input, ZLib::StreamType type = ZLib::Auto, TStringBuf dict = {});
+ 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.
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index 2290b4a9de..15f77f3ce4 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -75,21 +75,21 @@ Y_UNIT_TEST_SUITE(TZLibTest) {
}
}
- Y_UNIT_TEST(Dictionary) {
+ Y_UNIT_TEST(Dictionary) {
static constexpr TStringBuf data = "<html><body></body></html>";
static constexpr TStringBuf dict = "</<html><body>";
- for (auto type : {ZLib::Raw, ZLib::ZLib}) {
- TStringStream compressed;
- {
- TZLibCompress compressor(TZLibCompress::TParams(&compressed).SetDict(dict).SetType(type));
- compressor.Write(data);
- }
-
- TZLibDecompress decompressor(&compressed, type, ZLib::ZLIB_BUF_LEN, dict);
- UNIT_ASSERT_STRINGS_EQUAL(decompressor.ReadAll(), data);
- }
- }
-
+ for (auto type : {ZLib::Raw, ZLib::ZLib}) {
+ TStringStream compressed;
+ {
+ TZLibCompress compressor(TZLibCompress::TParams(&compressed).SetDict(dict).SetType(type));
+ compressor.Write(data);
+ }
+
+ TZLibDecompress decompressor(&compressed, type, ZLib::ZLIB_BUF_LEN, dict);
+ UNIT_ASSERT_STRINGS_EQUAL(decompressor.ReadAll(), data);
+ }
+ }
+
Y_UNIT_TEST(DecompressTwoStreams) {
// Check that Decompress(Compress(X) + Compress(Y)) == X + Y
TTempFile tmpFile(ZDATA);