zstd-ruby 1.5.6.5 → 1.5.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/ext/zstdruby/zstdruby.c +7 -7
- data/lib/zstd-ruby/version.rb +1 -1
- data/lib/zstd-ruby.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe1a5bcfa102673b36ea9a48096636faa76535095211998cddfe316775a3d78
|
4
|
+
data.tar.gz: e2a96d0d1d2bdda0bc3d34080df219aeaa8c5274a2dac7a838730fce54ebe4f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bdffd7e5b2d824fdf5ebad116ef4b965c4d4d2a77898df5a51623020db6fddf0e4562aa4d80de7f8978fa5f557ce85e56d19042667c379b3ac97c3a274a9d11
|
7
|
+
data.tar.gz: 639a3d64cf8a8fa36a10cf180560a4102516d4da21e3100c1cdd724732fb583449c828ac4eeef6f9bad89c2f22467f7adf80b083116121ccff8d356c58246966
|
data/README.md
CHANGED
@@ -127,6 +127,45 @@ Zstd.read_skippable_frame(compressed_data_with_skippable_frame)
|
|
127
127
|
# => "sample data"
|
128
128
|
```
|
129
129
|
|
130
|
+
### Stream Writer and Reader Wrapper
|
131
|
+
**EXPERIMENTAL**
|
132
|
+
|
133
|
+
* These features are experimental and may be subject to API changes in future releases.
|
134
|
+
* There may be performance and compatibility issues, so extensive testing is required before production use.
|
135
|
+
* If you have any questions, encounter bugs, or have suggestions, please report them via [GitHub issues](https://github.com/SpringMT/zstd-ruby/issues).
|
136
|
+
|
137
|
+
#### Zstd::StreamWriter
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
require 'stringio'
|
141
|
+
require 'zstd-ruby'
|
142
|
+
|
143
|
+
io = StringIO.new
|
144
|
+
stream = Zstd::StreamWriter.new(io)
|
145
|
+
stream.write("abc")
|
146
|
+
stream.finish
|
147
|
+
|
148
|
+
io.rewind
|
149
|
+
# Retrieve the compressed data
|
150
|
+
compressed_data = io.read
|
151
|
+
```
|
152
|
+
|
153
|
+
#### Zstd::StreamReader
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
require 'stringio'
|
157
|
+
require 'zstd-ruby' # Add the appropriate require statement if necessary
|
158
|
+
|
159
|
+
io = StringIO.new(compressed_data)
|
160
|
+
reader = Zstd::StreamReader.new(io)
|
161
|
+
|
162
|
+
# Read and output the decompressed data
|
163
|
+
puts reader.read(10) # 'abc'
|
164
|
+
puts reader.read(10) # 'def'
|
165
|
+
puts reader.read(10) # '' (end of data)
|
166
|
+
```
|
167
|
+
|
168
|
+
|
130
169
|
## JRuby
|
131
170
|
This gem does not support JRuby.
|
132
171
|
|
data/ext/zstdruby/zstdruby.c
CHANGED
@@ -87,13 +87,13 @@ static VALUE rb_compress_using_dict(int argc, VALUE *argv, VALUE self)
|
|
87
87
|
|
88
88
|
static VALUE decompress_buffered(ZSTD_DCtx* dctx, const char* input_data, size_t input_size)
|
89
89
|
{
|
90
|
-
VALUE output_string = rb_str_new(NULL, 0);
|
91
|
-
ZSTD_outBuffer output = { NULL, 0, 0 };
|
92
|
-
|
93
90
|
ZSTD_inBuffer input = { input_data, input_size, 0 };
|
91
|
+
VALUE result = rb_str_new(0, 0);
|
92
|
+
|
94
93
|
while (input.pos < input.size) {
|
94
|
+
ZSTD_outBuffer output = { NULL, 0, 0 };
|
95
95
|
output.size += ZSTD_DStreamOutSize();
|
96
|
-
|
96
|
+
VALUE output_string = rb_str_new(NULL, output.size);
|
97
97
|
output.dst = RSTRING_PTR(output_string);
|
98
98
|
|
99
99
|
size_t ret = zstd_stream_decompress(dctx, &output, &input, false);
|
@@ -101,10 +101,10 @@ static VALUE decompress_buffered(ZSTD_DCtx* dctx, const char* input_data, size_t
|
|
101
101
|
ZSTD_freeDCtx(dctx);
|
102
102
|
rb_raise(rb_eRuntimeError, "%s: %s", "ZSTD_decompressStream failed", ZSTD_getErrorName(ret));
|
103
103
|
}
|
104
|
+
rb_str_cat(result, output.dst, output.pos);
|
104
105
|
}
|
105
|
-
rb_str_resize(output_string, output.pos);
|
106
106
|
ZSTD_freeDCtx(dctx);
|
107
|
-
return
|
107
|
+
return result;
|
108
108
|
}
|
109
109
|
|
110
110
|
static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
|
@@ -134,7 +134,7 @@ static VALUE rb_decompress(int argc, VALUE *argv, VALUE self)
|
|
134
134
|
VALUE output = rb_str_new(NULL, uncompressed_size);
|
135
135
|
char* output_data = RSTRING_PTR(output);
|
136
136
|
|
137
|
-
size_t const decompress_size =
|
137
|
+
size_t const decompress_size = zstd_decompress(dctx, output_data, uncompressed_size, input_data, input_size, false);
|
138
138
|
if (ZSTD_isError(decompress_size)) {
|
139
139
|
rb_raise(rb_eRuntimeError, "%s: %s", "decompress error", ZSTD_getErrorName(decompress_size));
|
140
140
|
}
|
data/lib/zstd-ruby/version.rb
CHANGED
data/lib/zstd-ruby.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zstd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.6.
|
4
|
+
version: 1.5.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|