multi_compress 0.6.0 → 0.7.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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -0
  3. data/GET_STARTED.md +5 -3
  4. data/README.md +2 -2
  5. data/THIRD_PARTY_NOTICES.md +3 -3
  6. data/ext/multi_compress/exports.darwin +1 -0
  7. data/ext/multi_compress/exports.map +4 -0
  8. data/ext/multi_compress/extconf.rb +20 -0
  9. data/ext/multi_compress/multi_compress.c +352 -149
  10. data/ext/multi_compress/vendor/.vendored +2 -2
  11. data/ext/multi_compress/vendor/brotli/c/common/version.h +2 -2
  12. data/ext/multi_compress/vendor/brotli/c/dec/decode.c +59 -30
  13. data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -3
  14. data/ext/multi_compress/vendor/zstd/lib/BUCK +10 -5
  15. data/ext/multi_compress/vendor/zstd/lib/README.md +25 -5
  16. data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +6 -2
  17. data/ext/multi_compress/vendor/zstd/lib/common/bits.h +1 -1
  18. data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +3 -3
  19. data/ext/multi_compress/vendor/zstd/lib/common/bmi2.h +40 -0
  20. data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +37 -11
  21. data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +7 -6
  22. data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +4 -3
  23. data/ext/multi_compress/vendor/zstd/lib/common/pool.c +16 -19
  24. data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +31 -0
  25. data/ext/multi_compress/vendor/zstd/lib/common/threading.c +16 -2
  26. data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +9 -0
  27. data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +4 -2
  28. data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +300 -3
  29. data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +4 -0
  30. data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +4 -1
  31. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +775 -214
  32. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +35 -6
  33. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +9 -5
  34. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +14 -5
  35. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +2 -2
  36. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +2 -2
  37. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +49 -5
  38. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +11 -11
  39. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +11 -0
  40. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +16 -18
  41. data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +3 -3
  42. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +64 -39
  43. data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +30 -2
  44. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +78 -64
  45. data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +182 -18
  46. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +59 -27
  47. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +11 -0
  48. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +194 -93
  49. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +225 -85
  50. data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +19 -2
  51. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +136 -91
  52. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +77 -77
  53. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +48 -42
  54. data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +18 -14
  55. data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +66 -20
  56. data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +10 -6
  57. data/ext/multi_compress/vendor/zstd/lib/install_oses.mk +17 -0
  58. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +10 -8
  59. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +5 -364
  60. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +4 -5
  61. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +7 -3
  62. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +8 -5
  63. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +3 -3
  64. data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +1 -0
  65. data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +8 -7
  66. data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +1 -0
  67. data/ext/multi_compress/vendor/zstd/lib/module.modulemap +0 -21
  68. data/ext/multi_compress/vendor/zstd/lib/zstd.h +209 -112
  69. data/lib/multi_compress/active_record.rb +11 -5
  70. data/lib/multi_compress/codec.rb +164 -94
  71. data/lib/multi_compress/database/api.rb +42 -0
  72. data/lib/multi_compress/database/decoding.rb +42 -0
  73. data/lib/multi_compress/database/dictionary.rb +72 -0
  74. data/lib/multi_compress/database/encoding.rb +31 -0
  75. data/lib/multi_compress/database/header.rb +71 -0
  76. data/lib/multi_compress/database/operations.rb +73 -0
  77. data/lib/multi_compress/database/validation.rb +95 -0
  78. data/lib/multi_compress/database.rb +10 -282
  79. data/lib/multi_compress/db_deployment/bundle_archiver.rb +70 -0
  80. data/lib/multi_compress/db_deployment/bundle_metadata.rb +56 -0
  81. data/lib/multi_compress/db_deployment/bundle_stager.rb +62 -0
  82. data/lib/multi_compress/db_deployment/commands.rb +309 -0
  83. data/lib/multi_compress/db_deployment/deployment_bundle.rb +80 -0
  84. data/lib/multi_compress/db_deployment/deterministic_tar_writer.rb +76 -0
  85. data/lib/multi_compress/db_deployment/dictionary_registry.rb +244 -0
  86. data/lib/multi_compress/db_deployment/readable_view.rb +112 -0
  87. data/lib/multi_compress/db_deployment/readable_view_options.rb +51 -0
  88. data/lib/multi_compress/db_deployment/sql_identifiers.rb +45 -0
  89. data/lib/multi_compress/db_deployment.rb +10 -844
  90. data/lib/multi_compress/reader/buffer_operations.rb +57 -0
  91. data/lib/multi_compress/reader/read_operations.rb +69 -0
  92. data/lib/multi_compress/reader.rb +97 -0
  93. data/lib/multi_compress/stream_io.rb +13 -0
  94. data/lib/multi_compress/version.rb +1 -1
  95. data/lib/multi_compress/writer.rb +85 -0
  96. data/lib/multi_compress.rb +42 -333
  97. data/multi_compress.gemspec +2 -0
  98. data/mysql_udf/Makefile +12 -5
  99. data/mysql_udf/multi_compress_mysql.exports +6 -0
  100. data/postgres_extension/Makefile +2 -1
  101. data/postgres_extension/test/run_e2e.sh +28 -10
  102. metadata +30 -10
  103. data/ext/multi_compress/vendor/lz4/lib/Makefile +0 -244
  104. data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +0 -63
  105. data/ext/multi_compress/vendor/zstd/lib/Makefile +0 -389
  106. data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebc73c83a9de27fcde1080879572c025a30a3f2bb391313d5c21e56fd558cde3
4
- data.tar.gz: 20a2db05bc0ecafbb399a01275391e5d1c08feafe8fc51f683859463b9c14ff8
3
+ metadata.gz: a5735160681919d2bd51ffde344dcd31aaf9ca08767c0939e9d657a4915e4432
4
+ data.tar.gz: 2454cd5e4ee3dd82e4dcb20af13e48adc44f8cb5fa487d6ddc4d74bf9e655848
5
5
  SHA512:
6
- metadata.gz: aeac010c1419ad5b10919ba1d3e18b2053950555117dffc1075be2ce7b1e6ae9b2a9ff14d2684556a9aa0904ad030f688f4d954cb710692b263e8bb4ca238365
7
- data.tar.gz: 9493318cf1321bbe525a8f65992675ef7b0760bf853192cf04146b8280f32011c925a5576876787849737d26eea7cc807c739ff0d5182c652b939c0150c3bf5b
6
+ metadata.gz: 82c35a0bd5623186ba2220689e3fdd17c6fb91c0b307973d1517750b6e2391645c78cf610f98c69198e58165652bdc0c426270ea12907cb3e1f520529738e069
7
+ data.tar.gz: db6f54a4b6731d0c1ceb35de2c6d28b19bb3b53dfb1dfcceef97a5230d84d0e945ac82e088d6fdf9bfb19e6be966c10a2c79846e71b31905585be00fc2c224d6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0]
4
+
5
+ ### Changed
6
+ - Update vendored zstd to 1.6.0, including upstream fixes for streaming
7
+ decompression, dictionary compression and dictionary training. Compressed
8
+ output and trained dictionaries were byte-identical to 1.5.7 in our tests, and
9
+ data stays compatible in both directions. Rebuild and redeploy the
10
+ PostgreSQL extension and the MySQL UDF to get the decoder fixes in the database.
11
+ - Streaming decoders reject truncated input: `Inflater#finish` and `Reader`
12
+ (`read`, `read(length)`, `gets`, `each_line`) raise `MultiCompress::DataError`
13
+ when a zstd, brotli or lz4 stream ends early. They used to return the partial
14
+ output as if it were complete.
15
+ - zstd input without a declared content size (written by `Deflater`/`Writer` or
16
+ other streaming encoders): `MultiCompress.decompress` now decodes every
17
+ concatenated frame and raises `DataError` for a truncated frame or for garbage
18
+ after a frame. It used to return partial output, only the first frame, or
19
+ ignore the garbage. The one-shot path for a first frame with a declared content
20
+ size still decodes only that frame and rejects concatenated frames. `Inflater#write`
21
+ no longer drops the rest of a chunk after a zstd frame ends.
22
+ - A frame compressed with a zstd dictionary always needs `dictionary:` to decode.
23
+ It could previously decode without one if the same thread had just decoded a
24
+ streaming frame with that dictionary.
25
+ - `Inflater` reports a corrupted zstd dictionary as `Dictionary is corrupted`
26
+ instead of `Allocation error` (zstd 1.6.0). `compress`/`decompress` still raise
27
+ `MemError` ("failed to create cdict/ddict") for such a dictionary.
28
+
29
+ ### Fixed
30
+ - Use-after-free of a zstd dictionary: decoding a frame without content size left
31
+ its `DDict` referenced on the thread-local decompression context, and a later
32
+ one-shot `decompress` on that thread read it after GC had freed the
33
+ `Dictionary`. One-shot decoding now passes the dictionary explicitly, and the
34
+ context is reset on every exit, including exceptions.
35
+ - Vendored codec symbols are private in the Ruby extension and the MySQL UDF
36
+ (the PostgreSQL extension already used an export map). A zstd already loaded in
37
+ the process, such as the system libzstd pulled in by `mysql2` or linked into
38
+ mysqld 8, can no longer replace the bundled implementation. zstd's weak
39
+ `ZSTD_trace_*` hooks are compiled out.
40
+ - `script/sanitize.sh` builds an ASAN/UBSAN-instrumented extension. mkmf ignores
41
+ `CFLAGS` from the environment, so the script used to run the suite on an
42
+ uninstrumented build.
43
+
44
+ ## [0.6.1]
45
+
46
+ ### Changed
47
+ - Update vendored Brotli to 1.2.1, including the upstream security fix for an
48
+ out-of-bounds write.
49
+ - Refactor Ruby streaming, database, and deployment code into focused modules and
50
+ collaborators without changing the public API.
51
+ - Use a consistent singleton-method style and accessor macros for internal
52
+ configuration and adapter state.
53
+
3
54
  ## [0.6.0]
4
55
 
5
56
  ### Added
data/GET_STARTED.md CHANGED
@@ -163,6 +163,8 @@ inflater.close
163
163
  original_data = decompressed_chunks.join
164
164
  ```
165
165
 
166
+ `Inflater#finish` (and `Reader` at end of input) raises `MultiCompress::DataError` when the compressed stream ends before its end marker, so a truncated file or upload is reported instead of returning partial data.
167
+
166
168
  ### Advanced Streaming Example
167
169
 
168
170
  ```ruby
@@ -402,7 +404,7 @@ end
402
404
 
403
405
  Dramatically improves compression on small, similar data (JSON APIs, configs, logs).
404
406
 
405
- **Important**: Dictionary training is available for **Zstd** in the current release (vendored zstd **1.5.7**). Brotli dictionaries can be used, but this gem does not expose Brotli training through `train_dictionary`.
407
+ **Important**: Dictionary training is available for **Zstd** in the current release (vendored zstd **1.6.0**). Brotli dictionaries can be used, but this gem does not expose Brotli training through `train_dictionary`.
406
408
 
407
409
  ### Training Dictionary (Zstd)
408
410
 
@@ -679,9 +681,9 @@ MultiCompress.available?(:zstd) # => true
679
681
  MultiCompress.available?(:fake) # => false
680
682
 
681
683
  # Get library versions
682
- MultiCompress.version(:zstd) # => "1.5.7"
684
+ MultiCompress.version(:zstd) # => "1.6.0"
683
685
  MultiCompress.version(:lz4) # => "1.10.0"
684
- MultiCompress.version(:brotli) # => "1.2.0"
686
+ MultiCompress.version(:brotli) # => "1.2.1"
685
687
  ```
686
688
 
687
689
  ### Data Integrity
data/README.md CHANGED
@@ -7,9 +7,9 @@
7
7
  Modern compression technology: **zstd**, **lz4**, **brotli** — unified compression platform with native C performance, **fiber-friendly** for modern async Ruby stacks.
8
8
 
9
9
  Bundled library versions in the current release:
10
- - **zstd 1.5.7**
10
+ - **zstd 1.6.0**
11
11
  - **lz4 1.10.0**
12
- - **brotli 1.2.0**
12
+ - **brotli 1.2.1**
13
13
 
14
14
  📖 **[Get Started →](GET_STARTED.md)** — Complete technology overview, algorithms, and implementation details
15
15
 
@@ -6,9 +6,9 @@ MultiCompress vendors C sources from upstream compression libraries so the gem c
6
6
 
7
7
  | Library | Vendored version | Vendored source scope | Upstream license used by MultiCompress |
8
8
  |---|---:|---|---|
9
- | Zstandard (`zstd`) | 1.5.7 | `lib/` | BSD side of upstream BSD OR GPLv2 licensing |
9
+ | Zstandard (`zstd`) | 1.6.0 | `lib/` | BSD side of upstream BSD OR GPLv2 licensing |
10
10
  | LZ4 | 1.10.0 | `lib/` | BSD 2-Clause |
11
- | Brotli | 1.2.0 | `c/common`, `c/enc`, `c/dec`, `c/include` | MIT |
11
+ | Brotli | 1.2.1 | `c/common`, `c/enc`, `c/dec`, `c/include` | MIT |
12
12
 
13
13
  ## Notes
14
14
 
@@ -19,6 +19,6 @@ MultiCompress vendors C sources from upstream compression libraries so the gem c
19
19
 
20
20
  ## Upstream projects
21
21
 
22
- - Zstandard: https://github.com/facebook/zstd
22
+ - Zstandard: https://github.com/meta/zstd
23
23
  - LZ4: https://github.com/lz4/lz4
24
24
  - Brotli: https://github.com/google/brotli
@@ -0,0 +1 @@
1
+ _Init_multi_compress
@@ -0,0 +1,4 @@
1
+ {
2
+ global: Init_multi_compress;
3
+ local: *;
4
+ };
@@ -253,6 +253,26 @@ end
253
253
  $CFLAGS += " -O3"
254
254
  $CFLAGS += " -DXXH_NAMESPACE=MULTICOMPRESS_"
255
255
 
256
+ if vpath_dirs
257
+ if RbConfig::CONFIG["GCC"] == "yes" && try_cflags("-fvisibility=hidden", werror: false)
258
+ $CFLAGS += " -fvisibility=hidden"
259
+ puts " vendored codec symbols: hidden"
260
+ elsif RUBY_PLATFORM.match?(/darwin|linux/)
261
+ puts " WARNING: -fvisibility=hidden unavailable; relying on the linker export list"
262
+ else
263
+ puts " WARNING: -fvisibility=hidden unavailable; vendored codec symbols may be exported"
264
+ end
265
+ $CPPFLAGS += " -DZSTDLIB_VISIBLE= -DZSTDERRORLIB_VISIBLE= -DZDICTLIB_VISIBLE=" \
266
+ " -DLZ4LIB_VISIBILITY= -DLZ4FLIB_VISIBILITY="
267
+ $CPPFLAGS += " -DZSTD_TRACE=0"
268
+
269
+ if RUBY_PLATFORM.include?("darwin")
270
+ $DLDFLAGS += " -Wl,-exported_symbols_list,#{File.join(__dir__, 'exports.darwin')}"
271
+ elsif RUBY_PLATFORM.include?("linux")
272
+ $DLDFLAGS += " -Wl,--version-script=#{File.join(__dir__, 'exports.map')}"
273
+ end
274
+ end
275
+
256
276
  if RUBY_PLATFORM.include?("darwin") && try_cflags("-Wno-default-const-init-field-unsafe")
257
277
  $CFLAGS += " -Wno-default-const-init-field-unsafe"
258
278
  end