splitclient-rb 7.1.2.pre.rc2 → 7.1.4.pre.rc2
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/CHANGES.txt +7 -2
- data/Rakefile +2 -7
- data/lib/splitclient-rb.rb +1 -1
- data/lib/splitclient-rb/cache/adapters/redis_adapter.rb +2 -2
- data/lib/splitclient-rb/engine/evaluator/splitter.rb +5 -1
- data/lib/splitclient-rb/engine/parser/evaluator.rb +4 -0
- data/lib/splitclient-rb/version.rb +1 -1
- data/splitclient-rb.gemspec +3 -9
- metadata +22 -13
- data/ext/murmurhash/3_x86_32.c +0 -88
- data/ext/murmurhash/extconf.rb +0 -5
- data/ext/murmurhash/murmurhash.c +0 -251
- data/ext/murmurhash/murmurhash.h +0 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b28d11b34c32c3615332939de9bafc40058a00e403c48571ffa4ff48b93f13bb
|
4
|
+
data.tar.gz: e12017e9c031334e117f398e322fadaa819c0381b94ef87c5de5ddf7a7ac403e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edce3a288da26cd386d66cf8f31cf77fd3cff33622e12056836cf06165060d722caae97693ed2eba033369d509b3d52037eff03f7c8ef4e538bab375fec747db
|
7
|
+
data.tar.gz: 905e81111d98cc76991adc6b05514643fde63da0ee0453bb753c9829cbe9f796406e6661b6479c3033b4b6c3b8266ab9112d9ffc32ae08431c22414bc223ed8a
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
CHANGES
|
2
|
+
|
3
|
+
7.1.3 (Jul 31, 2020)
|
4
|
+
- Updated rake development dependency to ~> 12.3.3
|
5
|
+
|
6
|
+
7.1.2 (Jun 15, 2020)
|
7
|
+
- Fixed uninitialized constant LocalhostSplitStore::YAML for console apps.
|
3
8
|
- Updated default_streaming_enabled to true.
|
4
9
|
|
5
10
|
7.1.1 (May 19, 2020)
|
data/Rakefile
CHANGED
@@ -11,19 +11,14 @@ RSpec::Core::RakeTask.new(:spec)
|
|
11
11
|
RuboCop::RakeTask.new(:rubocop)
|
12
12
|
|
13
13
|
task spec: :compile
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
if RUBY_PLATFORM == '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
|
27
22
|
end
|
28
23
|
|
29
24
|
if !ENV['APPRAISAL_INITIALIZED']
|
data/lib/splitclient-rb.rb
CHANGED
@@ -14,7 +14,7 @@ module SplitIoClient
|
|
14
14
|
def initialize(redis_url)
|
15
15
|
connection = redis_url.is_a?(Hash) ? redis_url : { url: redis_url }
|
16
16
|
|
17
|
-
@redis = Redis.new(connection)
|
17
|
+
@redis = Redis.new(connection)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Map
|
@@ -142,7 +142,7 @@ module SplitIoClient
|
|
142
142
|
|
143
143
|
# General
|
144
144
|
def exists?(key)
|
145
|
-
@redis.exists(key)
|
145
|
+
@redis.exists?(key)
|
146
146
|
end
|
147
147
|
|
148
148
|
def delete(key)
|
@@ -1,3 +1,7 @@
|
|
1
|
+
unless defined?(JRUBY_VERSION)
|
2
|
+
require 'digest/murmurhash'
|
3
|
+
end
|
4
|
+
|
1
5
|
module SplitIoClient
|
2
6
|
# Misc class in charge of providing hash functions and
|
3
7
|
# determination of treatment based on concept of buckets
|
@@ -9,7 +13,7 @@ module SplitIoClient
|
|
9
13
|
when 'java'
|
10
14
|
Proc.new { |key, seed| Java::MurmurHash3.murmurhash3_x86_32(key, seed) }
|
11
15
|
else
|
12
|
-
Proc.new { |key, seed| Digest::
|
16
|
+
Proc.new { |key, seed| Digest::MurmurHash3_x86_32.rawdigest(key, [seed].pack('L')) }
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
data/splitclient-rb.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = 'Ruby client for split SDK.'
|
14
14
|
spec.description = 'Ruby client for using split SDK.'
|
15
15
|
spec.homepage = 'https://github.com/splitio/ruby-client'
|
16
|
-
spec.license = 'Apache
|
16
|
+
spec.license = 'Apache-2.0'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features|ext)/}) }
|
19
19
|
|
@@ -26,13 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
lib/murmurhash/murmurhash.jar]
|
27
27
|
)
|
28
28
|
else
|
29
|
-
spec.
|
30
|
-
%w[ext/murmurhash/3_x86_32.c
|
31
|
-
ext/murmurhash/extconf.rb
|
32
|
-
ext/murmurhash/murmurhash.c
|
33
|
-
ext/murmurhash/murmurhash.h]
|
34
|
-
)
|
35
|
-
spec.extensions = ['ext/murmurhash/extconf.rb']
|
29
|
+
spec.add_runtime_dependency 'digest-murmurhash', '>= 1.1.1'
|
36
30
|
end
|
37
31
|
|
38
32
|
spec.add_development_dependency 'allocation_stats'
|
@@ -40,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
40
34
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
41
35
|
spec.add_development_dependency 'pry'
|
42
36
|
spec.add_development_dependency 'pry-nav'
|
43
|
-
spec.add_development_dependency 'rake', '
|
37
|
+
spec.add_development_dependency 'rake', '12.3.3'
|
44
38
|
spec.add_development_dependency 'rake-compiler'
|
45
39
|
spec.add_development_dependency 'rspec'
|
46
40
|
spec.add_development_dependency 'rubocop', '0.59.0'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splitclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1.
|
4
|
+
version: 7.1.4.pre.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: digest-murmurhash
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: allocation_stats
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +98,16 @@ dependencies:
|
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - '='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 12.3.3
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 12.3.3
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake-compiler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,8 +322,7 @@ description: Ruby client for using split SDK.
|
|
308
322
|
email:
|
309
323
|
- pato@split.io
|
310
324
|
executables: []
|
311
|
-
extensions:
|
312
|
-
- ext/murmurhash/extconf.rb
|
325
|
+
extensions: []
|
313
326
|
extra_rdoc_files: []
|
314
327
|
files:
|
315
328
|
- ".github/pull_request_template.md"
|
@@ -324,10 +337,6 @@ files:
|
|
324
337
|
- LICENSE
|
325
338
|
- README.md
|
326
339
|
- Rakefile
|
327
|
-
- ext/murmurhash/3_x86_32.c
|
328
|
-
- ext/murmurhash/extconf.rb
|
329
|
-
- ext/murmurhash/murmurhash.c
|
330
|
-
- ext/murmurhash/murmurhash.h
|
331
340
|
- gemfiles/faraday_after_0.13.gemfile
|
332
341
|
- gemfiles/faraday_before_0.13.gemfile
|
333
342
|
- lib/murmurhash/base.rb
|
@@ -435,7 +444,7 @@ files:
|
|
435
444
|
- tasks/irb.rake
|
436
445
|
homepage: https://github.com/splitio/ruby-client
|
437
446
|
licenses:
|
438
|
-
- Apache
|
447
|
+
- Apache-2.0
|
439
448
|
metadata: {}
|
440
449
|
post_install_message:
|
441
450
|
rdoc_options: []
|
data/ext/murmurhash/3_x86_32.c
DELETED
@@ -1,88 +0,0 @@
|
|
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
|
-
}
|
data/ext/murmurhash/extconf.rb
DELETED
data/ext/murmurhash/murmurhash.c
DELETED
@@ -1,251 +0,0 @@
|
|
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
|
-
|
247
|
-
cDigest_MurmurHash3_x86_32 = rb_path2class("Digest::MurmurHashMRI3_x86_32");
|
248
|
-
rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "digest", murmur3_x86_32_s_digest, -1);
|
249
|
-
rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "rawdigest", murmur3_x86_32_s_rawdigest, -1);
|
250
|
-
rb_define_private_method(cDigest_MurmurHash3_x86_32, "finish", murmur3_x86_32_finish, 0);
|
251
|
-
}
|
data/ext/murmurhash/murmurhash.h
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH_INCLUDED
|
2
|
-
# define MURMURHASH_INCLUDED
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
// Microsoft Visual Studio
|
7
|
-
|
8
|
-
#if defined(_MSC_VER)
|
9
|
-
#define FORCE_INLINE __forceinline
|
10
|
-
#include <stdlib.h>
|
11
|
-
#define ROTL32(x,y) _rotl(x,y)
|
12
|
-
#define ROTL64(x,y) _rotl64(x,y)
|
13
|
-
#define BIG_CONSTANT(x) (x)
|
14
|
-
#else // defined(_MSC_VER)
|
15
|
-
#define FORCE_INLINE inline __attribute__((always_inline))
|
16
|
-
#define ROTL32(x,y) rotl32(x,y)
|
17
|
-
#define ROTL64(x,y) rotl64(x,y)
|
18
|
-
#define BIG_CONSTANT(x) (x##LLU)
|
19
|
-
#endif // !defined(_MSC_VER)
|
20
|
-
|
21
|
-
#ifdef DYNAMIC_ENDIAN
|
22
|
-
/* for universal binary of NEXTSTEP and MacOS X */
|
23
|
-
/* useless since autoconf 2.63? */
|
24
|
-
static int
|
25
|
-
is_bigendian(void)
|
26
|
-
{
|
27
|
-
static int init = 0;
|
28
|
-
static int endian_value;
|
29
|
-
char *p;
|
30
|
-
|
31
|
-
if (init) return endian_value;
|
32
|
-
init = 1;
|
33
|
-
p = (char*)&init;
|
34
|
-
return endian_value = p[0] ? 0 : 1;
|
35
|
-
}
|
36
|
-
# define BIGENDIAN_P() (is_bigendian())
|
37
|
-
#elif defined(WORDS_BIGENDIAN)
|
38
|
-
# define BIGENDIAN_P() 1
|
39
|
-
#else
|
40
|
-
# define BIGENDIAN_P() 0
|
41
|
-
#endif
|
42
|
-
|
43
|
-
#define MURMURHASH_MAGIC 0x5bd1e995
|
44
|
-
#define MURMURHASH_MAGIC64A BIG_CONSTANT(0xc6a4a7935bd1e995)
|
45
|
-
|
46
|
-
void assign_by_endian_32(uint8_t *digest, uint32_t h);
|
47
|
-
void assign_by_endian_64(uint8_t *digest, uint64_t h);
|
48
|
-
void assign_by_endian_128(uint8_t*, void*);
|
49
|
-
|
50
|
-
uint32_t rotl32(uint32_t, int8_t);
|
51
|
-
uint64_t rotl64(uint64_t, int8_t);
|
52
|
-
uint32_t getblock32(const uint32_t*, int);
|
53
|
-
uint64_t getblock64(const uint64_t*, int);
|
54
|
-
uint32_t fmix32(uint32_t);
|
55
|
-
uint64_t fmix64(uint64_t);
|
56
|
-
uint32_t _murmur_finish32(VALUE, uint32_t (*)(const char*, uint32_t, uint32_t));
|
57
|
-
uint64_t _murmur_finish64(VALUE, uint64_t (*)(const char*, uint32_t, uint64_t));
|
58
|
-
void _murmur_finish128(VALUE, void*, void (*)(const char*, uint32_t, uint32_t, void*));
|
59
|
-
uint32_t _murmur_s_digest32(int, VALUE*, VALUE, uint32_t (*)(const char*, uint32_t, uint32_t));
|
60
|
-
uint64_t _murmur_s_digest64(int, VALUE*, VALUE, uint64_t (*)(const char*, uint32_t, uint64_t));
|
61
|
-
void _murmur_s_digest128(int, VALUE*, VALUE, void*, void (*)(const char*, uint32_t, uint32_t, void*));
|
62
|
-
|
63
|
-
VALUE murmur1_finish(VALUE);
|
64
|
-
VALUE murmur1_s_digest(int, VALUE*, VALUE);
|
65
|
-
VALUE murmur1_s_rawdigest(int, VALUE*, VALUE);
|
66
|
-
VALUE murmur2_finish(VALUE);
|
67
|
-
VALUE murmur2_s_digest(int, VALUE*, VALUE);
|
68
|
-
VALUE murmur2_s_rawdigest(int, VALUE*, VALUE);
|
69
|
-
VALUE murmur2a_finish(VALUE);
|
70
|
-
VALUE murmur2a_s_digest(int, VALUE*, VALUE);
|
71
|
-
VALUE murmur2a_s_rawdigest(int, VALUE*, VALUE);
|
72
|
-
VALUE murmur64a_finish(VALUE);
|
73
|
-
VALUE murmur64a_s_digest(int, VALUE*, VALUE);
|
74
|
-
VALUE murmur64a_s_rawdigest(int, VALUE*, VALUE);
|
75
|
-
VALUE murmur64b_finish(VALUE);
|
76
|
-
VALUE murmur64b_s_digest(int, VALUE*, VALUE);
|
77
|
-
VALUE murmur64b_s_rawdigest(int, VALUE*, VALUE);
|
78
|
-
VALUE murmur_neutral2_finish(VALUE);
|
79
|
-
VALUE murmur_neutral2_s_digest(int, VALUE*, VALUE);
|
80
|
-
VALUE murmur_neutral2_s_rawdigest(int, VALUE*, VALUE);
|
81
|
-
VALUE murmur_aligned2_finish(VALUE);
|
82
|
-
VALUE murmur_aligned2_s_digest(int, VALUE*, VALUE);
|
83
|
-
VALUE murmur_aligned2_s_rawdigest(int, VALUE*, VALUE);
|
84
|
-
VALUE murmur3_x86_32_finish(VALUE);
|
85
|
-
VALUE murmur3_x86_32_s_digest(int, VALUE*, VALUE);
|
86
|
-
VALUE murmur3_x86_32_s_rawdigest(int, VALUE*, VALUE);
|
87
|
-
VALUE murmur3_x86_128_finish(VALUE);
|
88
|
-
VALUE murmur3_x86_128_s_digest(int, VALUE*, VALUE);
|
89
|
-
VALUE murmur3_x86_128_s_rawdigest(int, VALUE*, VALUE);
|
90
|
-
VALUE murmur3_x64_128_finish(VALUE);
|
91
|
-
VALUE murmur3_x64_128_s_digest(int, VALUE*, VALUE);
|
92
|
-
VALUE murmur3_x64_128_s_rawdigest(int, VALUE*, VALUE);
|
93
|
-
|
94
|
-
#endif /* ifndef MURMURHASH_INCLUDED */
|