snappy 0.0.14-java → 0.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/Gemfile +4 -0
- data/README.md +28 -4
- data/Rakefile +32 -29
- data/ext/api.c +6 -1
- data/ext/extconf.rb +21 -24
- data/lib/snappy.rb +6 -4
- data/lib/snappy/hadoop.rb +22 -0
- data/lib/snappy/hadoop/reader.rb +62 -0
- data/lib/snappy/hadoop/writer.rb +51 -0
- data/lib/snappy/reader.rb +19 -11
- data/lib/snappy/shim.rb +30 -0
- data/lib/snappy/version.rb +3 -1
- data/lib/snappy/writer.rb +8 -9
- data/snappy.gemspec +17 -37
- 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/vendor/snappy/CMakeLists.txt +297 -0
- data/vendor/snappy/CONTRIBUTING.md +26 -0
- data/vendor/snappy/COPYING +1 -1
- data/vendor/snappy/NEWS +60 -0
- data/vendor/snappy/{README → README.md} +29 -16
- 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-c.h +3 -3
- data/vendor/snappy/snappy-internal.h +113 -32
- data/vendor/snappy/snappy-sinksource.cc +33 -0
- data/vendor/snappy/snappy-sinksource.h +51 -6
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +160 -45
- data/vendor/snappy/snappy-stubs-public.h.in +23 -47
- data/vendor/snappy/snappy-test.cc +31 -24
- data/vendor/snappy/snappy-test.h +46 -103
- data/vendor/snappy/snappy.cc +786 -431
- data/vendor/snappy/snappy.h +37 -14
- data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
- data/vendor/snappy/snappy_unittest.cc +441 -290
- metadata +35 -75
- data/.travis.yml +0 -4
- 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 -1916
- data/vendor/snappy/Makefile.am +0 -23
- data/vendor/snappy/autogen.sh +0 -7
- data/vendor/snappy/configure.ac +0 -133
- data/vendor/snappy/m4/gtest.m4 +0 -74
- data/vendor/snappy/testdata/alice29.txt +0 -3609
- data/vendor/snappy/testdata/asyoulik.txt +0 -4122
- data/vendor/snappy/testdata/baddata1.snappy +0 -0
- data/vendor/snappy/testdata/baddata2.snappy +0 -0
- data/vendor/snappy/testdata/baddata3.snappy +0 -0
- data/vendor/snappy/testdata/fireworks.jpeg +0 -0
- data/vendor/snappy/testdata/geo.protodata +0 -0
- data/vendor/snappy/testdata/html +0 -1
- data/vendor/snappy/testdata/html_x_4 +0 -1
- data/vendor/snappy/testdata/kppkn.gtb +0 -0
- data/vendor/snappy/testdata/lcet10.txt +0 -7519
- data/vendor/snappy/testdata/paper-100k.pdf +2 -600
- data/vendor/snappy/testdata/plrabn12.txt +0 -10699
- data/vendor/snappy/testdata/urls.10K +0 -10000
@@ -1,5 +1,4 @@
|
|
1
1
|
// Copyright 2011 Google Inc. All Rights Reserved.
|
2
|
-
// Author: sesse@google.com (Steinar H. Gunderson)
|
3
2
|
//
|
4
3
|
// Redistribution and use in source and binary forms, with or without
|
5
4
|
// modification, are permitted provided that the following conditions are
|
@@ -33,66 +32,43 @@
|
|
33
32
|
// which is a public header. Instead, snappy-stubs-public.h is generated by
|
34
33
|
// from snappy-stubs-public.h.in at configure time.
|
35
34
|
|
36
|
-
#ifndef
|
37
|
-
#define
|
35
|
+
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
36
|
+
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
38
37
|
|
39
|
-
#
|
40
|
-
#include <
|
41
|
-
#
|
42
|
-
|
43
|
-
#if @ac_cv_have_stddef_h@
|
44
|
-
#include <stddef.h>
|
45
|
-
#endif
|
38
|
+
#include <cstddef>
|
39
|
+
#include <cstdint>
|
40
|
+
#include <string>
|
46
41
|
|
47
|
-
#if
|
42
|
+
#if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H
|
48
43
|
#include <sys/uio.h>
|
49
|
-
#endif
|
44
|
+
#endif // HAVE_SYS_UIO_H
|
50
45
|
|
51
|
-
#define SNAPPY_MAJOR
|
52
|
-
#define SNAPPY_MINOR
|
53
|
-
#define SNAPPY_PATCHLEVEL
|
46
|
+
#define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR}
|
47
|
+
#define SNAPPY_MINOR ${PROJECT_VERSION_MINOR}
|
48
|
+
#define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH}
|
54
49
|
#define SNAPPY_VERSION \
|
55
50
|
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
|
56
51
|
|
57
|
-
#include <string>
|
58
|
-
|
59
52
|
namespace snappy {
|
60
53
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
typedef uint64_t uint64;
|
70
|
-
#else
|
71
|
-
typedef signed char int8;
|
72
|
-
typedef unsigned char uint8;
|
73
|
-
typedef short int16;
|
74
|
-
typedef unsigned short uint16;
|
75
|
-
typedef int int32;
|
76
|
-
typedef unsigned int uint32;
|
77
|
-
typedef long long int64;
|
78
|
-
typedef unsigned long long uint64;
|
79
|
-
#endif
|
80
|
-
|
81
|
-
typedef std::string string;
|
82
|
-
|
83
|
-
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
84
|
-
TypeName(const TypeName&); \
|
85
|
-
void operator=(const TypeName&)
|
54
|
+
using int8 = std::int8_t;
|
55
|
+
using uint8 = std::uint8_t;
|
56
|
+
using int16 = std::int16_t;
|
57
|
+
using uint16 = std::uint16_t;
|
58
|
+
using int32 = std::int32_t;
|
59
|
+
using uint32 = std::uint32_t;
|
60
|
+
using int64 = std::int64_t;
|
61
|
+
using uint64 = std::uint64_t;
|
86
62
|
|
87
|
-
#if
|
63
|
+
#if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H
|
88
64
|
// Windows does not have an iovec type, yet the concept is universally useful.
|
89
65
|
// It is simple to define it ourselves, so we put it inside our own namespace.
|
90
66
|
struct iovec {
|
91
|
-
|
92
|
-
|
67
|
+
void* iov_base;
|
68
|
+
size_t iov_len;
|
93
69
|
};
|
94
|
-
#endif
|
70
|
+
#endif // !HAVE_SYS_UIO_H
|
95
71
|
|
96
72
|
} // namespace snappy
|
97
73
|
|
98
|
-
#endif //
|
74
|
+
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
@@ -28,13 +28,19 @@
|
|
28
28
|
//
|
29
29
|
// Various stubs for the unit tests for the open-source version of Snappy.
|
30
30
|
|
31
|
-
#
|
31
|
+
#ifdef HAVE_CONFIG_H
|
32
|
+
#include "config.h"
|
33
|
+
#endif
|
32
34
|
|
33
35
|
#ifdef HAVE_WINDOWS_H
|
34
|
-
|
36
|
+
// Needed to be able to use std::max without workarounds in the source code.
|
37
|
+
// https://support.microsoft.com/en-us/help/143208/prb-using-stl-in-windows-program-can-cause-min-max-conflicts
|
38
|
+
#define NOMINMAX
|
35
39
|
#include <windows.h>
|
36
40
|
#endif
|
37
41
|
|
42
|
+
#include "snappy-test.h"
|
43
|
+
|
38
44
|
#include <algorithm>
|
39
45
|
|
40
46
|
DEFINE_bool(run_microbenchmarks, true,
|
@@ -42,12 +48,12 @@ DEFINE_bool(run_microbenchmarks, true,
|
|
42
48
|
|
43
49
|
namespace snappy {
|
44
50
|
|
45
|
-
string ReadTestDataFile(const string& base, size_t size_limit) {
|
46
|
-
string contents;
|
51
|
+
std::string ReadTestDataFile(const std::string& base, size_t size_limit) {
|
52
|
+
std::string contents;
|
47
53
|
const char* srcdir = getenv("srcdir"); // This is set by Automake.
|
48
|
-
string prefix;
|
54
|
+
std::string prefix;
|
49
55
|
if (srcdir) {
|
50
|
-
prefix = string(srcdir) + "/";
|
56
|
+
prefix = std::string(srcdir) + "/";
|
51
57
|
}
|
52
58
|
file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults()
|
53
59
|
).CheckSuccess();
|
@@ -57,11 +63,11 @@ string ReadTestDataFile(const string& base, size_t size_limit) {
|
|
57
63
|
return contents;
|
58
64
|
}
|
59
65
|
|
60
|
-
string ReadTestDataFile(const string& base) {
|
66
|
+
std::string ReadTestDataFile(const std::string& base) {
|
61
67
|
return ReadTestDataFile(base, 0);
|
62
68
|
}
|
63
69
|
|
64
|
-
string
|
70
|
+
std::string StrFormat(const char* format, ...) {
|
65
71
|
char buf[4096];
|
66
72
|
va_list ap;
|
67
73
|
va_start(ap, format);
|
@@ -73,7 +79,7 @@ string StringPrintf(const char* format, ...) {
|
|
73
79
|
bool benchmark_running = false;
|
74
80
|
int64 benchmark_real_time_us = 0;
|
75
81
|
int64 benchmark_cpu_time_us = 0;
|
76
|
-
string
|
82
|
+
std::string* benchmark_label = nullptr;
|
77
83
|
int64 benchmark_bytes_processed = 0;
|
78
84
|
|
79
85
|
void ResetBenchmarkTiming() {
|
@@ -157,11 +163,11 @@ void StopBenchmarkTiming() {
|
|
157
163
|
benchmark_running = false;
|
158
164
|
}
|
159
165
|
|
160
|
-
void SetBenchmarkLabel(const string& str) {
|
166
|
+
void SetBenchmarkLabel(const std::string& str) {
|
161
167
|
if (benchmark_label) {
|
162
168
|
delete benchmark_label;
|
163
169
|
}
|
164
|
-
benchmark_label = new string(str);
|
170
|
+
benchmark_label = new std::string(str);
|
165
171
|
}
|
166
172
|
|
167
173
|
void SetBenchmarkBytesProcessed(int64 bytes) {
|
@@ -198,7 +204,7 @@ void Benchmark::Run() {
|
|
198
204
|
if (benchmark_real_time_us > 0) {
|
199
205
|
num_iterations = 200000 * kCalibrateIterations / benchmark_real_time_us;
|
200
206
|
}
|
201
|
-
num_iterations = max(num_iterations, kCalibrateIterations);
|
207
|
+
num_iterations = std::max(num_iterations, kCalibrateIterations);
|
202
208
|
BenchmarkRun benchmark_runs[kNumRuns];
|
203
209
|
|
204
210
|
for (int run = 0; run < kNumRuns; ++run) {
|
@@ -211,13 +217,13 @@ void Benchmark::Run() {
|
|
211
217
|
benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us;
|
212
218
|
}
|
213
219
|
|
214
|
-
string heading =
|
215
|
-
string human_readable_speed;
|
220
|
+
std::string heading = StrFormat("%s/%d", name_.c_str(), test_case_num);
|
221
|
+
std::string human_readable_speed;
|
216
222
|
|
217
|
-
nth_element(benchmark_runs,
|
218
|
-
|
219
|
-
|
220
|
-
|
223
|
+
std::nth_element(benchmark_runs,
|
224
|
+
benchmark_runs + kMedianPos,
|
225
|
+
benchmark_runs + kNumRuns,
|
226
|
+
BenchmarkCompareCPUTime());
|
221
227
|
int64 real_time_us = benchmark_runs[kMedianPos].real_time_us;
|
222
228
|
int64 cpu_time_us = benchmark_runs[kMedianPos].cpu_time_us;
|
223
229
|
if (cpu_time_us <= 0) {
|
@@ -226,15 +232,16 @@ void Benchmark::Run() {
|
|
226
232
|
int64 bytes_per_second =
|
227
233
|
benchmark_bytes_processed * 1000000 / cpu_time_us;
|
228
234
|
if (bytes_per_second < 1024) {
|
229
|
-
human_readable_speed =
|
235
|
+
human_readable_speed =
|
236
|
+
StrFormat("%dB/s", static_cast<int>(bytes_per_second));
|
230
237
|
} else if (bytes_per_second < 1024 * 1024) {
|
231
|
-
human_readable_speed =
|
238
|
+
human_readable_speed = StrFormat(
|
232
239
|
"%.1fkB/s", bytes_per_second / 1024.0f);
|
233
240
|
} else if (bytes_per_second < 1024 * 1024 * 1024) {
|
234
|
-
human_readable_speed =
|
241
|
+
human_readable_speed = StrFormat(
|
235
242
|
"%.1fMB/s", bytes_per_second / (1024.0f * 1024.0f));
|
236
243
|
} else {
|
237
|
-
human_readable_speed =
|
244
|
+
human_readable_speed = StrFormat(
|
238
245
|
"%.1fGB/s", bytes_per_second / (1024.0f * 1024.0f * 1024.0f));
|
239
246
|
}
|
240
247
|
}
|
@@ -520,8 +527,8 @@ int ZLib::UncompressAtMostOrAll(Bytef *dest, uLongf *destLen,
|
|
520
527
|
LOG(WARNING)
|
521
528
|
<< "UncompressChunkOrAll: Received some extra data, bytes total: "
|
522
529
|
<< uncomp_stream_.avail_in << " bytes: "
|
523
|
-
<< string(reinterpret_cast<const char *>(uncomp_stream_.next_in),
|
524
|
-
|
530
|
+
<< std::string(reinterpret_cast<const char *>(uncomp_stream_.next_in),
|
531
|
+
std::min(int(uncomp_stream_.avail_in), 20));
|
525
532
|
UncompressErrorInit();
|
526
533
|
return Z_DATA_ERROR; // what's the extra data for?
|
527
534
|
} else if (err != Z_OK && err != Z_STREAM_END && err != Z_BUF_ERROR) {
|
data/vendor/snappy/snappy-test.h
CHANGED
@@ -28,8 +28,8 @@
|
|
28
28
|
//
|
29
29
|
// Various stubs for the unit tests for the open-source version of Snappy.
|
30
30
|
|
31
|
-
#ifndef
|
32
|
-
#define
|
31
|
+
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
|
32
|
+
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
|
33
33
|
|
34
34
|
#include <iostream>
|
35
35
|
#include <string>
|
@@ -52,12 +52,9 @@
|
|
52
52
|
#endif
|
53
53
|
|
54
54
|
#ifdef HAVE_WINDOWS_H
|
55
|
-
#define WIN32_LEAN_AND_MEAN
|
56
55
|
#include <windows.h>
|
57
56
|
#endif
|
58
57
|
|
59
|
-
#include <string>
|
60
|
-
|
61
58
|
#ifdef HAVE_GTEST
|
62
59
|
|
63
60
|
#include <gtest/gtest.h>
|
@@ -111,35 +108,18 @@
|
|
111
108
|
#include "lzo/lzo1x.h"
|
112
109
|
#endif
|
113
110
|
|
114
|
-
#ifdef HAVE_LIBLZF
|
115
|
-
extern "C" {
|
116
|
-
#include "lzf.h"
|
117
|
-
}
|
118
|
-
#endif
|
119
|
-
|
120
|
-
#ifdef HAVE_LIBFASTLZ
|
121
|
-
#include "fastlz.h"
|
122
|
-
#endif
|
123
|
-
|
124
|
-
#ifdef HAVE_LIBQUICKLZ
|
125
|
-
#include "quicklz.h"
|
126
|
-
#endif
|
127
|
-
|
128
111
|
namespace {
|
129
112
|
|
130
|
-
namespace File {
|
131
|
-
void Init() { }
|
132
|
-
} // namespace File
|
133
|
-
|
134
113
|
namespace file {
|
135
|
-
int Defaults() { }
|
114
|
+
int Defaults() { return 0; }
|
136
115
|
|
137
116
|
class DummyStatus {
|
138
117
|
public:
|
139
118
|
void CheckSuccess() { }
|
140
119
|
};
|
141
120
|
|
142
|
-
DummyStatus GetContents(
|
121
|
+
DummyStatus GetContents(
|
122
|
+
const std::string& filename, std::string* data, int unused) {
|
143
123
|
FILE* fp = fopen(filename.c_str(), "rb");
|
144
124
|
if (fp == NULL) {
|
145
125
|
perror(filename.c_str());
|
@@ -154,15 +134,16 @@ namespace file {
|
|
154
134
|
perror("fread");
|
155
135
|
exit(1);
|
156
136
|
}
|
157
|
-
data->append(string(buf, ret));
|
137
|
+
data->append(std::string(buf, ret));
|
158
138
|
}
|
159
139
|
|
160
140
|
fclose(fp);
|
141
|
+
|
142
|
+
return DummyStatus();
|
161
143
|
}
|
162
144
|
|
163
|
-
DummyStatus SetContents(
|
164
|
-
|
165
|
-
int unused) {
|
145
|
+
inline DummyStatus SetContents(
|
146
|
+
const std::string& filename, const std::string& str, int unused) {
|
166
147
|
FILE* fp = fopen(filename.c_str(), "wb");
|
167
148
|
if (fp == NULL) {
|
168
149
|
perror(filename.c_str());
|
@@ -176,6 +157,8 @@ namespace file {
|
|
176
157
|
}
|
177
158
|
|
178
159
|
fclose(fp);
|
160
|
+
|
161
|
+
return DummyStatus();
|
179
162
|
}
|
180
163
|
} // namespace file
|
181
164
|
|
@@ -184,7 +167,7 @@ namespace file {
|
|
184
167
|
namespace snappy {
|
185
168
|
|
186
169
|
#define FLAGS_test_random_seed 301
|
187
|
-
|
170
|
+
using TypeParam = std::string;
|
188
171
|
|
189
172
|
void Test_CorruptedTest_VerifyCorrupted();
|
190
173
|
void Test_Snappy_SimpleTests();
|
@@ -193,67 +176,18 @@ void Test_Snappy_RandomData();
|
|
193
176
|
void Test_Snappy_FourByteOffset();
|
194
177
|
void Test_SnappyCorruption_TruncatedVarint();
|
195
178
|
void Test_SnappyCorruption_UnterminatedVarint();
|
179
|
+
void Test_SnappyCorruption_OverflowingVarint();
|
196
180
|
void Test_Snappy_ReadPastEndOfBuffer();
|
197
181
|
void Test_Snappy_FindMatchLength();
|
198
182
|
void Test_Snappy_FindMatchLengthRandom();
|
199
183
|
|
200
|
-
string ReadTestDataFile(const string& base, size_t size_limit);
|
184
|
+
std::string ReadTestDataFile(const std::string& base, size_t size_limit);
|
201
185
|
|
202
|
-
string ReadTestDataFile(const string& base);
|
186
|
+
std::string ReadTestDataFile(const std::string& base);
|
203
187
|
|
204
188
|
// A sprintf() variant that returns a std::string.
|
205
189
|
// Not safe for general use due to truncation issues.
|
206
|
-
string
|
207
|
-
|
208
|
-
// A simple, non-cryptographically-secure random generator.
|
209
|
-
class ACMRandom {
|
210
|
-
public:
|
211
|
-
explicit ACMRandom(uint32 seed) : seed_(seed) {}
|
212
|
-
|
213
|
-
int32 Next();
|
214
|
-
|
215
|
-
int32 Uniform(int32 n) {
|
216
|
-
return Next() % n;
|
217
|
-
}
|
218
|
-
uint8 Rand8() {
|
219
|
-
return static_cast<uint8>((Next() >> 1) & 0x000000ff);
|
220
|
-
}
|
221
|
-
bool OneIn(int X) { return Uniform(X) == 0; }
|
222
|
-
|
223
|
-
// Skewed: pick "base" uniformly from range [0,max_log] and then
|
224
|
-
// return "base" random bits. The effect is to pick a number in the
|
225
|
-
// range [0,2^max_log-1] with bias towards smaller numbers.
|
226
|
-
int32 Skewed(int max_log);
|
227
|
-
|
228
|
-
private:
|
229
|
-
static const uint32 M = 2147483647L; // 2^31-1
|
230
|
-
uint32 seed_;
|
231
|
-
};
|
232
|
-
|
233
|
-
inline int32 ACMRandom::Next() {
|
234
|
-
static const uint64 A = 16807; // bits 14, 8, 7, 5, 2, 1, 0
|
235
|
-
// We are computing
|
236
|
-
// seed_ = (seed_ * A) % M, where M = 2^31-1
|
237
|
-
//
|
238
|
-
// seed_ must not be zero or M, or else all subsequent computed values
|
239
|
-
// will be zero or M respectively. For all other values, seed_ will end
|
240
|
-
// up cycling through every number in [1,M-1]
|
241
|
-
uint64 product = seed_ * A;
|
242
|
-
|
243
|
-
// Compute (product % M) using the fact that ((x << 31) % M) == x.
|
244
|
-
seed_ = (product >> 31) + (product & M);
|
245
|
-
// The first reduction may overflow by 1 bit, so we may need to repeat.
|
246
|
-
// mod == M is not possible; using > allows the faster sign-bit-based test.
|
247
|
-
if (seed_ > M) {
|
248
|
-
seed_ -= M;
|
249
|
-
}
|
250
|
-
return seed_;
|
251
|
-
}
|
252
|
-
|
253
|
-
inline int32 ACMRandom::Skewed(int max_log) {
|
254
|
-
const int32 base = (Next() - 1) % (max_log+1);
|
255
|
-
return (Next() - 1) & ((1u << base)-1);
|
256
|
-
}
|
190
|
+
std::string StrFormat(const char* format, ...);
|
257
191
|
|
258
192
|
// A wall-time clock. This stub is not super-accurate, nor resistant to the
|
259
193
|
// system time changing.
|
@@ -307,8 +241,8 @@ typedef void (*BenchmarkFunction)(int, int);
|
|
307
241
|
|
308
242
|
class Benchmark {
|
309
243
|
public:
|
310
|
-
Benchmark(const string& name, BenchmarkFunction function)
|
311
|
-
name_(name), function_(function) {}
|
244
|
+
Benchmark(const std::string& name, BenchmarkFunction function)
|
245
|
+
: name_(name), function_(function) {}
|
312
246
|
|
313
247
|
Benchmark* DenseRange(int start, int stop) {
|
314
248
|
start_ = start;
|
@@ -319,7 +253,7 @@ class Benchmark {
|
|
319
253
|
void Run();
|
320
254
|
|
321
255
|
private:
|
322
|
-
const string name_;
|
256
|
+
const std::string name_;
|
323
257
|
const BenchmarkFunction function_;
|
324
258
|
int start_, stop_;
|
325
259
|
};
|
@@ -331,11 +265,13 @@ extern Benchmark* Benchmark_BM_UFlat;
|
|
331
265
|
extern Benchmark* Benchmark_BM_UIOVec;
|
332
266
|
extern Benchmark* Benchmark_BM_UValidate;
|
333
267
|
extern Benchmark* Benchmark_BM_ZFlat;
|
268
|
+
extern Benchmark* Benchmark_BM_ZFlatAll;
|
269
|
+
extern Benchmark* Benchmark_BM_ZFlatIncreasingTableSize;
|
334
270
|
|
335
271
|
void ResetBenchmarkTiming();
|
336
272
|
void StartBenchmarkTiming();
|
337
273
|
void StopBenchmarkTiming();
|
338
|
-
void SetBenchmarkLabel(const string& str);
|
274
|
+
void SetBenchmarkLabel(const std::string& str);
|
339
275
|
void SetBenchmarkBytesProcessed(int64 bytes);
|
340
276
|
|
341
277
|
#ifdef HAVE_LIBZ
|
@@ -463,7 +399,7 @@ class ZLib {
|
|
463
399
|
|
464
400
|
DECLARE_bool(run_microbenchmarks);
|
465
401
|
|
466
|
-
static void RunSpecifiedBenchmarks() {
|
402
|
+
static inline void RunSpecifiedBenchmarks() {
|
467
403
|
if (!FLAGS_run_microbenchmarks) {
|
468
404
|
return;
|
469
405
|
}
|
@@ -482,6 +418,8 @@ static void RunSpecifiedBenchmarks() {
|
|
482
418
|
snappy::Benchmark_BM_UIOVec->Run();
|
483
419
|
snappy::Benchmark_BM_UValidate->Run();
|
484
420
|
snappy::Benchmark_BM_ZFlat->Run();
|
421
|
+
snappy::Benchmark_BM_ZFlatAll->Run();
|
422
|
+
snappy::Benchmark_BM_ZFlatIncreasingTableSize->Run();
|
485
423
|
|
486
424
|
fprintf(stderr, "\n");
|
487
425
|
}
|
@@ -497,6 +435,7 @@ static inline int RUN_ALL_TESTS() {
|
|
497
435
|
snappy::Test_Snappy_FourByteOffset();
|
498
436
|
snappy::Test_SnappyCorruption_TruncatedVarint();
|
499
437
|
snappy::Test_SnappyCorruption_UnterminatedVarint();
|
438
|
+
snappy::Test_SnappyCorruption_OverflowingVarint();
|
500
439
|
snappy::Test_Snappy_ReadPastEndOfBuffer();
|
501
440
|
snappy::Test_Snappy_FindMatchLength();
|
502
441
|
snappy::Test_Snappy_FindMatchLengthRandom();
|
@@ -510,10 +449,6 @@ static inline int RUN_ALL_TESTS() {
|
|
510
449
|
// For main().
|
511
450
|
namespace snappy {
|
512
451
|
|
513
|
-
static void CompressFile(const char* fname);
|
514
|
-
static void UncompressFile(const char* fname);
|
515
|
-
static void MeasureFile(const char* fname);
|
516
|
-
|
517
452
|
// Logging.
|
518
453
|
|
519
454
|
#define LOG(level) LogMessage()
|
@@ -524,15 +459,15 @@ class LogMessage {
|
|
524
459
|
public:
|
525
460
|
LogMessage() { }
|
526
461
|
~LogMessage() {
|
527
|
-
cerr << endl;
|
462
|
+
std::cerr << std::endl;
|
528
463
|
}
|
529
464
|
|
530
465
|
LogMessage& operator<<(const std::string& msg) {
|
531
|
-
cerr << msg;
|
466
|
+
std::cerr << msg;
|
532
467
|
return *this;
|
533
468
|
}
|
534
469
|
LogMessage& operator<<(int x) {
|
535
|
-
cerr << x;
|
470
|
+
std::cerr << x;
|
536
471
|
return *this;
|
537
472
|
}
|
538
473
|
};
|
@@ -541,18 +476,29 @@ class LogMessage {
|
|
541
476
|
// and ones that are always active.
|
542
477
|
|
543
478
|
#define CRASH_UNLESS(condition) \
|
544
|
-
|
479
|
+
SNAPPY_PREDICT_TRUE(condition) ? (void)0 : \
|
545
480
|
snappy::LogMessageVoidify() & snappy::LogMessageCrash()
|
546
481
|
|
482
|
+
#ifdef _MSC_VER
|
483
|
+
// ~LogMessageCrash calls abort() and therefore never exits. This is by design
|
484
|
+
// so temporarily disable warning C4722.
|
485
|
+
#pragma warning(push)
|
486
|
+
#pragma warning(disable:4722)
|
487
|
+
#endif
|
488
|
+
|
547
489
|
class LogMessageCrash : public LogMessage {
|
548
490
|
public:
|
549
491
|
LogMessageCrash() { }
|
550
492
|
~LogMessageCrash() {
|
551
|
-
cerr << endl;
|
493
|
+
std::cerr << std::endl;
|
552
494
|
abort();
|
553
495
|
}
|
554
496
|
};
|
555
497
|
|
498
|
+
#ifdef _MSC_VER
|
499
|
+
#pragma warning(pop)
|
500
|
+
#endif
|
501
|
+
|
556
502
|
// This class is used to explicitly ignore values in the conditional
|
557
503
|
// logging macros. This avoids compiler warnings like "value computed
|
558
504
|
// is not used" and "statement has no effect".
|
@@ -572,11 +518,8 @@ class LogMessageVoidify {
|
|
572
518
|
#define CHECK_NE(a, b) CRASH_UNLESS((a) != (b))
|
573
519
|
#define CHECK_LT(a, b) CRASH_UNLESS((a) < (b))
|
574
520
|
#define CHECK_GT(a, b) CRASH_UNLESS((a) > (b))
|
521
|
+
#define CHECK_OK(cond) (cond).CheckSuccess()
|
575
522
|
|
576
|
-
} // namespace
|
577
|
-
|
578
|
-
using snappy::CompressFile;
|
579
|
-
using snappy::UncompressFile;
|
580
|
-
using snappy::MeasureFile;
|
523
|
+
} // namespace snappy
|
581
524
|
|
582
|
-
#endif //
|
525
|
+
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
|