snappy 0.0.17 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/.gitignore +2 -1
- data/.gitmodules +1 -1
- data/Dockerfile +13 -0
- data/Gemfile +4 -0
- data/README.md +29 -5
- data/Rakefile +32 -29
- data/ext/api.c +6 -1
- data/ext/extconf.rb +23 -16
- data/lib/snappy/hadoop/reader.rb +62 -0
- data/lib/snappy/hadoop/writer.rb +51 -0
- data/lib/snappy/hadoop.rb +22 -0
- data/lib/snappy/reader.rb +14 -10
- data/lib/snappy/shim.rb +1 -1
- data/lib/snappy/version.rb +1 -1
- data/lib/snappy.rb +5 -4
- data/snappy.gemspec +13 -13
- data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
- data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
- data/test/snappy_hadoop_test.rb +26 -0
- data/test/snappy_reader_test.rb +148 -0
- data/test/snappy_test.rb +95 -0
- data/test/snappy_writer_test.rb +55 -0
- data/test/test_helper.rb +7 -0
- data/test.sh +3 -0
- data/vendor/snappy/CMakeLists.txt +297 -0
- data/vendor/snappy/CONTRIBUTING.md +26 -0
- data/vendor/snappy/NEWS +40 -0
- data/vendor/snappy/{README → README.md} +27 -18
- data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/vendor/snappy/cmake/config.h.in +62 -0
- data/vendor/snappy/docs/README.md +72 -0
- data/vendor/snappy/snappy-internal.h +22 -18
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +116 -38
- data/vendor/snappy/snappy-stubs-public.h.in +20 -46
- data/vendor/snappy/snappy-test.cc +26 -22
- data/vendor/snappy/snappy-test.h +24 -98
- data/vendor/snappy/snappy.cc +380 -183
- data/vendor/snappy/snappy.h +14 -10
- data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
- data/vendor/snappy/snappy_unittest.cc +236 -261
- metadata +37 -92
- data/.travis.yml +0 -26
- data/smoke.sh +0 -8
- data/test/test-snappy-reader.rb +0 -129
- data/test/test-snappy-writer.rb +0 -55
- data/test/test-snappy.rb +0 -58
- data/vendor/snappy/ChangeLog +0 -2468
- data/vendor/snappy/INSTALL +0 -370
- data/vendor/snappy/Makefile +0 -982
- data/vendor/snappy/Makefile.am +0 -26
- data/vendor/snappy/Makefile.in +0 -982
- data/vendor/snappy/aclocal.m4 +0 -9738
- data/vendor/snappy/autogen.sh +0 -12
- data/vendor/snappy/autom4te.cache/output.0 +0 -18856
- data/vendor/snappy/autom4te.cache/output.1 +0 -18852
- data/vendor/snappy/autom4te.cache/requests +0 -297
- data/vendor/snappy/autom4te.cache/traces.0 +0 -2689
- data/vendor/snappy/autom4te.cache/traces.1 +0 -714
- data/vendor/snappy/config.guess +0 -1530
- data/vendor/snappy/config.h +0 -135
- data/vendor/snappy/config.h.in +0 -134
- data/vendor/snappy/config.log +0 -1640
- data/vendor/snappy/config.status +0 -2318
- data/vendor/snappy/config.sub +0 -1773
- data/vendor/snappy/configure +0 -18852
- data/vendor/snappy/configure.ac +0 -134
- data/vendor/snappy/depcomp +0 -688
- data/vendor/snappy/install-sh +0 -527
- data/vendor/snappy/libtool +0 -10246
- data/vendor/snappy/ltmain.sh +0 -9661
- data/vendor/snappy/m4/gtest.m4 +0 -74
- data/vendor/snappy/m4/libtool.m4 +0 -8001
- data/vendor/snappy/m4/ltoptions.m4 +0 -384
- data/vendor/snappy/m4/ltsugar.m4 +0 -123
- data/vendor/snappy/m4/ltversion.m4 +0 -23
- data/vendor/snappy/m4/lt~obsolete.m4 +0 -98
- data/vendor/snappy/missing +0 -331
- data/vendor/snappy/snappy-stubs-public.h +0 -100
- data/vendor/snappy/snappy.pc +0 -10
- data/vendor/snappy/snappy.pc.in +0 -10
- data/vendor/snappy/stamp-h1 +0 -1
data/vendor/snappy/snappy-test.h
CHANGED
@@ -55,8 +55,6 @@
|
|
55
55
|
#include <windows.h>
|
56
56
|
#endif
|
57
57
|
|
58
|
-
#include <string>
|
59
|
-
|
60
58
|
#ifdef HAVE_GTEST
|
61
59
|
|
62
60
|
#include <gtest/gtest.h>
|
@@ -110,26 +108,8 @@
|
|
110
108
|
#include "lzo/lzo1x.h"
|
111
109
|
#endif
|
112
110
|
|
113
|
-
#ifdef HAVE_LIBLZF
|
114
|
-
extern "C" {
|
115
|
-
#include "lzf.h"
|
116
|
-
}
|
117
|
-
#endif
|
118
|
-
|
119
|
-
#ifdef HAVE_LIBFASTLZ
|
120
|
-
#include "fastlz.h"
|
121
|
-
#endif
|
122
|
-
|
123
|
-
#ifdef HAVE_LIBQUICKLZ
|
124
|
-
#include "quicklz.h"
|
125
|
-
#endif
|
126
|
-
|
127
111
|
namespace {
|
128
112
|
|
129
|
-
namespace File {
|
130
|
-
void Init() { }
|
131
|
-
} // namespace File
|
132
|
-
|
133
113
|
namespace file {
|
134
114
|
int Defaults() { return 0; }
|
135
115
|
|
@@ -138,7 +118,8 @@ namespace file {
|
|
138
118
|
void CheckSuccess() { }
|
139
119
|
};
|
140
120
|
|
141
|
-
DummyStatus GetContents(
|
121
|
+
DummyStatus GetContents(
|
122
|
+
const std::string& filename, std::string* data, int unused) {
|
142
123
|
FILE* fp = fopen(filename.c_str(), "rb");
|
143
124
|
if (fp == NULL) {
|
144
125
|
perror(filename.c_str());
|
@@ -153,7 +134,7 @@ namespace file {
|
|
153
134
|
perror("fread");
|
154
135
|
exit(1);
|
155
136
|
}
|
156
|
-
data->append(string(buf, ret));
|
137
|
+
data->append(std::string(buf, ret));
|
157
138
|
}
|
158
139
|
|
159
140
|
fclose(fp);
|
@@ -161,9 +142,8 @@ namespace file {
|
|
161
142
|
return DummyStatus();
|
162
143
|
}
|
163
144
|
|
164
|
-
DummyStatus SetContents(
|
165
|
-
|
166
|
-
int unused) {
|
145
|
+
inline DummyStatus SetContents(
|
146
|
+
const std::string& filename, const std::string& str, int unused) {
|
167
147
|
FILE* fp = fopen(filename.c_str(), "wb");
|
168
148
|
if (fp == NULL) {
|
169
149
|
perror(filename.c_str());
|
@@ -187,7 +167,7 @@ namespace file {
|
|
187
167
|
namespace snappy {
|
188
168
|
|
189
169
|
#define FLAGS_test_random_seed 301
|
190
|
-
|
170
|
+
using TypeParam = std::string;
|
191
171
|
|
192
172
|
void Test_CorruptedTest_VerifyCorrupted();
|
193
173
|
void Test_Snappy_SimpleTests();
|
@@ -201,63 +181,13 @@ void Test_Snappy_ReadPastEndOfBuffer();
|
|
201
181
|
void Test_Snappy_FindMatchLength();
|
202
182
|
void Test_Snappy_FindMatchLengthRandom();
|
203
183
|
|
204
|
-
string ReadTestDataFile(const string& base, size_t size_limit);
|
184
|
+
std::string ReadTestDataFile(const std::string& base, size_t size_limit);
|
205
185
|
|
206
|
-
string ReadTestDataFile(const string& base);
|
186
|
+
std::string ReadTestDataFile(const std::string& base);
|
207
187
|
|
208
188
|
// A sprintf() variant that returns a std::string.
|
209
189
|
// Not safe for general use due to truncation issues.
|
210
|
-
string
|
211
|
-
|
212
|
-
// A simple, non-cryptographically-secure random generator.
|
213
|
-
class ACMRandom {
|
214
|
-
public:
|
215
|
-
explicit ACMRandom(uint32 seed) : seed_(seed) {}
|
216
|
-
|
217
|
-
int32 Next();
|
218
|
-
|
219
|
-
int32 Uniform(int32 n) {
|
220
|
-
return Next() % n;
|
221
|
-
}
|
222
|
-
uint8 Rand8() {
|
223
|
-
return static_cast<uint8>((Next() >> 1) & 0x000000ff);
|
224
|
-
}
|
225
|
-
bool OneIn(int X) { return Uniform(X) == 0; }
|
226
|
-
|
227
|
-
// Skewed: pick "base" uniformly from range [0,max_log] and then
|
228
|
-
// return "base" random bits. The effect is to pick a number in the
|
229
|
-
// range [0,2^max_log-1] with bias towards smaller numbers.
|
230
|
-
int32 Skewed(int max_log);
|
231
|
-
|
232
|
-
private:
|
233
|
-
static const uint32 M = 2147483647L; // 2^31-1
|
234
|
-
uint32 seed_;
|
235
|
-
};
|
236
|
-
|
237
|
-
inline int32 ACMRandom::Next() {
|
238
|
-
static const uint64 A = 16807; // bits 14, 8, 7, 5, 2, 1, 0
|
239
|
-
// We are computing
|
240
|
-
// seed_ = (seed_ * A) % M, where M = 2^31-1
|
241
|
-
//
|
242
|
-
// seed_ must not be zero or M, or else all subsequent computed values
|
243
|
-
// will be zero or M respectively. For all other values, seed_ will end
|
244
|
-
// up cycling through every number in [1,M-1]
|
245
|
-
uint64 product = seed_ * A;
|
246
|
-
|
247
|
-
// Compute (product % M) using the fact that ((x << 31) % M) == x.
|
248
|
-
seed_ = (product >> 31) + (product & M);
|
249
|
-
// The first reduction may overflow by 1 bit, so we may need to repeat.
|
250
|
-
// mod == M is not possible; using > allows the faster sign-bit-based test.
|
251
|
-
if (seed_ > M) {
|
252
|
-
seed_ -= M;
|
253
|
-
}
|
254
|
-
return seed_;
|
255
|
-
}
|
256
|
-
|
257
|
-
inline int32 ACMRandom::Skewed(int max_log) {
|
258
|
-
const int32 base = (Next() - 1) % (max_log+1);
|
259
|
-
return (Next() - 1) & ((1u << base)-1);
|
260
|
-
}
|
190
|
+
std::string StrFormat(const char* format, ...);
|
261
191
|
|
262
192
|
// A wall-time clock. This stub is not super-accurate, nor resistant to the
|
263
193
|
// system time changing.
|
@@ -311,8 +241,8 @@ typedef void (*BenchmarkFunction)(int, int);
|
|
311
241
|
|
312
242
|
class Benchmark {
|
313
243
|
public:
|
314
|
-
Benchmark(const string& name, BenchmarkFunction function)
|
315
|
-
name_(name), function_(function) {}
|
244
|
+
Benchmark(const std::string& name, BenchmarkFunction function)
|
245
|
+
: name_(name), function_(function) {}
|
316
246
|
|
317
247
|
Benchmark* DenseRange(int start, int stop) {
|
318
248
|
start_ = start;
|
@@ -323,7 +253,7 @@ class Benchmark {
|
|
323
253
|
void Run();
|
324
254
|
|
325
255
|
private:
|
326
|
-
const string name_;
|
256
|
+
const std::string name_;
|
327
257
|
const BenchmarkFunction function_;
|
328
258
|
int start_, stop_;
|
329
259
|
};
|
@@ -335,11 +265,13 @@ extern Benchmark* Benchmark_BM_UFlat;
|
|
335
265
|
extern Benchmark* Benchmark_BM_UIOVec;
|
336
266
|
extern Benchmark* Benchmark_BM_UValidate;
|
337
267
|
extern Benchmark* Benchmark_BM_ZFlat;
|
268
|
+
extern Benchmark* Benchmark_BM_ZFlatAll;
|
269
|
+
extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize;
|
338
270
|
|
339
271
|
void ResetBenchmarkTiming();
|
340
272
|
void StartBenchmarkTiming();
|
341
273
|
void StopBenchmarkTiming();
|
342
|
-
void SetBenchmarkLabel(const string& str);
|
274
|
+
void SetBenchmarkLabel(const std::string& str);
|
343
275
|
void SetBenchmarkBytesProcessed(int64 bytes);
|
344
276
|
|
345
277
|
#ifdef HAVE_LIBZ
|
@@ -467,7 +399,7 @@ class ZLib {
|
|
467
399
|
|
468
400
|
DECLARE_bool(run_microbenchmarks);
|
469
401
|
|
470
|
-
static void RunSpecifiedBenchmarks() {
|
402
|
+
static inline void RunSpecifiedBenchmarks() {
|
471
403
|
if (!FLAGS_run_microbenchmarks) {
|
472
404
|
return;
|
473
405
|
}
|
@@ -486,6 +418,8 @@ static void RunSpecifiedBenchmarks() {
|
|
486
418
|
snappy::Benchmark_BM_UIOVec->Run();
|
487
419
|
snappy::Benchmark_BM_UValidate->Run();
|
488
420
|
snappy::Benchmark_BM_ZFlat->Run();
|
421
|
+
snappy::Benchmark_BM_ZFlatAll->Run();
|
422
|
+
snappy::Benchmark_BM_ZFlatIncreasingTableSize->Run();
|
489
423
|
|
490
424
|
fprintf(stderr, "\n");
|
491
425
|
}
|
@@ -515,10 +449,6 @@ static inline int RUN_ALL_TESTS() {
|
|
515
449
|
// For main().
|
516
450
|
namespace snappy {
|
517
451
|
|
518
|
-
static void CompressFile(const char* fname);
|
519
|
-
static void UncompressFile(const char* fname);
|
520
|
-
static void MeasureFile(const char* fname);
|
521
|
-
|
522
452
|
// Logging.
|
523
453
|
|
524
454
|
#define LOG(level) LogMessage()
|
@@ -529,15 +459,15 @@ class LogMessage {
|
|
529
459
|
public:
|
530
460
|
LogMessage() { }
|
531
461
|
~LogMessage() {
|
532
|
-
cerr << endl;
|
462
|
+
std::cerr << std::endl;
|
533
463
|
}
|
534
464
|
|
535
465
|
LogMessage& operator<<(const std::string& msg) {
|
536
|
-
cerr << msg;
|
466
|
+
std::cerr << msg;
|
537
467
|
return *this;
|
538
468
|
}
|
539
469
|
LogMessage& operator<<(int x) {
|
540
|
-
cerr << x;
|
470
|
+
std::cerr << x;
|
541
471
|
return *this;
|
542
472
|
}
|
543
473
|
};
|
@@ -546,7 +476,7 @@ class LogMessage {
|
|
546
476
|
// and ones that are always active.
|
547
477
|
|
548
478
|
#define CRASH_UNLESS(condition) \
|
549
|
-
|
479
|
+
SNAPPY_PREDICT_TRUE(condition) ? (void)0 : \
|
550
480
|
snappy::LogMessageVoidify() & snappy::LogMessageCrash()
|
551
481
|
|
552
482
|
#ifdef _MSC_VER
|
@@ -560,7 +490,7 @@ class LogMessageCrash : public LogMessage {
|
|
560
490
|
public:
|
561
491
|
LogMessageCrash() { }
|
562
492
|
~LogMessageCrash() {
|
563
|
-
cerr << endl;
|
493
|
+
std::cerr << std::endl;
|
564
494
|
abort();
|
565
495
|
}
|
566
496
|
};
|
@@ -590,10 +520,6 @@ class LogMessageVoidify {
|
|
590
520
|
#define CHECK_GT(a, b) CRASH_UNLESS((a) > (b))
|
591
521
|
#define CHECK_OK(cond) (cond).CheckSuccess()
|
592
522
|
|
593
|
-
} // namespace
|
594
|
-
|
595
|
-
using snappy::CompressFile;
|
596
|
-
using snappy::UncompressFile;
|
597
|
-
using snappy::MeasureFile;
|
523
|
+
} // namespace snappy
|
598
524
|
|
599
525
|
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
|