digest-murmurhash 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Rakefile +1 -2
- data/digest-murmurhash.gemspec +5 -8
- data/ext/digest/murmurhash/extconf.rb +0 -3
- data/ext/digest/murmurhash/murmurhash.c +121 -202
- data/ext/digest/murmurhash/murmurhash.h +23 -55
- data/ext/digest/murmurhash/murmurhash1.c +35 -47
- data/ext/digest/murmurhash/murmurhash1.h +0 -2
- data/ext/digest/murmurhash/murmurhash2.c +35 -48
- data/ext/digest/murmurhash/murmurhash2.h +0 -2
- data/ext/digest/murmurhash/murmurhash2a.c +41 -62
- data/ext/digest/murmurhash/murmurhash2a.h +0 -2
- data/ext/digest/murmurhash/murmurhash64a.c +40 -52
- data/ext/digest/murmurhash/murmurhash64a.h +0 -3
- data/ext/digest/murmurhash/murmurhash64b.c +56 -68
- data/ext/digest/murmurhash/murmurhash64b.h +0 -2
- data/ext/digest/murmurhash/murmurhash_aligned2.c +39 -51
- data/ext/digest/murmurhash/murmurhash_aligned2.h +0 -2
- data/ext/digest/murmurhash/murmurhash_neutral2.c +39 -51
- data/ext/digest/murmurhash/murmurhash_neutral2.h +0 -2
- data/lib/digest/murmurhash.rb +72 -6
- data/spec/digest_spec.rb +20 -19
- data/spec/exception_spec.rb +4 -4
- data/spec/mem_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -27
- data/lib/digest/murmurhash/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4bb19a065230c4cf479bbc3e5d30a3ecacaab7e
|
4
|
+
data.tar.gz: 8b6b55cb5d5d3c398e9ac006b5b84359272c034d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09aa8502b047d0487b5727846236e91c33d06e7db3bfdc89f74ddc71f935d7f672232d3c6e27fc5c588fe6c90fb8d151e7611c356e2c168e216e20822862d07a
|
7
|
+
data.tar.gz: 1b6a03328a0428b3cc5455ca306fcc4d5bab0c5a8609300e9b7dbc774a499b8921d9f5b96b653ec3c72b8fa4d59cec5fcffe09447eac5d84f1c1b5ef4dc92771
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -17,8 +17,7 @@ Rake::ExtensionTask.new('murmurhash', spec) do |ext|
|
|
17
17
|
ext.lib_dir = 'lib/digest/murmurhash'
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
desc "gem reinstall v#{Digest::MurmurHash::VERSION}"
|
20
|
+
desc "gem reinstall"
|
22
21
|
task :reinstall do |t|
|
23
22
|
system "gem uninstall murmurhash"
|
24
23
|
system "rake clean"
|
data/digest-murmurhash.gemspec
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'digest/murmurhash/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = "digest-murmurhash"
|
8
|
-
spec.version =
|
5
|
+
spec.version = "1.0.0"
|
9
6
|
spec.author = "ksss"
|
10
7
|
spec.email = "co000ri@gmail.com"
|
11
8
|
spec.description = %q{Digest::MurmurHash is class collections of use algorithm MurmurHash desiged by Austin Appleby.}
|
@@ -19,9 +16,9 @@ Gem::Specification.new do |spec|
|
|
19
16
|
spec.require_paths = ["lib"]
|
20
17
|
spec.extensions = ["ext/digest/murmurhash/extconf.rb"]
|
21
18
|
|
22
|
-
spec.add_runtime_dependency "digest-
|
23
|
-
spec.add_development_dependency "bundler"
|
19
|
+
spec.add_runtime_dependency "digest-simple"
|
20
|
+
spec.add_development_dependency "bundler"
|
24
21
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "rake-compiler"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "rake-compiler"
|
27
24
|
end
|
@@ -8,246 +8,165 @@
|
|
8
8
|
#include "murmurhash_aligned2.h"
|
9
9
|
|
10
10
|
VALUE cDigest_MurmurHash1,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ID
|
18
|
-
|
19
|
-
|
20
|
-
VALUE
|
21
|
-
murmur_seed_get32(VALUE self)
|
22
|
-
{
|
23
|
-
if (!rb_ivar_defined(self, id_seed)) {
|
24
|
-
rb_ivar_set(self, id_seed, rb_usascii_str_new(DEFAULT_SEED, 4));
|
25
|
-
}
|
26
|
-
return rb_ivar_get(self, id_seed);
|
27
|
-
}
|
28
|
-
|
29
|
-
VALUE
|
30
|
-
murmur_seed_set32(VALUE self, VALUE obj)
|
31
|
-
{
|
32
|
-
StringValue(obj);
|
33
|
-
if (RSTRING_LEN(obj) != 4) {
|
34
|
-
rb_raise(rb_eArgError, "seed string should 64 bit chars");
|
35
|
-
}
|
36
|
-
return rb_ivar_set(self, id_seed, obj);
|
37
|
-
}
|
11
|
+
cDigest_MurmurHash2,
|
12
|
+
cDigest_MurmurHash2A,
|
13
|
+
cDigest_MurmurHash64A,
|
14
|
+
cDigest_MurmurHash64B,
|
15
|
+
cDigest_MurmurHashNeutral2,
|
16
|
+
cDigest_MurmurHashAligned2;
|
17
|
+
ID id_DEFAULT_SEED;
|
18
|
+
ID iv_seed;
|
19
|
+
ID iv_buffer;
|
38
20
|
|
39
|
-
|
40
|
-
|
21
|
+
void
|
22
|
+
assign_by_endian_32(uint8_t *digest, uint64_t h)
|
41
23
|
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
if (BIGENDIAN_P()) {
|
25
|
+
digest[0] = h >> 24;
|
26
|
+
digest[1] = h >> 16;
|
27
|
+
digest[2] = h >> 8;
|
28
|
+
digest[3] = h;
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
digest[3] = h >> 24;
|
32
|
+
digest[2] = h >> 16;
|
33
|
+
digest[1] = h >> 8;
|
34
|
+
digest[0] = h;
|
35
|
+
}
|
46
36
|
}
|
47
37
|
|
48
|
-
|
49
|
-
|
38
|
+
void
|
39
|
+
assign_by_endian_64(uint8_t *digest, uint64_t h)
|
50
40
|
{
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
41
|
+
if (BIGENDIAN_P()) {
|
42
|
+
digest[0] = h >> 56;
|
43
|
+
digest[1] = h >> 48;
|
44
|
+
digest[2] = h >> 40;
|
45
|
+
digest[3] = h >> 32;
|
46
|
+
digest[4] = h >> 24;
|
47
|
+
digest[5] = h >> 16;
|
48
|
+
digest[6] = h >> 8;
|
49
|
+
digest[7] = h;
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
digest[7] = h >> 56;
|
53
|
+
digest[6] = h >> 48;
|
54
|
+
digest[5] = h >> 40;
|
55
|
+
digest[4] = h >> 32;
|
56
|
+
digest[3] = h >> 24;
|
57
|
+
digest[2] = h >> 16;
|
58
|
+
digest[1] = h >> 8;
|
59
|
+
digest[0] = h;
|
60
|
+
}
|
56
61
|
}
|
57
62
|
|
58
63
|
uint32_t
|
59
64
|
_murmur_finish32(VALUE self, uint32_t (*process)(const char *, uint32_t, uint32_t))
|
60
65
|
{
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
const char *seed = RSTRING_PTR(rb_ivar_get(self, iv_seed));
|
67
|
+
VALUE buffer = rb_ivar_get(self, iv_buffer);
|
68
|
+
return process(RSTRING_PTR(buffer), RSTRING_LEN(buffer), *(uint32_t*)seed);
|
64
69
|
}
|
65
70
|
|
66
71
|
uint64_t
|
67
72
|
_murmur_finish64(VALUE self, uint64_t (*process)(const char *, uint32_t, uint64_t))
|
68
73
|
{
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
const char *seed = RSTRING_PTR(rb_ivar_get(self, iv_seed));
|
75
|
+
VALUE buffer = rb_ivar_get(self, iv_buffer);
|
76
|
+
return process(RSTRING_PTR(buffer), RSTRING_LEN(buffer), *(uint64_t*)seed);
|
72
77
|
}
|
73
78
|
|
74
|
-
|
75
79
|
uint32_t
|
76
80
|
_murmur_s_digest32(int argc, VALUE *argv, VALUE klass, uint32_t (*process)(const char *, uint32_t, uint32_t))
|
77
81
|
{
|
78
|
-
|
79
|
-
|
82
|
+
VALUE str;
|
83
|
+
const char *seed;
|
80
84
|
|
81
|
-
|
82
|
-
|
85
|
+
if (argc < 1)
|
86
|
+
rb_raise(rb_eArgError, "no data given");
|
83
87
|
|
84
|
-
|
88
|
+
str = *argv;
|
85
89
|
|
86
|
-
|
90
|
+
StringValue(str);
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
if (1 < argc) {
|
93
|
+
StringValue(argv[1]);
|
94
|
+
if (RSTRING_LEN(argv[1]) != 4) {
|
95
|
+
rb_raise(rb_eArgError, "seed string should 32 bit chars");
|
96
|
+
}
|
97
|
+
seed = RSTRING_PTR(argv[1]);
|
98
|
+
} else {
|
99
|
+
seed = RSTRING_PTR(rb_const_get(klass, id_DEFAULT_SEED));
|
100
|
+
}
|
97
101
|
|
98
|
-
|
102
|
+
return process(RSTRING_PTR(str), RSTRING_LEN(str), *(uint32_t*)seed);
|
99
103
|
}
|
100
104
|
|
101
105
|
uint64_t
|
102
106
|
_murmur_s_digest64(int argc, VALUE *argv, VALUE klass, uint64_t (*process)(const char *, uint32_t, uint64_t))
|
103
107
|
{
|
104
|
-
|
105
|
-
|
108
|
+
VALUE str;
|
109
|
+
const char *seed;
|
106
110
|
|
107
|
-
|
108
|
-
|
111
|
+
if (argc < 1)
|
112
|
+
rb_raise(rb_eArgError, "no data given");
|
109
113
|
|
110
|
-
|
114
|
+
str = *argv;
|
111
115
|
|
112
|
-
|
116
|
+
StringValue(str);
|
113
117
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
118
|
+
if (1 < argc) {
|
119
|
+
StringValue(argv[1]);
|
120
|
+
if (RSTRING_LEN(argv[1]) != 8) {
|
121
|
+
rb_raise(rb_eArgError, "seed string should 64 bit chars");
|
122
|
+
}
|
123
|
+
seed = RSTRING_PTR(argv[1]);
|
124
|
+
} else {
|
125
|
+
seed = RSTRING_PTR(rb_const_get(klass, id_DEFAULT_SEED));
|
126
|
+
}
|
123
127
|
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
/*
|
128
|
-
* from https://github.com/ruby/ruby/blob/trunk/ext/digest/digest.c
|
129
|
-
* Copyright (C) 1995-2001 Yukihiro Matsumoto
|
130
|
-
* Copyright (C) 2001-2006 Akinori MUSHA
|
131
|
-
*/
|
132
|
-
VALUE
|
133
|
-
hexencode_str_new(VALUE str_digest)
|
134
|
-
{
|
135
|
-
char *digest;
|
136
|
-
size_t digest_len;
|
137
|
-
size_t i;
|
138
|
-
VALUE str;
|
139
|
-
char *p;
|
140
|
-
static const char hex[] = {
|
141
|
-
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
142
|
-
'a', 'b', 'c', 'd', 'e', 'f'
|
143
|
-
};
|
144
|
-
|
145
|
-
StringValue(str_digest);
|
146
|
-
digest = RSTRING_PTR(str_digest);
|
147
|
-
digest_len = RSTRING_LEN(str_digest);
|
148
|
-
|
149
|
-
if (LONG_MAX / 2 < digest_len) {
|
150
|
-
rb_raise(rb_eRuntimeError, "digest string too long");
|
151
|
-
}
|
152
|
-
|
153
|
-
str = rb_usascii_str_new(0, digest_len * 2);
|
154
|
-
|
155
|
-
for (i = 0, p = RSTRING_PTR(str); i < digest_len; i++) {
|
156
|
-
unsigned char byte = digest[i];
|
157
|
-
|
158
|
-
p[i + i] = hex[byte >> 4];
|
159
|
-
p[i + i + 1] = hex[byte & 0x0f];
|
160
|
-
}
|
161
|
-
|
162
|
-
return str;
|
128
|
+
return process(RSTRING_PTR(str), RSTRING_LEN(str), *(uint64_t*)seed);
|
163
129
|
}
|
164
130
|
|
165
131
|
void
|
166
132
|
Init_murmurhash(void)
|
167
133
|
{
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
rb_define_method(cDigest_MurmurHash2A, "to_i", murmur2a_to_i, 0);
|
207
|
-
rb_define_method(cDigest_MurmurHash2A, "seed", murmur_seed_get32, 0);
|
208
|
-
rb_define_method(cDigest_MurmurHash2A, "seed=", murmur_seed_set32, 1);
|
209
|
-
|
210
|
-
/* class Digest::MurmurHash64A < Digest::StringBuffer */
|
211
|
-
cDigest_MurmurHash64A = rb_define_class_under(mDigest, "MurmurHash64A", cDigest_StringBuffer);
|
212
|
-
rb_define_const(cDigest_MurmurHash64A, "DEFAULT_SEED", rb_usascii_str_new(DEFAULT_SEED, 8));
|
213
|
-
rb_define_singleton_method(cDigest_MurmurHash64A, "digest", murmur64a_s_digest, -1);
|
214
|
-
rb_define_singleton_method(cDigest_MurmurHash64A, "hexdigest", murmur64a_s_hexdigest, -1);
|
215
|
-
rb_define_singleton_method(cDigest_MurmurHash64A, "rawdigest", murmur64a_s_rawdigest, -1);
|
216
|
-
rb_define_private_method(cDigest_MurmurHash64A, "finish", murmur64a_finish, 0);
|
217
|
-
rb_define_method(cDigest_MurmurHash64A, "to_i", murmur64a_to_i, 0);
|
218
|
-
rb_define_method(cDigest_MurmurHash64A, "seed", murmur_seed_get64, 0);
|
219
|
-
rb_define_method(cDigest_MurmurHash64A, "seed=", murmur_seed_set64, 1);
|
220
|
-
|
221
|
-
/* class Digest::MurmurHash64B < Digest::StringBuffer */
|
222
|
-
cDigest_MurmurHash64B = rb_define_class_under(mDigest, "MurmurHash64B", cDigest_StringBuffer);
|
223
|
-
rb_define_const(cDigest_MurmurHash64B, "DEFAULT_SEED", rb_usascii_str_new(DEFAULT_SEED, 8));
|
224
|
-
rb_define_singleton_method(cDigest_MurmurHash64B, "digest", murmur64b_s_digest, -1);
|
225
|
-
rb_define_singleton_method(cDigest_MurmurHash64B, "hexdigest", murmur64b_s_hexdigest, -1);
|
226
|
-
rb_define_singleton_method(cDigest_MurmurHash64B, "rawdigest", murmur64b_s_rawdigest, -1);
|
227
|
-
rb_define_private_method(cDigest_MurmurHash64B, "finish", murmur64b_finish, 0);
|
228
|
-
rb_define_method(cDigest_MurmurHash64B, "to_i", murmur64b_to_i, 0);
|
229
|
-
rb_define_method(cDigest_MurmurHash64B, "seed", murmur_seed_get64, 0);
|
230
|
-
rb_define_method(cDigest_MurmurHash64B, "seed=", murmur_seed_set64, 1);
|
231
|
-
|
232
|
-
/* class Digest::MurmurHashNeutral2 < Digest::StringBuffer */
|
233
|
-
cDigest_MurmurHashNeutral2 = rb_define_class_under(mDigest, "MurmurHashNeutral2", cDigest_StringBuffer);
|
234
|
-
rb_define_const(cDigest_MurmurHashNeutral2, "DEFAULT_SEED", rb_usascii_str_new(DEFAULT_SEED, 4));
|
235
|
-
rb_define_singleton_method(cDigest_MurmurHashNeutral2, "digest", murmur_neutral2_s_digest, -1);
|
236
|
-
rb_define_singleton_method(cDigest_MurmurHashNeutral2, "hexdigest", murmur_neutral2_s_hexdigest, -1);
|
237
|
-
rb_define_singleton_method(cDigest_MurmurHashNeutral2, "rawdigest", murmur_neutral2_s_rawdigest, -1);
|
238
|
-
rb_define_private_method(cDigest_MurmurHashNeutral2, "finish", murmur_neutral2_finish, 0);
|
239
|
-
rb_define_method(cDigest_MurmurHashNeutral2, "to_i", murmur_neutral2_to_i, 0);
|
240
|
-
rb_define_method(cDigest_MurmurHashNeutral2, "seed", murmur_seed_get32, 0);
|
241
|
-
rb_define_method(cDigest_MurmurHashNeutral2, "seed=", murmur_seed_set32, 1);
|
242
|
-
|
243
|
-
/* class Digest::MurmurHashAligned2 < Digest::StringBuffer */
|
244
|
-
cDigest_MurmurHashAligned2 = rb_define_class_under(mDigest, "MurmurHashAligned2", cDigest_StringBuffer);
|
245
|
-
rb_define_const(cDigest_MurmurHashAligned2, "DEFAULT_SEED", rb_usascii_str_new(DEFAULT_SEED, 4));
|
246
|
-
rb_define_singleton_method(cDigest_MurmurHashAligned2, "digest", murmur_aligned2_s_digest, -1);
|
247
|
-
rb_define_singleton_method(cDigest_MurmurHashAligned2, "hexdigest", murmur_aligned2_s_hexdigest, -1);
|
248
|
-
rb_define_singleton_method(cDigest_MurmurHashAligned2, "rawdigest", murmur_aligned2_s_rawdigest, -1);
|
249
|
-
rb_define_private_method(cDigest_MurmurHashAligned2, "finish", murmur_aligned2_finish, 0);
|
250
|
-
rb_define_method(cDigest_MurmurHashAligned2, "to_i", murmur_aligned2_to_i, 0);
|
251
|
-
rb_define_method(cDigest_MurmurHashAligned2, "seed", murmur_seed_get32, 0);
|
252
|
-
rb_define_method(cDigest_MurmurHashAligned2, "seed=", murmur_seed_set32, 1);
|
134
|
+
id_DEFAULT_SEED = rb_intern("DEFAULT_SEED");
|
135
|
+
iv_seed = rb_intern("@seed");
|
136
|
+
iv_buffer = rb_intern("@buffer");
|
137
|
+
|
138
|
+
cDigest_MurmurHash1 = rb_path2class("Digest::MurmurHash1");
|
139
|
+
rb_define_singleton_method(cDigest_MurmurHash1, "digest", murmur1_s_digest, -1);
|
140
|
+
rb_define_singleton_method(cDigest_MurmurHash1, "rawdigest", murmur1_s_rawdigest, -1);
|
141
|
+
rb_define_private_method(cDigest_MurmurHash1, "finish", murmur1_finish, 0);
|
142
|
+
|
143
|
+
cDigest_MurmurHash2 = rb_path2class("Digest::MurmurHash2");
|
144
|
+
rb_define_singleton_method(cDigest_MurmurHash2, "digest", murmur2_s_digest, -1);
|
145
|
+
rb_define_singleton_method(cDigest_MurmurHash2, "rawdigest", murmur2_s_rawdigest, -1);
|
146
|
+
rb_define_private_method(cDigest_MurmurHash2, "finish", murmur2_finish, 0);
|
147
|
+
|
148
|
+
cDigest_MurmurHash2A = rb_path2class("Digest::MurmurHash2A");
|
149
|
+
rb_define_singleton_method(cDigest_MurmurHash2A, "digest", murmur2a_s_digest, -1);
|
150
|
+
rb_define_singleton_method(cDigest_MurmurHash2A, "rawdigest", murmur2a_s_rawdigest, -1);
|
151
|
+
rb_define_private_method(cDigest_MurmurHash2A, "finish", murmur2a_finish, 0);
|
152
|
+
|
153
|
+
cDigest_MurmurHash64A = rb_path2class("Digest::MurmurHash64A");
|
154
|
+
rb_define_singleton_method(cDigest_MurmurHash64A, "digest", murmur64a_s_digest, -1);
|
155
|
+
rb_define_singleton_method(cDigest_MurmurHash64A, "rawdigest", murmur64a_s_rawdigest, -1);
|
156
|
+
rb_define_private_method(cDigest_MurmurHash64A, "finish", murmur64a_finish, 0);
|
157
|
+
|
158
|
+
cDigest_MurmurHash64B = rb_path2class("Digest::MurmurHash64B");
|
159
|
+
rb_define_singleton_method(cDigest_MurmurHash64B, "digest", murmur64b_s_digest, -1);
|
160
|
+
rb_define_singleton_method(cDigest_MurmurHash64B, "rawdigest", murmur64b_s_rawdigest, -1);
|
161
|
+
rb_define_private_method(cDigest_MurmurHash64B, "finish", murmur64b_finish, 0);
|
162
|
+
|
163
|
+
cDigest_MurmurHashNeutral2 = rb_path2class("Digest::MurmurHashNeutral2");
|
164
|
+
rb_define_singleton_method(cDigest_MurmurHashNeutral2, "digest", murmur_neutral2_s_digest, -1);
|
165
|
+
rb_define_singleton_method(cDigest_MurmurHashNeutral2, "rawdigest", murmur_neutral2_s_rawdigest, -1);
|
166
|
+
rb_define_private_method(cDigest_MurmurHashNeutral2, "finish", murmur_neutral2_finish, 0);
|
167
|
+
|
168
|
+
cDigest_MurmurHashAligned2 = rb_path2class("Digest::MurmurHashAligned2");
|
169
|
+
rb_define_singleton_method(cDigest_MurmurHashAligned2, "digest", murmur_aligned2_s_digest, -1);
|
170
|
+
rb_define_singleton_method(cDigest_MurmurHashAligned2, "rawdigest", murmur_aligned2_s_rawdigest, -1);
|
171
|
+
rb_define_private_method(cDigest_MurmurHashAligned2, "finish", murmur_aligned2_finish, 0);
|
253
172
|
}
|
@@ -10,69 +10,37 @@
|
|
10
10
|
# define BIG_CONSTANT(x) (x##LLU)
|
11
11
|
#endif // !defined(_MSC_VER)
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
(digest)[0] = (h); \
|
32
|
-
} while (0)
|
13
|
+
#ifdef DYNAMIC_ENDIAN
|
14
|
+
/* for universal binary of NEXTSTEP and MacOS X */
|
15
|
+
/* useless since autoconf 2.63? */
|
16
|
+
static int
|
17
|
+
is_bigendian(void)
|
18
|
+
{
|
19
|
+
static int init = 0;
|
20
|
+
static int endian_value;
|
21
|
+
char *p;
|
22
|
+
|
23
|
+
if (init) return endian_value;
|
24
|
+
init = 1;
|
25
|
+
p = (char*)&init;
|
26
|
+
return endian_value = p[0] ? 0 : 1;
|
27
|
+
}
|
28
|
+
# define BIGENDIAN_P() (is_bigendian())
|
29
|
+
#elif defined(WORDS_BIGENDIAN)
|
30
|
+
# define BIGENDIAN_P() 1
|
33
31
|
#else
|
34
|
-
# define
|
35
|
-
(digest)[0] = (h) >> 24; \
|
36
|
-
(digest)[1] = (h) >> 16; \
|
37
|
-
(digest)[2] = (h) >> 8; \
|
38
|
-
(digest)[3] = (h); \
|
39
|
-
} while (0)
|
40
|
-
# define ASSINE_BY_ENDIAN_64(digest, h) do { \
|
41
|
-
(digest)[0] = (h) >> 56; \
|
42
|
-
(digest)[1] = (h) >> 48; \
|
43
|
-
(digest)[2] = (h) >> 40; \
|
44
|
-
(digest)[3] = (h) >> 32; \
|
45
|
-
(digest)[4] = (h) >> 24; \
|
46
|
-
(digest)[5] = (h) >> 16; \
|
47
|
-
(digest)[6] = (h) >> 8; \
|
48
|
-
(digest)[7] = (h); \
|
49
|
-
} while (0)
|
32
|
+
# define BIGENDIAN_P() 0
|
50
33
|
#endif
|
51
34
|
|
52
|
-
|
53
|
-
|
54
|
-
char* buffer;
|
55
|
-
char* p;
|
56
|
-
size_t memsize;
|
57
|
-
} buffer_t;
|
58
|
-
|
59
|
-
#define MURMURHASH(self, name) \
|
60
|
-
buffer_t* name; \
|
61
|
-
Data_Get_Struct(self, buffer_t, name); \
|
62
|
-
if (name == NULL) { \
|
63
|
-
rb_raise(rb_eArgError, "NULL found for " # name " when shouldn't be.'"); \
|
64
|
-
}
|
65
|
-
|
66
|
-
VALUE murmur_seed_get32(VALUE self);
|
67
|
-
VALUE murmur_seed_get64(VALUE self);
|
35
|
+
#define MURMURHASH_MAGIC 0x5bd1e995
|
36
|
+
#define MURMURHASH_MAGIC64A BIG_CONSTANT(0xc6a4a7935bd1e995)
|
68
37
|
|
69
|
-
|
38
|
+
void assign_by_endian_32(uint8_t *digest, uint64_t h);
|
39
|
+
void assign_by_endian_64(uint8_t *digest, uint64_t h);
|
70
40
|
|
71
41
|
uint32_t _murmur_finish32(VALUE self, uint32_t (*process)(const char *, uint32_t, uint32_t));
|
72
42
|
uint64_t _murmur_finish64(VALUE self, uint64_t (*process)(const char *, uint32_t, uint64_t));
|
73
43
|
uint32_t _murmur_s_digest32(int argc, VALUE *argv, VALUE klass, uint32_t (*process)(const char *, uint32_t, uint32_t));
|
74
44
|
uint64_t _murmur_s_digest64(int argc, VALUE *argv, VALUE klass, uint64_t (*process)(const char *, uint32_t, uint64_t));
|
75
|
-
VALUE hexencode_str_new(VALUE str_digest);
|
76
45
|
|
77
46
|
#endif /* ifndef MURMURHASH_INCLUDED */
|
78
|
-
|