zstd-ruby 2.0.0.pre.preview1 → 2.0.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 +4 -4
- data/ext/zstdruby/streaming_compress.c +20 -5
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c217e3eae21252b6af27b109769b412d7f2e527366b7f197c16ceb1a5c9b7374
|
4
|
+
data.tar.gz: 67f593fa170baaf3b1a87e0683794da2d2bbd7b89d6eb58c2ac8e513f18aba84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdea0867d22baff1f4d1992103b0afd851495f7cb1ab6cbf6fcbaec9fc90f427e4c856fc7cbce47eea70a17165b43e3ad5410199c9a7c7abd71a6c62b69042ee
|
7
|
+
data.tar.gz: b2a4087ac5eabdde754f4b9eb2f33e5409022856d617787f4d2f920b9143de930f5a6ed5a91e52a205743c18031e90bc859679fd70584215fedf454140dfd12b
|
@@ -4,6 +4,7 @@ struct streaming_compress_t {
|
|
4
4
|
ZSTD_CCtx* ctx;
|
5
5
|
VALUE buf;
|
6
6
|
size_t buf_size;
|
7
|
+
VALUE pending; /* accumulate compressed bytes produced by write() */
|
7
8
|
};
|
8
9
|
|
9
10
|
static void
|
@@ -12,8 +13,10 @@ streaming_compress_mark(void *p)
|
|
12
13
|
struct streaming_compress_t *sc = p;
|
13
14
|
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
14
15
|
rb_gc_mark_movable(sc->buf);
|
16
|
+
rb_gc_mark_movable(sc->pending);
|
15
17
|
#else
|
16
18
|
rb_gc_mark(sc->buf);
|
19
|
+
rb_gc_mark(sc->pending);
|
17
20
|
#endif
|
18
21
|
}
|
19
22
|
|
@@ -40,6 +43,7 @@ streaming_compress_compact(void *p)
|
|
40
43
|
{
|
41
44
|
struct streaming_compress_t *sc = p;
|
42
45
|
sc->buf = rb_gc_location(sc->buf);
|
46
|
+
sc->pending = rb_gc_location(sc->pending);
|
43
47
|
}
|
44
48
|
#endif
|
45
49
|
|
@@ -64,6 +68,7 @@ rb_streaming_compress_allocate(VALUE klass)
|
|
64
68
|
sc->ctx = NULL;
|
65
69
|
sc->buf = Qnil;
|
66
70
|
sc->buf_size = 0;
|
71
|
+
sc->pending = Qnil;
|
67
72
|
return obj;
|
68
73
|
}
|
69
74
|
|
@@ -86,6 +91,7 @@ rb_streaming_compress_initialize(int argc, VALUE *argv, VALUE obj)
|
|
86
91
|
sc->ctx = ctx;
|
87
92
|
sc->buf = rb_str_new(NULL, buffOutSize);
|
88
93
|
sc->buf_size = buffOutSize;
|
94
|
+
sc->pending = rb_str_new(0, 0);
|
89
95
|
|
90
96
|
return obj;
|
91
97
|
}
|
@@ -142,7 +148,6 @@ static VALUE
|
|
142
148
|
rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
|
143
149
|
{
|
144
150
|
size_t total = 0;
|
145
|
-
VALUE result = rb_str_new(0, 0);
|
146
151
|
struct streaming_compress_t* sc;
|
147
152
|
TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
|
148
153
|
const char* output_data = RSTRING_PTR(sc->buf);
|
@@ -160,6 +165,10 @@ rb_streaming_compress_write(int argc, VALUE *argv, VALUE obj)
|
|
160
165
|
if (ZSTD_isError(ret)) {
|
161
166
|
rb_raise(rb_eRuntimeError, "compress error error code: %s", ZSTD_getErrorName(ret));
|
162
167
|
}
|
168
|
+
/* collect produced bytes */
|
169
|
+
if (output.pos > 0) {
|
170
|
+
rb_str_cat(sc->pending, output.dst, output.pos);
|
171
|
+
}
|
163
172
|
total += RSTRING_LEN(str);
|
164
173
|
}
|
165
174
|
}
|
@@ -192,8 +201,11 @@ rb_streaming_compress_flush(VALUE obj)
|
|
192
201
|
{
|
193
202
|
struct streaming_compress_t* sc;
|
194
203
|
TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
|
195
|
-
VALUE
|
196
|
-
|
204
|
+
VALUE drained = no_compress(sc, ZSTD_e_flush);
|
205
|
+
rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
|
206
|
+
VALUE out = sc->pending;
|
207
|
+
sc->pending = rb_str_new(0, 0);
|
208
|
+
return out;
|
197
209
|
}
|
198
210
|
|
199
211
|
static VALUE
|
@@ -201,8 +213,11 @@ rb_streaming_compress_finish(VALUE obj)
|
|
201
213
|
{
|
202
214
|
struct streaming_compress_t* sc;
|
203
215
|
TypedData_Get_Struct(obj, struct streaming_compress_t, &streaming_compress_type, sc);
|
204
|
-
VALUE
|
205
|
-
|
216
|
+
VALUE drained = no_compress(sc, ZSTD_e_end);
|
217
|
+
rb_str_cat(sc->pending, RSTRING_PTR(drained), RSTRING_LEN(drained));
|
218
|
+
VALUE out = sc->pending;
|
219
|
+
sc->pending = rb_str_new(0, 0);
|
220
|
+
return out;
|
206
221
|
}
|
207
222
|
|
208
223
|
extern VALUE rb_mZstd, cStreamingCompress;
|
data/lib/zstd-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zstd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SpringMT
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-09-26 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -188,7 +187,6 @@ homepage: https://github.com/SpringMT/zstd-ruby
|
|
188
187
|
licenses:
|
189
188
|
- MIT
|
190
189
|
metadata: {}
|
191
|
-
post_install_message:
|
192
190
|
rdoc_options: []
|
193
191
|
require_paths:
|
194
192
|
- lib
|
@@ -199,12 +197,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
197
|
version: '0'
|
200
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
199
|
requirements:
|
202
|
-
- - "
|
200
|
+
- - ">="
|
203
201
|
- !ruby/object:Gem::Version
|
204
|
-
version:
|
202
|
+
version: '0'
|
205
203
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
-
signing_key:
|
204
|
+
rubygems_version: 3.6.2
|
208
205
|
specification_version: 4
|
209
206
|
summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
|
210
207
|
test_files: []
|