splitclient-rb 7.1.4.pre.rc7 → 7.1.4.pre.rc8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.txt +1 -1
- data/Rakefile +7 -2
- data/ext/murmurhash/3_x64_128.c +117 -0
- data/ext/murmurhash/3_x86_32.c +88 -0
- data/ext/murmurhash/extconf.rb +5 -0
- data/ext/murmurhash/murmurhash.c +255 -0
- data/ext/murmurhash/murmurhash.h +94 -0
- data/lib/splitclient-rb.rb +6 -1
- data/lib/splitclient-rb/cache/hashers/impression_hasher.rb +34 -0
- data/lib/splitclient-rb/cache/observers/impression_observer.rb +22 -0
- data/lib/splitclient-rb/cache/repositories/impressions/memory_repository.rb +4 -18
- data/lib/splitclient-rb/cache/repositories/impressions/redis_repository.rb +7 -18
- data/lib/splitclient-rb/cache/repositories/impressions_repository.rb +1 -27
- data/lib/splitclient-rb/cache/routers/impression_router.rb +12 -14
- data/lib/splitclient-rb/cache/senders/impressions_count_sender.rb +73 -0
- data/lib/splitclient-rb/cache/senders/impressions_formatter.rb +11 -11
- data/lib/splitclient-rb/cache/senders/impressions_sender.rb +3 -3
- data/lib/splitclient-rb/clients/split_client.rb +24 -73
- data/lib/splitclient-rb/engine/api/impressions.rb +30 -13
- data/lib/splitclient-rb/engine/common/impressions_counter.rb +45 -0
- data/lib/splitclient-rb/engine/common/impressions_manager.rb +87 -0
- data/lib/splitclient-rb/engine/evaluator/splitter.rb +1 -5
- data/lib/splitclient-rb/engine/parser/evaluator.rb +0 -4
- data/lib/splitclient-rb/engine/sync_manager.rb +5 -6
- data/lib/splitclient-rb/engine/synchronizer.rb +9 -1
- data/lib/splitclient-rb/split_config.rb +31 -1
- data/lib/splitclient-rb/split_factory.rb +5 -2
- data/lib/splitclient-rb/version.rb +1 -1
- data/splitclient-rb.gemspec +8 -1
- metadata +14 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f9703a389acb58ca8982fc62bfc39853a4cb9db03ff25ce479db5353d1cd1e
|
4
|
+
data.tar.gz: 109946a00efbde7b119f92e7c0d6807f9816a97ed41388c3421a5cc3b94c707d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bad0bdc17f8dfd9160c2e295bac71799ccf8adadcf15261be27b2a07e30882bce4939cf7864d14edcf8937462b2d39dd03a0cb6c0e12169108ed25dcaa9711b
|
7
|
+
data.tar.gz: 831c75840e0a61ab8b32db9d403fe66aaa730ccb672f5021761f881cbac0da7ccfc6b62894ff2ca70da97ff6ddf7fa9b628693eca566cc50e8ef3e19b458d03e
|
data/CHANGES.txt
CHANGED
data/Rakefile
CHANGED
@@ -11,14 +11,19 @@ RSpec::Core::RakeTask.new(:spec)
|
|
11
11
|
RuboCop::RakeTask.new(:rubocop)
|
12
12
|
|
13
13
|
task spec: :compile
|
14
|
-
|
15
|
-
|
14
|
+
case RUBY_PLATFORM
|
15
|
+
when 'java'
|
16
16
|
require 'rake/javaextensiontask'
|
17
17
|
Rake::JavaExtensionTask.new 'murmurhash' do |ext|
|
18
18
|
ext.lib_dir = 'lib/murmurhash'
|
19
19
|
ext.target_version = '1.7'
|
20
20
|
ext.source_version = '1.7'
|
21
21
|
end
|
22
|
+
else
|
23
|
+
require 'rake/extensiontask'
|
24
|
+
Rake::ExtensionTask.new 'murmurhash' do |ext|
|
25
|
+
ext.lib_dir = 'lib/murmurhash'
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
if !ENV['APPRAISAL_INITIALIZED']
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/*
|
2
|
+
* MurmurHash3_x64_128 (C) Austin Appleby
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include "murmurhash.h"
|
6
|
+
|
7
|
+
void
|
8
|
+
murmur_hash_process3_x64_128(const char * key, uint32_t len, uint32_t seed, void *out)
|
9
|
+
{
|
10
|
+
const uint8_t * data = (const uint8_t*)key;
|
11
|
+
const int nblocks = len / 16;
|
12
|
+
|
13
|
+
uint64_t h1 = seed;
|
14
|
+
uint64_t h2 = seed;
|
15
|
+
|
16
|
+
const uint64_t c1 = (uint64_t)BIG_CONSTANT(0x87c37b91114253d5);
|
17
|
+
const uint64_t c2 = (uint64_t)BIG_CONSTANT(0x4cf5ad432745937f);
|
18
|
+
|
19
|
+
//----------
|
20
|
+
// body
|
21
|
+
|
22
|
+
const uint64_t * blocks = (const uint64_t *)(data);
|
23
|
+
|
24
|
+
int i;
|
25
|
+
|
26
|
+
for(i = 0; i < nblocks; i++)
|
27
|
+
{
|
28
|
+
uint64_t k1 = getblock64(blocks,i*2+0);
|
29
|
+
uint64_t k2 = getblock64(blocks,i*2+1);
|
30
|
+
|
31
|
+
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
|
32
|
+
|
33
|
+
h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
|
34
|
+
|
35
|
+
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
|
36
|
+
|
37
|
+
h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
|
38
|
+
}
|
39
|
+
|
40
|
+
//----------
|
41
|
+
// tail
|
42
|
+
|
43
|
+
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
|
44
|
+
|
45
|
+
uint64_t k1 = 0;
|
46
|
+
uint64_t k2 = 0;
|
47
|
+
|
48
|
+
switch(len & 15)
|
49
|
+
{
|
50
|
+
case 15: k2 ^= ((uint64_t)tail[14]) << 48;
|
51
|
+
case 14: k2 ^= ((uint64_t)tail[13]) << 40;
|
52
|
+
case 13: k2 ^= ((uint64_t)tail[12]) << 32;
|
53
|
+
case 12: k2 ^= ((uint64_t)tail[11]) << 24;
|
54
|
+
case 11: k2 ^= ((uint64_t)tail[10]) << 16;
|
55
|
+
case 10: k2 ^= ((uint64_t)tail[ 9]) << 8;
|
56
|
+
case 9: k2 ^= ((uint64_t)tail[ 8]) << 0;
|
57
|
+
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
|
58
|
+
|
59
|
+
case 8: k1 ^= ((uint64_t)tail[ 7]) << 56;
|
60
|
+
case 7: k1 ^= ((uint64_t)tail[ 6]) << 48;
|
61
|
+
case 6: k1 ^= ((uint64_t)tail[ 5]) << 40;
|
62
|
+
case 5: k1 ^= ((uint64_t)tail[ 4]) << 32;
|
63
|
+
case 4: k1 ^= ((uint64_t)tail[ 3]) << 24;
|
64
|
+
case 3: k1 ^= ((uint64_t)tail[ 2]) << 16;
|
65
|
+
case 2: k1 ^= ((uint64_t)tail[ 1]) << 8;
|
66
|
+
case 1: k1 ^= ((uint64_t)tail[ 0]) << 0;
|
67
|
+
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
|
68
|
+
};
|
69
|
+
|
70
|
+
//----------
|
71
|
+
// finalization
|
72
|
+
|
73
|
+
h1 ^= len; h2 ^= len;
|
74
|
+
|
75
|
+
h1 += h2;
|
76
|
+
h2 += h1;
|
77
|
+
|
78
|
+
h1 = fmix64(h1);
|
79
|
+
h2 = fmix64(h2);
|
80
|
+
|
81
|
+
h1 += h2;
|
82
|
+
h2 += h1;
|
83
|
+
|
84
|
+
((uint64_t*)out)[0] = h1;
|
85
|
+
((uint64_t*)out)[1] = h2;
|
86
|
+
}
|
87
|
+
|
88
|
+
VALUE
|
89
|
+
murmur3_x64_128_finish(VALUE self)
|
90
|
+
{
|
91
|
+
uint8_t digest[16];
|
92
|
+
uint64_t out[2];
|
93
|
+
|
94
|
+
_murmur_finish128(self, out, murmur_hash_process3_x64_128);
|
95
|
+
assign_by_endian_128(digest, out);
|
96
|
+
return rb_str_new((const char*) digest, 16);
|
97
|
+
}
|
98
|
+
|
99
|
+
VALUE
|
100
|
+
murmur3_x64_128_s_digest(int argc, VALUE *argv, VALUE klass)
|
101
|
+
{
|
102
|
+
uint8_t digest[16];
|
103
|
+
uint64_t out[2];
|
104
|
+
|
105
|
+
_murmur_s_digest128(argc, argv, klass, (void*)out, murmur_hash_process3_x64_128);
|
106
|
+
assign_by_endian_128(digest, out);
|
107
|
+
return rb_str_new((const char*) digest, 16);
|
108
|
+
}
|
109
|
+
|
110
|
+
VALUE
|
111
|
+
murmur3_x64_128_s_rawdigest(int argc, VALUE *argv, VALUE klass)
|
112
|
+
{
|
113
|
+
uint64_t out[2];
|
114
|
+
|
115
|
+
_murmur_s_digest128(argc, argv, klass, (void*)out, murmur_hash_process3_x64_128);
|
116
|
+
return rb_assoc_new(ULL2NUM(out[0]), ULL2NUM(out[1]));
|
117
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
/*
|
2
|
+
* MurmurHash3_x86_32 (C) Austin Appleby
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include "murmurhash.h"
|
6
|
+
|
7
|
+
uint32_t
|
8
|
+
murmur_hash_process3_x86_32(const char * key, uint32_t len, uint32_t seed)
|
9
|
+
{
|
10
|
+
const uint8_t * data = (const uint8_t*)key;
|
11
|
+
const int nblocks = len / 4;
|
12
|
+
int i;
|
13
|
+
|
14
|
+
uint32_t h1 = seed;
|
15
|
+
|
16
|
+
const uint32_t c1 = 0xcc9e2d51;
|
17
|
+
const uint32_t c2 = 0x1b873593;
|
18
|
+
|
19
|
+
//----------
|
20
|
+
// body
|
21
|
+
|
22
|
+
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
|
23
|
+
|
24
|
+
for(i = -nblocks; i; i++)
|
25
|
+
{
|
26
|
+
uint32_t k1 = getblock32(blocks,i);
|
27
|
+
|
28
|
+
k1 *= c1;
|
29
|
+
k1 = ROTL32(k1,15);
|
30
|
+
k1 *= c2;
|
31
|
+
|
32
|
+
h1 ^= k1;
|
33
|
+
h1 = ROTL32(h1,13);
|
34
|
+
h1 = h1*5+0xe6546b64;
|
35
|
+
}
|
36
|
+
|
37
|
+
//----------
|
38
|
+
// tail
|
39
|
+
|
40
|
+
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
|
41
|
+
|
42
|
+
uint32_t k1 = 0;
|
43
|
+
|
44
|
+
switch(len & 3)
|
45
|
+
{
|
46
|
+
case 3: k1 ^= tail[2] << 16;
|
47
|
+
case 2: k1 ^= tail[1] << 8;
|
48
|
+
case 1: k1 ^= tail[0];
|
49
|
+
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
|
50
|
+
};
|
51
|
+
|
52
|
+
//----------
|
53
|
+
// finalization
|
54
|
+
|
55
|
+
h1 ^= len;
|
56
|
+
|
57
|
+
h1 = fmix32(h1);
|
58
|
+
|
59
|
+
return h1;
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE
|
63
|
+
murmur3_x86_32_finish(VALUE self)
|
64
|
+
{
|
65
|
+
uint8_t digest[4];
|
66
|
+
uint32_t h;
|
67
|
+
|
68
|
+
h = _murmur_finish32(self, murmur_hash_process3_x86_32);
|
69
|
+
assign_by_endian_32(digest, h);
|
70
|
+
return rb_str_new((const char*) digest, 4);
|
71
|
+
}
|
72
|
+
|
73
|
+
VALUE
|
74
|
+
murmur3_x86_32_s_digest(int argc, VALUE *argv, VALUE klass)
|
75
|
+
{
|
76
|
+
uint8_t digest[4];
|
77
|
+
uint32_t h;
|
78
|
+
|
79
|
+
h = _murmur_s_digest32(argc, argv, klass, murmur_hash_process3_x86_32);
|
80
|
+
assign_by_endian_32(digest, h);
|
81
|
+
return rb_str_new((const char*) digest, 4);
|
82
|
+
}
|
83
|
+
|
84
|
+
VALUE
|
85
|
+
murmur3_x86_32_s_rawdigest(int argc, VALUE *argv, VALUE klass)
|
86
|
+
{
|
87
|
+
return ULL2NUM(_murmur_s_digest32(argc, argv, klass, murmur_hash_process3_x86_32));
|
88
|
+
}
|
@@ -0,0 +1,255 @@
|
|
1
|
+
#include "murmurhash.h"
|
2
|
+
|
3
|
+
ID id_DEFAULT_SEED;
|
4
|
+
ID iv_seed;
|
5
|
+
ID iv_buffer;
|
6
|
+
|
7
|
+
|
8
|
+
inline uint32_t rotl32 ( uint32_t x, int8_t r )
|
9
|
+
{
|
10
|
+
return (x << r) | (x >> (32 - r));
|
11
|
+
}
|
12
|
+
inline uint64_t rotl64 ( uint64_t x, int8_t r )
|
13
|
+
{
|
14
|
+
return (x << r) | (x >> (64 - r));
|
15
|
+
}
|
16
|
+
|
17
|
+
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
|
18
|
+
{
|
19
|
+
return p[i];
|
20
|
+
}
|
21
|
+
|
22
|
+
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
|
23
|
+
{
|
24
|
+
return p[i];
|
25
|
+
}
|
26
|
+
|
27
|
+
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
|
28
|
+
{
|
29
|
+
h ^= h >> 16;
|
30
|
+
h *= 0x85ebca6b;
|
31
|
+
h ^= h >> 13;
|
32
|
+
h *= 0xc2b2ae35;
|
33
|
+
h ^= h >> 16;
|
34
|
+
|
35
|
+
return h;
|
36
|
+
}
|
37
|
+
|
38
|
+
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
|
39
|
+
{
|
40
|
+
k ^= k >> 33;
|
41
|
+
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
|
42
|
+
k ^= k >> 33;
|
43
|
+
k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
|
44
|
+
k ^= k >> 33;
|
45
|
+
|
46
|
+
return k;
|
47
|
+
}
|
48
|
+
|
49
|
+
void
|
50
|
+
assign_by_endian_32(uint8_t *digest, uint32_t h)
|
51
|
+
{
|
52
|
+
if (BIGENDIAN_P()) {
|
53
|
+
digest[0] = h >> 24;
|
54
|
+
digest[1] = h >> 16;
|
55
|
+
digest[2] = h >> 8;
|
56
|
+
digest[3] = h;
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
digest[3] = h >> 24;
|
60
|
+
digest[2] = h >> 16;
|
61
|
+
digest[1] = h >> 8;
|
62
|
+
digest[0] = h;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
void
|
67
|
+
assign_by_endian_64(uint8_t *digest, uint64_t h)
|
68
|
+
{
|
69
|
+
if (BIGENDIAN_P()) {
|
70
|
+
digest[0] = h >> 56;
|
71
|
+
digest[1] = h >> 48;
|
72
|
+
digest[2] = h >> 40;
|
73
|
+
digest[3] = h >> 32;
|
74
|
+
digest[4] = h >> 24;
|
75
|
+
digest[5] = h >> 16;
|
76
|
+
digest[6] = h >> 8;
|
77
|
+
digest[7] = h;
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
digest[7] = h >> 56;
|
81
|
+
digest[6] = h >> 48;
|
82
|
+
digest[5] = h >> 40;
|
83
|
+
digest[4] = h >> 32;
|
84
|
+
digest[3] = h >> 24;
|
85
|
+
digest[2] = h >> 16;
|
86
|
+
digest[1] = h >> 8;
|
87
|
+
digest[0] = h;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
void
|
92
|
+
assign_by_endian_128(uint8_t *digest, void *out)
|
93
|
+
{
|
94
|
+
int i;
|
95
|
+
|
96
|
+
if (BIGENDIAN_P()) {
|
97
|
+
for (i = 0; i < 4; i++) {
|
98
|
+
digest[(i*4) ] = ((uint32_t*)out)[i] >> 24;
|
99
|
+
digest[(i*4)+1] = ((uint32_t*)out)[i] >> 16;
|
100
|
+
digest[(i*4)+2] = ((uint32_t*)out)[i] >> 8;
|
101
|
+
digest[(i*4)+3] = ((uint32_t*)out)[i];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
for (i = 0; i < 4; i++) {
|
106
|
+
digest[16-(i*4)-1] = ((uint32_t*)out)[i] >> 24;
|
107
|
+
digest[16-(i*4)-2] = ((uint32_t*)out)[i] >> 16;
|
108
|
+
digest[16-(i*4)-3] = ((uint32_t*)out)[i] >> 8;
|
109
|
+
digest[16-(i*4)-4] = ((uint32_t*)out)[i];
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
static uint32_t
|
115
|
+
rstring2uint32_t(VALUE str)
|
116
|
+
{
|
117
|
+
long len = RSTRING_LEN(str);
|
118
|
+
if (UINT32_MAX < len) {
|
119
|
+
rb_raise(rb_eRangeError, "String length=%ld will overflow from long to uint32_t", len);
|
120
|
+
}
|
121
|
+
return (uint32_t)len;
|
122
|
+
}
|
123
|
+
|
124
|
+
uint32_t
|
125
|
+
_murmur_finish32(VALUE self, uint32_t (*process)(const char*, uint32_t, uint32_t))
|
126
|
+
{
|
127
|
+
const char *seed = RSTRING_PTR(rb_ivar_get(self, iv_seed));
|
128
|
+
VALUE buffer = rb_ivar_get(self, iv_buffer);
|
129
|
+
return process(RSTRING_PTR(buffer), rstring2uint32_t(buffer), *(uint32_t*)seed);
|
130
|
+
}
|
131
|
+
|
132
|
+
uint64_t
|
133
|
+
_murmur_finish64(VALUE self, uint64_t (*process)(const char*, uint32_t, uint64_t))
|
134
|
+
{
|
135
|
+
const char *seed = RSTRING_PTR(rb_ivar_get(self, iv_seed));
|
136
|
+
VALUE buffer = rb_ivar_get(self, iv_buffer);
|
137
|
+
return process(RSTRING_PTR(buffer), rstring2uint32_t(buffer), *(uint64_t*)seed);
|
138
|
+
}
|
139
|
+
|
140
|
+
void
|
141
|
+
_murmur_finish128(VALUE self, void *out, void (*process)(const char*, uint32_t, uint32_t, void*))
|
142
|
+
{
|
143
|
+
const char *seed = RSTRING_PTR(rb_ivar_get(self, iv_seed));
|
144
|
+
VALUE buffer = rb_ivar_get(self, iv_buffer);
|
145
|
+
process(RSTRING_PTR(buffer), rstring2uint32_t(buffer), *(uint32_t*)seed, out);
|
146
|
+
}
|
147
|
+
|
148
|
+
uint32_t
|
149
|
+
_murmur_s_digest32(int argc, VALUE *argv, VALUE klass, uint32_t (*process)(const char *, uint32_t, uint32_t))
|
150
|
+
{
|
151
|
+
VALUE str;
|
152
|
+
const char *seed;
|
153
|
+
|
154
|
+
if (argc < 1)
|
155
|
+
rb_raise(rb_eArgError, "no data given");
|
156
|
+
|
157
|
+
str = *argv;
|
158
|
+
|
159
|
+
StringValue(str);
|
160
|
+
|
161
|
+
if (1 < argc) {
|
162
|
+
StringValue(argv[1]);
|
163
|
+
if (RSTRING_LEN(argv[1]) != 4) {
|
164
|
+
rb_raise(rb_eArgError, "seed string should be 4 length");
|
165
|
+
}
|
166
|
+
seed = RSTRING_PTR(argv[1]);
|
167
|
+
} else {
|
168
|
+
seed = RSTRING_PTR(rb_const_get(klass, id_DEFAULT_SEED));
|
169
|
+
}
|
170
|
+
|
171
|
+
return process(RSTRING_PTR(str), rstring2uint32_t(str), *(uint32_t*)seed);
|
172
|
+
}
|
173
|
+
|
174
|
+
uint64_t
|
175
|
+
_murmur_s_digest64(int argc, VALUE *argv, VALUE klass, uint64_t (*process)(const char *, uint32_t, uint64_t))
|
176
|
+
{
|
177
|
+
VALUE str;
|
178
|
+
const char *seed;
|
179
|
+
|
180
|
+
if (argc < 1)
|
181
|
+
rb_raise(rb_eArgError, "no data given");
|
182
|
+
|
183
|
+
str = *argv;
|
184
|
+
|
185
|
+
StringValue(str);
|
186
|
+
|
187
|
+
if (1 < argc) {
|
188
|
+
StringValue(argv[1]);
|
189
|
+
if (RSTRING_LEN(argv[1]) != 8) {
|
190
|
+
rb_raise(rb_eArgError, "seed string should be 8 length");
|
191
|
+
}
|
192
|
+
seed = RSTRING_PTR(argv[1]);
|
193
|
+
} else {
|
194
|
+
seed = RSTRING_PTR(rb_const_get(klass, id_DEFAULT_SEED));
|
195
|
+
}
|
196
|
+
|
197
|
+
return process(RSTRING_PTR(str), rstring2uint32_t(str), *(uint64_t*)seed);
|
198
|
+
}
|
199
|
+
|
200
|
+
void
|
201
|
+
_murmur_s_digest128(int argc, VALUE *argv, VALUE klass, void *out, void (*process)(const char *, uint32_t, uint32_t, void *))
|
202
|
+
{
|
203
|
+
VALUE str;
|
204
|
+
const char *seed;
|
205
|
+
int seed_length = 4;
|
206
|
+
|
207
|
+
if (argc < 1)
|
208
|
+
rb_raise(rb_eArgError, "no data given");
|
209
|
+
|
210
|
+
str = *argv;
|
211
|
+
|
212
|
+
StringValue(str);
|
213
|
+
|
214
|
+
if (1 < argc) {
|
215
|
+
StringValue(argv[1]);
|
216
|
+
if (RSTRING_LEN(argv[1]) != seed_length) {
|
217
|
+
rb_raise(rb_eArgError, "seed string should be %d length", seed_length);
|
218
|
+
}
|
219
|
+
seed = RSTRING_PTR(argv[1]);
|
220
|
+
} else {
|
221
|
+
seed = RSTRING_PTR(rb_const_get(klass, id_DEFAULT_SEED));
|
222
|
+
}
|
223
|
+
|
224
|
+
process(RSTRING_PTR(str), rstring2uint32_t(str), *(uint32_t*)seed, out);
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
void
|
229
|
+
Init_murmurhash(void)
|
230
|
+
{
|
231
|
+
VALUE cDigest_MurmurHash1,
|
232
|
+
cDigest_MurmurHash2,
|
233
|
+
cDigest_MurmurHash2A,
|
234
|
+
cDigest_MurmurHash64A,
|
235
|
+
cDigest_MurmurHash64B,
|
236
|
+
cDigest_MurmurHashNeutral2,
|
237
|
+
cDigest_MurmurHashAligned2,
|
238
|
+
cDigest_MurmurHash3_x86_32,
|
239
|
+
cDigest_MurmurHash3_x86_128,
|
240
|
+
cDigest_MurmurHash3_x64_128;
|
241
|
+
|
242
|
+
id_DEFAULT_SEED = rb_intern("DEFAULT_SEED");
|
243
|
+
iv_seed = rb_intern("@seed");
|
244
|
+
iv_buffer = rb_intern("@buffer");
|
245
|
+
|
246
|
+
cDigest_MurmurHash3_x86_32 = rb_path2class("Digest::MurmurHashMRI3_x86_32");
|
247
|
+
rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "digest", murmur3_x86_32_s_digest, -1);
|
248
|
+
rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "rawdigest", murmur3_x86_32_s_rawdigest, -1);
|
249
|
+
rb_define_private_method(cDigest_MurmurHash3_x86_32, "finish", murmur3_x86_32_finish, 0);
|
250
|
+
|
251
|
+
cDigest_MurmurHash3_x64_128 = rb_path2class("Digest::MurmurHashMRI3_x64_128");
|
252
|
+
rb_define_singleton_method(cDigest_MurmurHash3_x64_128, "digest", murmur3_x64_128_s_digest, -1);
|
253
|
+
rb_define_singleton_method(cDigest_MurmurHash3_x64_128, "rawdigest", murmur3_x64_128_s_rawdigest, -1);
|
254
|
+
rb_define_private_method(cDigest_MurmurHash3_x64_128, "finish", murmur3_x64_128_finish, 0);
|
255
|
+
}
|