snappy 0.0.17 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +45 -5
- data/Rakefile +32 -29
- data/ext/api.c +6 -1
- data/ext/extconf.rb +31 -22
- 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 +14 -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 +420 -0
- data/vendor/snappy/CONTRIBUTING.md +31 -0
- data/vendor/snappy/NEWS +52 -0
- data/vendor/snappy/{README → README.md} +75 -49
- data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/vendor/snappy/cmake/config.h.in +66 -0
- data/vendor/snappy/docs/README.md +72 -0
- data/vendor/snappy/snappy-internal.h +200 -32
- data/vendor/snappy/snappy-sinksource.cc +26 -9
- data/vendor/snappy/snappy-sinksource.h +11 -11
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +299 -302
- data/vendor/snappy/snappy-stubs-public.h.in +10 -47
- data/vendor/snappy/snappy-test.cc +94 -200
- data/vendor/snappy/snappy-test.h +101 -358
- data/vendor/snappy/snappy.cc +1437 -474
- data/vendor/snappy/snappy.h +31 -12
- data/vendor/snappy/snappy_benchmark.cc +378 -0
- data/vendor/snappy/snappy_compress_fuzzer.cc +60 -0
- data/vendor/snappy/snappy_test_data.cc +57 -0
- data/vendor/snappy/snappy_test_data.h +68 -0
- data/vendor/snappy/snappy_test_tool.cc +471 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +58 -0
- data/vendor/snappy/snappy_unittest.cc +271 -792
- metadata +42 -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
@@ -0,0 +1,420 @@
|
|
1
|
+
# Copyright 2019 Google Inc. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions are
|
5
|
+
# met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above
|
10
|
+
# copyright notice, this list of conditions and the following disclaimer
|
11
|
+
# in the documentation and/or other materials provided with the
|
12
|
+
# distribution.
|
13
|
+
# * Neither the name of Google Inc. nor the names of its
|
14
|
+
# contributors may be used to endorse or promote products derived from
|
15
|
+
# this software without specific prior written permission.
|
16
|
+
#
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
|
29
|
+
cmake_minimum_required(VERSION 3.1)
|
30
|
+
project(Snappy VERSION 1.1.10 LANGUAGES C CXX)
|
31
|
+
|
32
|
+
# C++ standard can be overridden when this is used as a sub-project.
|
33
|
+
if(NOT CMAKE_CXX_STANDARD)
|
34
|
+
# This project requires C++11.
|
35
|
+
set(CMAKE_CXX_STANDARD 11)
|
36
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
37
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
38
|
+
endif(NOT CMAKE_CXX_STANDARD)
|
39
|
+
|
40
|
+
# https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
|
41
|
+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
42
|
+
# Use the highest warning level for Visual Studio.
|
43
|
+
set(CMAKE_CXX_WARNING_LEVEL 4)
|
44
|
+
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
45
|
+
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
46
|
+
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
47
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
48
|
+
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
49
|
+
|
50
|
+
# Disable C++ exceptions.
|
51
|
+
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
52
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
|
53
|
+
add_definitions(-D_HAS_EXCEPTIONS=0)
|
54
|
+
|
55
|
+
# Disable RTTI.
|
56
|
+
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
57
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
58
|
+
else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
59
|
+
# Use -Wall for clang and gcc.
|
60
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
61
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
62
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
63
|
+
|
64
|
+
# Use -Wextra for clang and gcc.
|
65
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
|
66
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
67
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
|
68
|
+
|
69
|
+
# Use -Werror for clang only.
|
70
|
+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
71
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
72
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
73
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
74
|
+
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
75
|
+
|
76
|
+
# Disable C++ exceptions.
|
77
|
+
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
78
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
79
|
+
|
80
|
+
# Disable RTTI.
|
81
|
+
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
82
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
83
|
+
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
84
|
+
|
85
|
+
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
|
86
|
+
# it prominent in the GUI.
|
87
|
+
option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
|
88
|
+
|
89
|
+
option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
|
90
|
+
|
91
|
+
option(SNAPPY_BUILD_BENCHMARKS "Build Snappy's benchmarks" ON)
|
92
|
+
|
93
|
+
option(SNAPPY_FUZZING_BUILD "Build Snappy for fuzzing." OFF)
|
94
|
+
|
95
|
+
option(SNAPPY_REQUIRE_AVX "Target processors with AVX support." OFF)
|
96
|
+
|
97
|
+
option(SNAPPY_REQUIRE_AVX2 "Target processors with AVX2 support." OFF)
|
98
|
+
|
99
|
+
option(SNAPPY_INSTALL "Install Snappy's header and library" ON)
|
100
|
+
|
101
|
+
include(TestBigEndian)
|
102
|
+
test_big_endian(SNAPPY_IS_BIG_ENDIAN)
|
103
|
+
|
104
|
+
include(CheckIncludeFile)
|
105
|
+
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
|
106
|
+
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
107
|
+
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
108
|
+
check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
|
109
|
+
check_include_file("unistd.h" HAVE_UNISTD_H)
|
110
|
+
check_include_file("windows.h" HAVE_WINDOWS_H)
|
111
|
+
|
112
|
+
include(CheckLibraryExists)
|
113
|
+
check_library_exists(z zlibVersion "" HAVE_LIBZ)
|
114
|
+
check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
|
115
|
+
check_library_exists(lz4 LZ4_compress_default "" HAVE_LIBLZ4)
|
116
|
+
|
117
|
+
include(CheckCXXCompilerFlag)
|
118
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX" HAVE_VISUAL_STUDIO_ARCH_AVX)
|
119
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX2" HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
120
|
+
CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_CLANG_MAVX)
|
121
|
+
CHECK_CXX_COMPILER_FLAG("-mbmi2" HAVE_CLANG_MBMI2)
|
122
|
+
if(SNAPPY_REQUIRE_AVX2)
|
123
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
124
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
|
125
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
126
|
+
if(HAVE_CLANG_MAVX)
|
127
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
128
|
+
endif(HAVE_CLANG_MAVX)
|
129
|
+
if(HAVE_CLANG_MBMI2)
|
130
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2")
|
131
|
+
endif(HAVE_CLANG_MBMI2)
|
132
|
+
elseif (SNAPPY_REQUIRE_AVX)
|
133
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
134
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
|
135
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
136
|
+
if(HAVE_CLANG_MAVX)
|
137
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
138
|
+
endif(HAVE_CLANG_MAVX)
|
139
|
+
endif(SNAPPY_REQUIRE_AVX2)
|
140
|
+
|
141
|
+
# Used by googletest.
|
142
|
+
check_cxx_compiler_flag(-Wno-missing-field-initializers
|
143
|
+
SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
144
|
+
|
145
|
+
include(CheckCXXSourceCompiles)
|
146
|
+
check_cxx_source_compiles("
|
147
|
+
int main() {
|
148
|
+
return __builtin_expect(0, 1);
|
149
|
+
}" HAVE_BUILTIN_EXPECT)
|
150
|
+
|
151
|
+
check_cxx_source_compiles("
|
152
|
+
int main() {
|
153
|
+
return __builtin_ctzll(0);
|
154
|
+
}" HAVE_BUILTIN_CTZ)
|
155
|
+
|
156
|
+
check_cxx_source_compiles("
|
157
|
+
__attribute__((always_inline)) int zero() { return 0; }
|
158
|
+
|
159
|
+
int main() {
|
160
|
+
return zero();
|
161
|
+
}" HAVE_ATTRIBUTE_ALWAYS_INLINE)
|
162
|
+
|
163
|
+
check_cxx_source_compiles("
|
164
|
+
#include <tmmintrin.h>
|
165
|
+
|
166
|
+
int main() {
|
167
|
+
const __m128i *src = 0;
|
168
|
+
__m128i dest;
|
169
|
+
const __m128i shuffle_mask = _mm_load_si128(src);
|
170
|
+
const __m128i pattern = _mm_shuffle_epi8(_mm_loadl_epi64(src), shuffle_mask);
|
171
|
+
_mm_storeu_si128(&dest, pattern);
|
172
|
+
return 0;
|
173
|
+
}" SNAPPY_HAVE_SSSE3)
|
174
|
+
|
175
|
+
check_cxx_source_compiles("
|
176
|
+
#include <immintrin.h>
|
177
|
+
int main() {
|
178
|
+
return _mm_crc32_u32(0, 1);
|
179
|
+
}" SNAPPY_HAVE_X86_CRC32)
|
180
|
+
|
181
|
+
check_cxx_source_compiles("
|
182
|
+
#include <arm_neon.h>
|
183
|
+
#include <arm_acle.h>
|
184
|
+
int main() {
|
185
|
+
return __crc32cw(0, 1);
|
186
|
+
}" SNAPPY_HAVE_NEON_CRC32)
|
187
|
+
|
188
|
+
check_cxx_source_compiles("
|
189
|
+
#include <immintrin.h>
|
190
|
+
int main() {
|
191
|
+
return _bzhi_u32(0, 1);
|
192
|
+
}" SNAPPY_HAVE_BMI2)
|
193
|
+
|
194
|
+
check_cxx_source_compiles("
|
195
|
+
#include <arm_neon.h>
|
196
|
+
int main() {
|
197
|
+
uint8_t val = 3, dup[8];
|
198
|
+
uint8x16_t v = vld1q_dup_u8(&val);
|
199
|
+
vst1q_u8(dup, v);
|
200
|
+
return 0;
|
201
|
+
}" SNAPPY_HAVE_NEON)
|
202
|
+
|
203
|
+
include(CheckSymbolExists)
|
204
|
+
check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
|
205
|
+
check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
|
206
|
+
|
207
|
+
configure_file(
|
208
|
+
"cmake/config.h.in"
|
209
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
210
|
+
)
|
211
|
+
|
212
|
+
# We don't want to define HAVE_ macros in public headers. Instead, we use
|
213
|
+
# CMake's variable substitution with 0/1 variables, which will be seen by the
|
214
|
+
# preprocessor as constants.
|
215
|
+
set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
|
216
|
+
if(NOT HAVE_SYS_UIO_H_01)
|
217
|
+
set(HAVE_SYS_UIO_H_01 0)
|
218
|
+
endif(NOT HAVE_SYS_UIO_H_01)
|
219
|
+
|
220
|
+
if (SNAPPY_FUZZING_BUILD)
|
221
|
+
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
222
|
+
message(WARNING "Fuzzing builds are only supported with Clang")
|
223
|
+
endif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
224
|
+
|
225
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
226
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
227
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
228
|
+
|
229
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
230
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
|
231
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
232
|
+
endif (SNAPPY_FUZZING_BUILD)
|
233
|
+
|
234
|
+
configure_file(
|
235
|
+
"snappy-stubs-public.h.in"
|
236
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
|
237
|
+
|
238
|
+
add_library(snappy "")
|
239
|
+
target_sources(snappy
|
240
|
+
PRIVATE
|
241
|
+
"snappy-internal.h"
|
242
|
+
"snappy-stubs-internal.h"
|
243
|
+
"snappy-c.cc"
|
244
|
+
"snappy-sinksource.cc"
|
245
|
+
"snappy-stubs-internal.cc"
|
246
|
+
"snappy.cc"
|
247
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
248
|
+
|
249
|
+
# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
|
250
|
+
$<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
|
251
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
|
252
|
+
$<INSTALL_INTERFACE:include/snappy-c.h>
|
253
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
|
254
|
+
$<INSTALL_INTERFACE:include/snappy-sinksource.h>
|
255
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
|
256
|
+
$<INSTALL_INTERFACE:include/snappy.h>
|
257
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
|
258
|
+
$<INSTALL_INTERFACE:include/snappy-stubs-public.h>
|
259
|
+
)
|
260
|
+
target_include_directories(snappy
|
261
|
+
PUBLIC
|
262
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
263
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
264
|
+
$<INSTALL_INTERFACE:include>
|
265
|
+
)
|
266
|
+
set_target_properties(snappy
|
267
|
+
PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
|
268
|
+
|
269
|
+
target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
|
270
|
+
if(BUILD_SHARED_LIBS)
|
271
|
+
set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
272
|
+
endif(BUILD_SHARED_LIBS)
|
273
|
+
|
274
|
+
if(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
|
275
|
+
add_library(snappy_test_support "")
|
276
|
+
target_sources(snappy_test_support
|
277
|
+
PRIVATE
|
278
|
+
"snappy-test.cc"
|
279
|
+
"snappy-test.h"
|
280
|
+
"snappy_test_data.cc"
|
281
|
+
"snappy_test_data.h"
|
282
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
283
|
+
)
|
284
|
+
|
285
|
+
# Test files include snappy-test.h, HAVE_CONFIG_H must be defined.
|
286
|
+
target_compile_definitions(snappy_test_support PUBLIC -DHAVE_CONFIG_H)
|
287
|
+
|
288
|
+
target_link_libraries(snappy_test_support snappy)
|
289
|
+
|
290
|
+
if(HAVE_LIBZ)
|
291
|
+
target_link_libraries(snappy_test_support z)
|
292
|
+
endif(HAVE_LIBZ)
|
293
|
+
if(HAVE_LIBLZO2)
|
294
|
+
target_link_libraries(snappy_test_support lzo2)
|
295
|
+
endif(HAVE_LIBLZO2)
|
296
|
+
if(HAVE_LIBLZ4)
|
297
|
+
target_link_libraries(snappy_test_support lz4)
|
298
|
+
endif(HAVE_LIBLZ4)
|
299
|
+
|
300
|
+
target_include_directories(snappy_test_support
|
301
|
+
BEFORE PUBLIC
|
302
|
+
"${PROJECT_SOURCE_DIR}"
|
303
|
+
)
|
304
|
+
endif(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
|
305
|
+
|
306
|
+
if(SNAPPY_BUILD_TESTS)
|
307
|
+
enable_testing()
|
308
|
+
|
309
|
+
# Prevent overriding the parent project's compiler/linker settings on Windows.
|
310
|
+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
311
|
+
set(install_gtest OFF)
|
312
|
+
set(install_gmock OFF)
|
313
|
+
set(build_gmock ON)
|
314
|
+
|
315
|
+
# This project is tested using GoogleTest.
|
316
|
+
add_subdirectory("third_party/googletest")
|
317
|
+
|
318
|
+
# GoogleTest triggers a missing field initializers warning.
|
319
|
+
if(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
320
|
+
set_property(TARGET gtest
|
321
|
+
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
322
|
+
set_property(TARGET gmock
|
323
|
+
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
324
|
+
endif(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
325
|
+
|
326
|
+
add_executable(snappy_unittest "")
|
327
|
+
target_sources(snappy_unittest
|
328
|
+
PRIVATE
|
329
|
+
"snappy_unittest.cc"
|
330
|
+
)
|
331
|
+
target_link_libraries(snappy_unittest snappy_test_support gmock_main gtest)
|
332
|
+
|
333
|
+
add_test(
|
334
|
+
NAME snappy_unittest
|
335
|
+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
336
|
+
COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
|
337
|
+
|
338
|
+
add_executable(snappy_test_tool "")
|
339
|
+
target_sources(snappy_test_tool
|
340
|
+
PRIVATE
|
341
|
+
"snappy_test_tool.cc"
|
342
|
+
)
|
343
|
+
target_link_libraries(snappy_test_tool snappy_test_support)
|
344
|
+
endif(SNAPPY_BUILD_TESTS)
|
345
|
+
|
346
|
+
if(SNAPPY_BUILD_BENCHMARKS)
|
347
|
+
add_executable(snappy_benchmark "")
|
348
|
+
target_sources(snappy_benchmark
|
349
|
+
PRIVATE
|
350
|
+
"snappy_benchmark.cc"
|
351
|
+
)
|
352
|
+
target_link_libraries(snappy_benchmark snappy_test_support benchmark_main)
|
353
|
+
|
354
|
+
# This project uses Google benchmark for benchmarking.
|
355
|
+
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
356
|
+
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
|
357
|
+
add_subdirectory("third_party/benchmark")
|
358
|
+
endif(SNAPPY_BUILD_BENCHMARKS)
|
359
|
+
|
360
|
+
if(SNAPPY_FUZZING_BUILD)
|
361
|
+
add_executable(snappy_compress_fuzzer "")
|
362
|
+
target_sources(snappy_compress_fuzzer
|
363
|
+
PRIVATE "snappy_compress_fuzzer.cc"
|
364
|
+
)
|
365
|
+
target_link_libraries(snappy_compress_fuzzer snappy)
|
366
|
+
set_target_properties(snappy_compress_fuzzer
|
367
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
368
|
+
)
|
369
|
+
|
370
|
+
add_executable(snappy_uncompress_fuzzer "")
|
371
|
+
target_sources(snappy_uncompress_fuzzer
|
372
|
+
PRIVATE "snappy_uncompress_fuzzer.cc"
|
373
|
+
)
|
374
|
+
target_link_libraries(snappy_uncompress_fuzzer snappy)
|
375
|
+
set_target_properties(snappy_uncompress_fuzzer
|
376
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
377
|
+
)
|
378
|
+
endif(SNAPPY_FUZZING_BUILD)
|
379
|
+
|
380
|
+
# Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
|
381
|
+
include(GNUInstallDirs)
|
382
|
+
|
383
|
+
if(SNAPPY_INSTALL)
|
384
|
+
install(TARGETS snappy
|
385
|
+
EXPORT SnappyTargets
|
386
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
387
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
388
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
389
|
+
)
|
390
|
+
install(
|
391
|
+
FILES
|
392
|
+
"snappy-c.h"
|
393
|
+
"snappy-sinksource.h"
|
394
|
+
"snappy.h"
|
395
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
|
396
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
397
|
+
)
|
398
|
+
|
399
|
+
include(CMakePackageConfigHelpers)
|
400
|
+
configure_package_config_file(
|
401
|
+
"cmake/${PROJECT_NAME}Config.cmake.in"
|
402
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
403
|
+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
404
|
+
)
|
405
|
+
write_basic_package_version_file(
|
406
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
407
|
+
COMPATIBILITY SameMajorVersion
|
408
|
+
)
|
409
|
+
install(
|
410
|
+
EXPORT SnappyTargets
|
411
|
+
NAMESPACE Snappy::
|
412
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
413
|
+
)
|
414
|
+
install(
|
415
|
+
FILES
|
416
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
417
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
418
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
419
|
+
)
|
420
|
+
endif(SNAPPY_INSTALL)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# How to Contribute
|
2
|
+
|
3
|
+
We'd love to accept your patches and contributions to this project. There are
|
4
|
+
just a few small guidelines you need to follow.
|
5
|
+
|
6
|
+
## Contributor License Agreement
|
7
|
+
|
8
|
+
Contributions to this project must be accompanied by a Contributor License
|
9
|
+
Agreement. You (or your employer) retain the copyright to your contribution;
|
10
|
+
this simply gives us permission to use and redistribute your contributions as
|
11
|
+
part of the project. Head over to <https://cla.developers.google.com/> to see
|
12
|
+
your current agreements on file or to sign a new one.
|
13
|
+
|
14
|
+
You generally only need to submit a CLA once, so if you've already submitted one
|
15
|
+
(even if it was for a different project), you probably don't need to do it
|
16
|
+
again.
|
17
|
+
|
18
|
+
## Code Reviews
|
19
|
+
|
20
|
+
All submissions, including submissions by project members, require review. We
|
21
|
+
use GitHub pull requests for this purpose. Consult
|
22
|
+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
23
|
+
information on using pull requests.
|
24
|
+
|
25
|
+
See [the README](README.md#contributing-to-the-snappy-project) for areas
|
26
|
+
where we are likely to accept external contributions.
|
27
|
+
|
28
|
+
## Community Guidelines
|
29
|
+
|
30
|
+
This project follows [Google's Open Source Community
|
31
|
+
Guidelines](https://opensource.google/conduct/).
|
data/vendor/snappy/NEWS
CHANGED
@@ -1,3 +1,55 @@
|
|
1
|
+
Snappy v1.1.10, Mar 8th 2023:
|
2
|
+
|
3
|
+
* Performance improvements
|
4
|
+
|
5
|
+
* Compilation fixes for various environments
|
6
|
+
|
7
|
+
Snappy v1.1.9, May 4th 2021:
|
8
|
+
|
9
|
+
* Performance improvements.
|
10
|
+
|
11
|
+
* Google Test and Google Benchmark are now bundled in third_party/.
|
12
|
+
|
13
|
+
Snappy v1.1.8, January 15th 2020:
|
14
|
+
|
15
|
+
* Small performance improvements.
|
16
|
+
|
17
|
+
* Removed snappy::string alias for std::string.
|
18
|
+
|
19
|
+
* Improved CMake configuration.
|
20
|
+
|
21
|
+
Snappy v1.1.7, August 24th 2017:
|
22
|
+
|
23
|
+
* Improved CMake build support for 64-bit Linux distributions.
|
24
|
+
|
25
|
+
* MSVC builds now use MSVC-specific intrinsics that map to clzll.
|
26
|
+
|
27
|
+
* ARM64 (AArch64) builds use the code paths optimized for 64-bit processors.
|
28
|
+
|
29
|
+
Snappy v1.1.6, July 12th 2017:
|
30
|
+
|
31
|
+
This is a re-release of v1.1.5 with proper SONAME / SOVERSION values.
|
32
|
+
|
33
|
+
Snappy v1.1.5, June 28th 2017:
|
34
|
+
|
35
|
+
This release has broken SONAME / SOVERSION values. Users of snappy as a shared
|
36
|
+
library should avoid 1.1.5 and use 1.1.6 instead. SONAME / SOVERSION errors will
|
37
|
+
manifest as the dynamic library loader complaining that it cannot find snappy's
|
38
|
+
shared library file (libsnappy.so / libsnappy.dylib), or that the library it
|
39
|
+
found does not have the required version. 1.1.6 has the same code as 1.1.5, but
|
40
|
+
carries build configuration fixes for the issues above.
|
41
|
+
|
42
|
+
* Add CMake build support. The autoconf build support is now deprecated, and
|
43
|
+
will be removed in the next release.
|
44
|
+
|
45
|
+
* Add AppVeyor configuration, for Windows CI coverage.
|
46
|
+
|
47
|
+
* Small performance improvement on little-endian PowerPC.
|
48
|
+
|
49
|
+
* Small performance improvement on LLVM with position-independent executables.
|
50
|
+
|
51
|
+
* Fix a few issues with various build environments.
|
52
|
+
|
1
53
|
Snappy v1.1.4, January 25th 2017:
|
2
54
|
|
3
55
|
* Fix a 1% performance regression when snappy is used in PIE executables.
|
@@ -1,5 +1,6 @@
|
|
1
1
|
Snappy, a fast compressor/decompressor.
|
2
2
|
|
3
|
+
[](https://github.com/google/snappy/actions/workflows/build.yml)
|
3
4
|
|
4
5
|
Introduction
|
5
6
|
============
|
@@ -34,7 +35,7 @@ Snappy is intended to be fast. On a single core of a Core i7 processor
|
|
34
35
|
in 64-bit mode, it compresses at about 250 MB/sec or more and decompresses at
|
35
36
|
about 500 MB/sec or more. (These numbers are for the slowest inputs in our
|
36
37
|
benchmark suite; others are much faster.) In our tests, Snappy usually
|
37
|
-
is faster than algorithms in the same class (e.g. LZO, LZF,
|
38
|
+
is faster than algorithms in the same class (e.g. LZO, LZF, QuickLZ,
|
38
39
|
etc.) while achieving comparable compression ratios.
|
39
40
|
|
40
41
|
Typical compression ratios (based on the benchmark suite) are about 1.5-1.7x
|
@@ -51,8 +52,8 @@ In particular:
|
|
51
52
|
|
52
53
|
- Snappy uses 64-bit operations in several places to process more data at
|
53
54
|
once than would otherwise be possible.
|
54
|
-
- Snappy assumes unaligned 32
|
55
|
-
On some platforms, these must be emulated with single-byte loads
|
55
|
+
- Snappy assumes unaligned 32 and 64-bit loads and stores are cheap.
|
56
|
+
On some platforms, these must be emulated with single-byte loads
|
56
57
|
and stores, which is much slower.
|
57
58
|
- Snappy assumes little-endian throughout, and needs to byte-swap data in
|
58
59
|
several places if running on a big-endian platform.
|
@@ -62,25 +63,41 @@ Performance optimizations, whether for 64-bit x86 or other platforms,
|
|
62
63
|
are of course most welcome; see "Contact", below.
|
63
64
|
|
64
65
|
|
66
|
+
Building
|
67
|
+
========
|
68
|
+
|
69
|
+
You need the CMake version specified in [CMakeLists.txt](./CMakeLists.txt)
|
70
|
+
or later to build:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
git submodule update --init
|
74
|
+
mkdir build
|
75
|
+
cd build && cmake ../ && make
|
76
|
+
```
|
77
|
+
|
65
78
|
Usage
|
66
79
|
=====
|
67
80
|
|
68
81
|
Note that Snappy, both the implementation and the main interface,
|
69
82
|
is written in C++. However, several third-party bindings to other languages
|
70
|
-
are available; see the home page
|
71
|
-
|
72
|
-
|
83
|
+
are available; see the [home page](docs/README.md) for more information.
|
84
|
+
Also, if you want to use Snappy from C code, you can use the included C
|
85
|
+
bindings in snappy-c.h.
|
73
86
|
|
74
87
|
To use Snappy from your own C++ program, include the file "snappy.h" from
|
75
88
|
your calling file, and link against the compiled library.
|
76
89
|
|
77
90
|
There are many ways to call Snappy, but the simplest possible is
|
78
91
|
|
79
|
-
|
92
|
+
```c++
|
93
|
+
snappy::Compress(input.data(), input.size(), &output);
|
94
|
+
```
|
80
95
|
|
81
96
|
and similarly
|
82
97
|
|
83
|
-
|
98
|
+
```c++
|
99
|
+
snappy::Uncompress(input.data(), input.size(), &output);
|
100
|
+
```
|
84
101
|
|
85
102
|
where "input" and "output" are both instances of std::string.
|
86
103
|
|
@@ -92,48 +109,57 @@ information.
|
|
92
109
|
Tests and benchmarks
|
93
110
|
====================
|
94
111
|
|
95
|
-
When you compile Snappy,
|
96
|
-
library itself. You do not need
|
97
|
-
but
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
112
|
+
When you compile Snappy, the following binaries are compiled in addition to the
|
113
|
+
library itself. You do not need them to use the compressor from your own
|
114
|
+
library, but they are useful for Snappy development.
|
115
|
+
|
116
|
+
* `snappy_benchmark` contains microbenchmarks used to tune compression and
|
117
|
+
decompression performance.
|
118
|
+
* `snappy_unittests` contains unit tests, verifying correctness on your machine
|
119
|
+
in various scenarios.
|
120
|
+
* `snappy_test_tool` can benchmark Snappy against a few other compression
|
121
|
+
libraries (zlib, LZO, LZF, and QuickLZ), if they were detected at configure
|
122
|
+
time. To benchmark using a given file, give the compression algorithm you want
|
123
|
+
to test Snappy against (e.g. --zlib) and then a list of one or more file names
|
124
|
+
on the command line.
|
125
|
+
|
126
|
+
If you want to change or optimize Snappy, please run the tests and benchmarks to
|
127
|
+
verify you have not broken anything.
|
128
|
+
|
129
|
+
The testdata/ directory contains the files used by the microbenchmarks, which
|
130
|
+
should provide a reasonably balanced starting point for benchmarking. (Note that
|
131
|
+
baddata[1-3].snappy are not intended as benchmarks; they are used to verify
|
132
|
+
correctness in the presence of corrupted data in the unit test.)
|
133
|
+
|
134
|
+
Contributing to the Snappy Project
|
135
|
+
==================================
|
136
|
+
|
137
|
+
In addition to the aims listed at the top of the [README](README.md) Snappy
|
138
|
+
explicitly supports the following:
|
139
|
+
|
140
|
+
1. C++11
|
141
|
+
2. Clang (gcc and MSVC are best-effort).
|
142
|
+
3. Low level optimizations (e.g. assembly or equivalent intrinsics) for:
|
143
|
+
1. [x86](https://en.wikipedia.org/wiki/X86)
|
144
|
+
2. [x86-64](https://en.wikipedia.org/wiki/X86-64)
|
145
|
+
3. ARMv7 (32-bit)
|
146
|
+
4. ARMv8 (AArch64)
|
147
|
+
4. Supports only the Snappy compression scheme as described in
|
148
|
+
[format_description.txt](format_description.txt).
|
149
|
+
5. CMake for building
|
150
|
+
|
151
|
+
Changes adding features or dependencies outside of the core area of focus listed
|
152
|
+
above might not be accepted. If in doubt post a message to the
|
153
|
+
[Snappy discussion mailing list](https://groups.google.com/g/snappy-compression).
|
154
|
+
|
155
|
+
We are unlikely to accept contributions to the build configuration files, such
|
156
|
+
as `CMakeLists.txt`. We are focused on maintaining a build configuration that
|
157
|
+
allows us to test that the project works in a few supported configurations
|
158
|
+
inside Google. We are not currently interested in supporting other requirements,
|
159
|
+
such as different operating systems, compilers, or build systems.
|
128
160
|
|
129
161
|
Contact
|
130
162
|
=======
|
131
163
|
|
132
|
-
Snappy is distributed through GitHub. For the latest version
|
133
|
-
|
134
|
-
|
135
|
-
http://google.github.io/snappy/
|
136
|
-
|
137
|
-
or the repository at
|
138
|
-
|
139
|
-
https://github.com/google/snappy
|
164
|
+
Snappy is distributed through GitHub. For the latest version and other
|
165
|
+
information, see https://github.com/google/snappy.
|