aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams
diff options
context:
space:
mode:
authormvel <mvel@yandex-team.ru>2022-02-10 16:45:41 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:41 +0300
commitbd30392c4cc92487950adc375c07adf52da1d592 (patch)
treee8d1a3f19b7fc890bcef6e4cc5de41f1d88c9ac3 /library/cpp/streams
parent5d50718e66d9c037dc587a0211110b7d25a66185 (diff)
downloadydb-bd30392c4cc92487950adc375c07adf52da1d592.tar.gz
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/streams')
-rw-r--r--library/cpp/streams/lz/lz.cpp14
-rw-r--r--library/cpp/streams/lz/lz_ut.cpp158
2 files changed, 86 insertions, 86 deletions
diff --git a/library/cpp/streams/lz/lz.cpp b/library/cpp/streams/lz/lz.cpp
index b65bb3ed96..a94d5f1f23 100644
--- a/library/cpp/streams/lz/lz.cpp
+++ b/library/cpp/streams/lz/lz.cpp
@@ -103,7 +103,7 @@ private:
if (len) {
const size_t out = this->Compress((const char*)ptr, len, (char*)Block(), this->AdditionalDataLength());
- // catch compressor buffer overrun (e.g. SEARCH-2043)
+ // catch compressor buffer overrun (e.g. SEARCH-2043)
//Y_VERIFY(out <= this->Hint(this->BlockSize()));
if (out < len || TCompressor::SaveIncompressibleChunks()) {
@@ -377,9 +377,9 @@ public:
}
static inline size_t Hint(size_t len) noexcept {
- // see SEARCH-2043 and, e.g. examples at
- // http://stackoverflow.com/questions/4235019/how-to-get-lzo-to-work-with-a-file-stream
- return len + (len / 16) + 64 + 3;
+ // see SEARCH-2043 and, e.g. examples at
+ // http://stackoverflow.com/questions/4235019/how-to-get-lzo-to-work-with-a-file-stream
+ return len + (len / 16) + 64 + 3;
}
static inline bool SaveIncompressibleChunks() noexcept {
@@ -502,7 +502,7 @@ public:
static const char signature[];
static inline size_t Hint(size_t len) noexcept {
- return Max<size_t>(snappy::MaxCompressedLength(len), 100);
+ return Max<size_t>(snappy::MaxCompressedLength(len), 100);
}
inline size_t Compress(const char* data, size_t len, char* ptr, size_t /*dstMaxSize*/) {
@@ -561,8 +561,8 @@ public:
}
inline bool SaveIncompressibleChunks() const noexcept {
- // we must save incompressible chunks "as is"
- // after compressor run in streaming mode
+ // we must save incompressible chunks "as is"
+ // after compressor run in streaming mode
return Table_->Setting(3);
}
diff --git a/library/cpp/streams/lz/lz_ut.cpp b/library/cpp/streams/lz/lz_ut.cpp
index 6876f070fc..b3ee24af7b 100644
--- a/library/cpp/streams/lz/lz_ut.cpp
+++ b/library/cpp/streams/lz/lz_ut.cpp
@@ -4,75 +4,75 @@
#include <library/cpp/resource/resource.h>
#include <util/stream/file.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <util/system/tempfile.h>
#include <util/generic/singleton.h>
#define LDATA "./ldata"
-#define LDATA_RANDOM "./ldata.random"
+#define LDATA_RANDOM "./ldata.random"
static const TString data = "aa aaa aa aaa aa aaa bb bbb bb bbb bb bbb";
namespace {
- /**
- * Produces well-formed random crap
- **/
+ /**
+ * Produces well-formed random crap
+ **/
TString RandomString(size_t size) {
TString entropy(NResource::Find("/random.data"));
TString result;
- size_t seed = 1;
- size_t j = 0;
- for (size_t i = 0; i < size; ++i) {
- seed *= 3;
- char sym;
- do {
- sym = char((seed ^ i) % 256);
- if (!sym) {
- seed += 1;
- }
- } while (!sym);
+ size_t seed = 1;
+ size_t j = 0;
+ for (size_t i = 0; i < size; ++i) {
+ seed *= 3;
+ char sym;
+ do {
+ sym = char((seed ^ i) % 256);
+ if (!sym) {
+ seed += 1;
+ }
+ } while (!sym);
Y_ASSERT(sym);
j = (j + 1) % entropy.size();
- result += char(sym + entropy[j]);
- }
- return result;
- }
-
+ result += char(sym + entropy[j]);
+ }
+ return result;
+ }
+
TVector<TString> InitRandomData() {
static const TVector<size_t> sizes = {
- 0,
- 1,
- 127,
- 2017,
- 32767,
- };
-
+ 0,
+ 1,
+ 127,
+ 2017,
+ 32767,
+ };
+
TVector<TString> result;
- for (auto size : sizes) {
- result.push_back(RandomString(size));
- }
+ for (auto size : sizes) {
+ result.push_back(RandomString(size));
+ }
result.push_back(NResource::Find("/request.data"));
- return result;
- }
-
+ return result;
+ }
+
TString TestFileName(const TString& d, size_t bufferSize) {
return LDATA_RANDOM + TString(".") + ToString(d.size()) + TString(".") + ToString(bufferSize);
- }
-
+ }
+
struct TRandomData: public TVector<TString> {
inline TRandomData() {
InitRandomData().swap(*this);
}
};
}
-
+
static const TVector<size_t> bufferSizes = {
- 127,
- 1024,
- 32768,
-};
-
-namespace {
+ 127,
+ 1024,
+ 32768,
+};
+
+namespace {
template <TLzqCompress::EVersion Ver, int Level, TLzqCompress::EMode Mode>
struct TLzqCompressX: public TLzqCompress {
inline TLzqCompressX(IOutputStream* out, size_t bufLen)
@@ -83,7 +83,7 @@ namespace {
}
template <class C>
-static inline void TestGoodDataCompress() {
+static inline void TestGoodDataCompress() {
TFixedBufferFileOutput o(LDATA);
C c(&o, 1024);
@@ -99,28 +99,28 @@ static inline void TestGoodDataCompress() {
o.Finish();
}
-template <class C>
+template <class C>
static inline void TestIncompressibleDataCompress(const TString& d, size_t bufferSize) {
TString testFileName = TestFileName(d, bufferSize);
TFixedBufferFileOutput o(testFileName);
- C c(&o, bufferSize);
+ C c(&o, bufferSize);
c.Write(d.data(), d.size());
- c.Finish();
- o.Finish();
-}
-
-template <class C>
-static inline void TestCompress() {
- TestGoodDataCompress<C>();
- for (auto bufferSize : bufferSizes) {
+ c.Finish();
+ o.Finish();
+}
+
+template <class C>
+static inline void TestCompress() {
+ TestGoodDataCompress<C>();
+ for (auto bufferSize : bufferSizes) {
for (auto rd : *Singleton<TRandomData>()) {
- TestIncompressibleDataCompress<C>(rd, bufferSize);
- }
- }
-}
-
+ TestIncompressibleDataCompress<C>(rd, bufferSize);
+ }
+ }
+}
+
template <class D>
-static inline void TestGoodDataDecompress() {
+static inline void TestGoodDataDecompress() {
TTempFile tmpFile(LDATA);
{
@@ -137,29 +137,29 @@ static inline void TestGoodDataDecompress() {
}
}
-template <class D>
+template <class D>
static inline void TestIncompressibleDataDecompress(const TString& d, size_t bufferSize) {
TString testFileName = TestFileName(d, bufferSize);
- TTempFile tmpFile(testFileName);
-
- {
+ TTempFile tmpFile(testFileName);
+
+ {
TFileInput i(testFileName);
- D ld(&i);
-
- UNIT_ASSERT_EQUAL(ld.ReadAll(), d);
- }
-}
-
-template <class D>
-static inline void TestDecompress() {
- TestGoodDataDecompress<D>();
- for (auto bufferSize : bufferSizes) {
+ D ld(&i);
+
+ UNIT_ASSERT_EQUAL(ld.ReadAll(), d);
+ }
+}
+
+template <class D>
+static inline void TestDecompress() {
+ TestGoodDataDecompress<D>();
+ for (auto bufferSize : bufferSizes) {
for (auto rd : *Singleton<TRandomData>()) {
- TestIncompressibleDataDecompress<D>(rd, bufferSize);
- }
- }
-}
-
+ TestIncompressibleDataDecompress<D>(rd, bufferSize);
+ }
+ }
+}
+
class TMixedDecompress: public IInputStream {
public:
TMixedDecompress(IInputStream* input)