ruby-zstds 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/extconf.rb +98 -25
- data/ext/zstds_ext/buffer.c +0 -2
- data/ext/zstds_ext/dictionary.c +11 -1
- data/ext/zstds_ext/error.c +0 -4
- data/ext/zstds_ext/io.c +0 -1
- data/ext/zstds_ext/main.c +3 -1
- data/ext/zstds_ext/option.c +0 -3
- data/ext/zstds_ext/stream/compressor.c +0 -3
- data/ext/zstds_ext/stream/decompressor.c +0 -3
- data/ext/zstds_ext/string.c +0 -1
- data/lib/zstds/dictionary.rb +8 -4
- data/lib/zstds/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd4f85616a45bb4ea60d08e4f6e4dfa0091d5a098458e3f5c5ac81d6c9113aa3
|
4
|
+
data.tar.gz: a7b1afaa038f4339b0de26e91ae86c16a942620f8f450cbc791a7330cec372cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e76817922415c3fa1381aca25636aef90cc1a4bb98c8c8adc998667fc5eb10e24e27f66127f6c93d341af222bbf44229ef37996ea24fa89888b5381f0e8f1fb
|
7
|
+
data.tar.gz: c4aaa1527b723e6c2eec1f185b10657d50fd2e55fb0a9debf4cf993d561931b8cb60216023b0971d4739389eadcdccec011db668b943bfdc49f323e5852f409c
|
data/ext/extconf.rb
CHANGED
@@ -9,26 +9,96 @@ have_func "rb_thread_call_without_gvl", "ruby/thread.h"
|
|
9
9
|
# https://bugs.gentoo.org/713940
|
10
10
|
$LDFLAGS << " -pthread" # rubocop:disable Style/GlobalVars
|
11
11
|
|
12
|
-
def require_header(name,
|
12
|
+
def require_header(name, constants: [], macroses: [], types: [])
|
13
13
|
abort "Can't find #{name} header" unless find_header name
|
14
14
|
|
15
|
+
constants.each do |constant|
|
16
|
+
abort "Can't find #{constant} constant in #{name} header" unless have_const constant, name
|
17
|
+
end
|
18
|
+
|
19
|
+
macroses.each do |macro|
|
20
|
+
abort "Can't find #{macro} macro in #{name} header" unless have_macro macro, name
|
21
|
+
end
|
22
|
+
|
15
23
|
types.each do |type|
|
16
24
|
abort "Can't find #{type} type in #{name} header" unless find_type type, nil, name
|
17
25
|
end
|
18
26
|
end
|
19
27
|
|
20
|
-
require_header "zstd_errors.h", %w[
|
21
|
-
ZSTD_ErrorCode
|
22
|
-
]
|
23
|
-
require_header "zstd.h", [
|
24
|
-
"ZSTD_CCtx *",
|
25
|
-
"ZSTD_DCtx *",
|
26
|
-
"ZSTD_strategy",
|
27
|
-
"ZSTD_bounds",
|
28
|
-
"ZSTD_inBuffer",
|
29
|
-
"ZSTD_outBuffer"
|
30
|
-
]
|
31
28
|
require_header "zdict.h"
|
29
|
+
require_header(
|
30
|
+
"zstd.h",
|
31
|
+
:constants => %w[
|
32
|
+
ZSTD_btlazy2
|
33
|
+
ZSTD_btopt
|
34
|
+
ZSTD_btultra
|
35
|
+
ZSTD_btultra2
|
36
|
+
ZSTD_c_chainLog
|
37
|
+
ZSTD_c_checksumFlag
|
38
|
+
ZSTD_c_compressionLevel
|
39
|
+
ZSTD_c_contentSizeFlag
|
40
|
+
ZSTD_c_dictIDFlag
|
41
|
+
ZSTD_c_enableLongDistanceMatching
|
42
|
+
ZSTD_c_hashLog
|
43
|
+
ZSTD_c_jobSize
|
44
|
+
ZSTD_c_ldmBucketSizeLog
|
45
|
+
ZSTD_c_ldmHashLog
|
46
|
+
ZSTD_c_ldmHashRateLog
|
47
|
+
ZSTD_c_ldmMinMatch
|
48
|
+
ZSTD_c_minMatch
|
49
|
+
ZSTD_c_nbWorkers
|
50
|
+
ZSTD_c_overlapLog
|
51
|
+
ZSTD_c_searchLog
|
52
|
+
ZSTD_c_strategy
|
53
|
+
ZSTD_c_targetLength
|
54
|
+
ZSTD_c_windowLog
|
55
|
+
ZSTD_dfast
|
56
|
+
ZSTD_d_windowLogMax
|
57
|
+
ZSTD_e_continue
|
58
|
+
ZSTD_e_end
|
59
|
+
ZSTD_e_flush
|
60
|
+
ZSTD_fast
|
61
|
+
ZSTD_greedy
|
62
|
+
ZSTD_lazy
|
63
|
+
ZSTD_lazy2
|
64
|
+
],
|
65
|
+
:macroses => %w[ZSTD_VERSION_STRING],
|
66
|
+
:types => [
|
67
|
+
"ZSTD_bounds",
|
68
|
+
"ZSTD_CCtx *",
|
69
|
+
"ZSTD_DCtx *",
|
70
|
+
"ZSTD_inBuffer",
|
71
|
+
"ZSTD_outBuffer",
|
72
|
+
"ZSTD_strategy"
|
73
|
+
]
|
74
|
+
)
|
75
|
+
require_header(
|
76
|
+
"zstd_errors.h",
|
77
|
+
:constants => %w[
|
78
|
+
ZSTD_error_checksum_wrong
|
79
|
+
ZSTD_error_corruption_detected
|
80
|
+
ZSTD_error_dictionaryCreation_failed
|
81
|
+
ZSTD_error_dictionary_corrupted
|
82
|
+
ZSTD_error_dictionary_wrong
|
83
|
+
ZSTD_error_dstBuffer_null
|
84
|
+
ZSTD_error_dstSize_tooSmall
|
85
|
+
ZSTD_error_frameParameter_unsupported
|
86
|
+
ZSTD_error_frameParameter_windowTooLarge
|
87
|
+
ZSTD_error_init_missing
|
88
|
+
ZSTD_error_maxSymbolValue_tooLarge
|
89
|
+
ZSTD_error_maxSymbolValue_tooSmall
|
90
|
+
ZSTD_error_memory_allocation
|
91
|
+
ZSTD_error_parameter_outOfBound
|
92
|
+
ZSTD_error_parameter_unsupported
|
93
|
+
ZSTD_error_prefix_unknown
|
94
|
+
ZSTD_error_srcSize_wrong
|
95
|
+
ZSTD_error_stage_wrong
|
96
|
+
ZSTD_error_tableLog_tooLarge
|
97
|
+
ZSTD_error_version_unsupported
|
98
|
+
ZSTD_error_workSpace_tooSmall
|
99
|
+
],
|
100
|
+
:types => %w[ZSTD_ErrorCode]
|
101
|
+
)
|
32
102
|
|
33
103
|
def require_library(name, functions)
|
34
104
|
functions.each do |function|
|
@@ -39,26 +109,29 @@ end
|
|
39
109
|
require_library(
|
40
110
|
"zstd",
|
41
111
|
%w[
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
ZSTD_freeDCtx
|
112
|
+
ZDICT_getDictID
|
113
|
+
ZDICT_getDictHeaderSize
|
114
|
+
ZDICT_isError
|
115
|
+
ZDICT_trainFromBuffer
|
116
|
+
ZSTD_CCtx_loadDictionary
|
48
117
|
ZSTD_CCtx_setParameter
|
49
|
-
ZSTD_DCtx_setParameter
|
50
118
|
ZSTD_CCtx_setPledgedSrcSize
|
51
|
-
ZSTD_cParam_getBounds
|
52
|
-
ZSTD_dParam_getBounds
|
53
119
|
ZSTD_CStreamInSize
|
54
120
|
ZSTD_CStreamOutSize
|
121
|
+
ZSTD_compressStream2
|
122
|
+
ZSTD_cParam_getBounds
|
123
|
+
ZSTD_createCCtx
|
124
|
+
ZSTD_createDCtx
|
125
|
+
ZSTD_DCtx_setParameter
|
126
|
+
ZSTD_DCtx_loadDictionary
|
55
127
|
ZSTD_DStreamInSize
|
56
128
|
ZSTD_DStreamOutSize
|
57
|
-
ZSTD_compressStream2
|
58
129
|
ZSTD_decompressStream
|
59
|
-
|
60
|
-
|
61
|
-
|
130
|
+
ZSTD_dParam_getBounds
|
131
|
+
ZSTD_freeCCtx
|
132
|
+
ZSTD_freeDCtx
|
133
|
+
ZSTD_getErrorCode
|
134
|
+
ZSTD_isError
|
62
135
|
]
|
63
136
|
)
|
64
137
|
|
data/ext/zstds_ext/buffer.c
CHANGED
data/ext/zstds_ext/dictionary.c
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
#include <string.h>
|
7
7
|
#include <zdict.h>
|
8
8
|
|
9
|
-
#include "ruby.h"
|
10
9
|
#include "zstds_ext/buffer.h"
|
11
10
|
#include "zstds_ext/error.h"
|
12
11
|
#include "zstds_ext/gvl.h"
|
@@ -154,6 +153,16 @@ VALUE zstds_ext_get_dictionary_buffer_id(VALUE ZSTDS_EXT_UNUSED(self), VALUE buf
|
|
154
153
|
return UINT2NUM(id);
|
155
154
|
}
|
156
155
|
|
156
|
+
VALUE zstds_ext_get_dictionary_header_size(VALUE ZSTDS_EXT_UNUSED(self), VALUE buffer)
|
157
|
+
{
|
158
|
+
zstds_result_t result = ZDICT_getDictHeaderSize(RSTRING_PTR(buffer), RSTRING_LEN(buffer));
|
159
|
+
if (ZDICT_isError(result)) {
|
160
|
+
zstds_ext_raise_error(zstds_ext_get_error(ZSTD_getErrorCode(result)));
|
161
|
+
}
|
162
|
+
|
163
|
+
return SIZET2NUM(result);
|
164
|
+
}
|
165
|
+
|
157
166
|
// -- exports --
|
158
167
|
|
159
168
|
void zstds_ext_dictionary_exports(VALUE root_module)
|
@@ -161,5 +170,6 @@ void zstds_ext_dictionary_exports(VALUE root_module)
|
|
161
170
|
VALUE dictionary = rb_define_class_under(root_module, "Dictionary", rb_cObject);
|
162
171
|
|
163
172
|
rb_define_singleton_method(dictionary, "get_buffer_id", zstds_ext_get_dictionary_buffer_id, 1);
|
173
|
+
rb_define_singleton_method(dictionary, "get_header_size", zstds_ext_get_dictionary_header_size, 1);
|
164
174
|
rb_define_singleton_method(dictionary, "train_buffer", zstds_ext_train_dictionary_buffer, 2);
|
165
175
|
}
|
data/ext/zstds_ext/error.c
CHANGED
data/ext/zstds_ext/io.c
CHANGED
data/ext/zstds_ext/main.c
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
// Ruby bindings for zstd library.
|
2
2
|
// Copyright (c) 2019 AUTHORS, MIT License.
|
3
3
|
|
4
|
-
#include "ruby.h"
|
5
4
|
#include "zstds_ext/buffer.h"
|
6
5
|
#include "zstds_ext/dictionary.h"
|
7
6
|
#include "zstds_ext/io.h"
|
@@ -21,4 +20,7 @@ void Init_zstds_ext()
|
|
21
20
|
zstds_ext_compressor_exports(root_module);
|
22
21
|
zstds_ext_decompressor_exports(root_module);
|
23
22
|
zstds_ext_string_exports(root_module);
|
23
|
+
|
24
|
+
VALUE version = rb_str_new2(ZSTD_VERSION_STRING);
|
25
|
+
rb_define_const(root_module, "LIBRARY_VERSION", rb_obj_freeze(version));
|
24
26
|
}
|
data/ext/zstds_ext/option.c
CHANGED
data/ext/zstds_ext/string.c
CHANGED
data/lib/zstds/dictionary.rb
CHANGED
@@ -23,10 +23,6 @@ module ZSTDS
|
|
23
23
|
@buffer = buffer
|
24
24
|
end
|
25
25
|
|
26
|
-
def id
|
27
|
-
self.class.get_buffer_id @buffer
|
28
|
-
end
|
29
|
-
|
30
26
|
def self.train(samples, options = {})
|
31
27
|
Validation.validate_array samples
|
32
28
|
|
@@ -45,5 +41,13 @@ module ZSTDS
|
|
45
41
|
buffer = train_buffer samples, options
|
46
42
|
new buffer
|
47
43
|
end
|
44
|
+
|
45
|
+
def id
|
46
|
+
self.class.get_buffer_id @buffer
|
47
|
+
end
|
48
|
+
|
49
|
+
def header_size
|
50
|
+
self.class.get_header_size @buffer
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
data/lib/zstds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-zstds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Aladjev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: parallel
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1.
|
131
|
+
version: '1.22'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '1.
|
138
|
+
version: '1.22'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-minitest
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
145
|
+
version: '0.15'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0.
|
152
|
+
version: '0.15'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rubocop-performance
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0.
|
173
|
+
version: '0.6'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0.
|
180
|
+
version: '0.6'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: simplecov
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
260
|
- !ruby/object:Gem::Version
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
|
-
rubygems_version: 3.2.
|
263
|
+
rubygems_version: 3.2.22
|
264
264
|
signing_key:
|
265
265
|
specification_version: 4
|
266
266
|
summary: Ruby bindings for zstd library.
|