digest-murmurhash 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -26
- data/Rakefile +2 -2
- data/digest-murmurhash.gemspec +6 -7
- data/ext/digest/murmurhash/{murmurhash1.c → 1.c} +1 -1
- data/ext/digest/murmurhash/{murmurhash2.c → 2.c} +1 -1
- data/ext/digest/murmurhash/{murmurhash2a.c → 2a.c} +1 -1
- data/ext/digest/murmurhash/3_x64_128.c +117 -0
- data/ext/digest/murmurhash/3_x86_128.c +141 -0
- data/ext/digest/murmurhash/3_x86_32.c +88 -0
- data/ext/digest/murmurhash/{murmurhash64a.c → 64a.c} +1 -1
- data/ext/digest/murmurhash/{murmurhash64b.c → 64b.c} +2 -2
- data/ext/digest/murmurhash/aligned2.c +163 -0
- data/ext/digest/murmurhash/extconf.rb +1 -1
- data/ext/digest/murmurhash/{murmurhash.c → init.c} +136 -22
- data/ext/digest/murmurhash/init.h +94 -0
- data/ext/digest/murmurhash/{murmurhash_neutral2.c → neutral2.c} +3 -3
- data/lib/digest/murmurhash.rb +3 -73
- data/lib/digest/murmurhash/base.rb +58 -0
- data/spec/bench.rb +18 -12
- data/spec/digest_spec.rb +41 -29
- data/spec/exception_spec.rb +17 -12
- data/spec/mem_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -8
- metadata +20 -36
- data/ext/digest/murmurhash/murmurhash.h +0 -46
- data/ext/digest/murmurhash/murmurhash1.h +0 -11
- data/ext/digest/murmurhash/murmurhash2.h +0 -11
- data/ext/digest/murmurhash/murmurhash2a.h +0 -11
- data/ext/digest/murmurhash/murmurhash64a.h +0 -10
- data/ext/digest/murmurhash/murmurhash64b.h +0 -11
- data/ext/digest/murmurhash/murmurhash_aligned2.c +0 -75
- data/ext/digest/murmurhash/murmurhash_aligned2.h +0 -11
- data/ext/digest/murmurhash/murmurhash_neutral2.h +0 -11
data/spec/mem_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,15 +9,13 @@ def all_classes
|
|
9
9
|
MurmurHash64A,
|
10
10
|
MurmurHash64B,
|
11
11
|
MurmurHashNeutral2,
|
12
|
-
MurmurHashAligned2
|
12
|
+
MurmurHashAligned2,
|
13
|
+
MurmurHash3_x86_32,
|
14
|
+
MurmurHash3_x86_128,
|
15
|
+
MurmurHash3_x64_128
|
13
16
|
]
|
14
17
|
end
|
15
18
|
|
16
|
-
def
|
17
|
-
(0..
|
19
|
+
def seed_str(klass)
|
20
|
+
(0..klass::DEFAULT_SEED.length).to_a.pack("C#{klass::DEFAULT_SEED.length}")
|
18
21
|
end
|
19
|
-
|
20
|
-
def seed64
|
21
|
-
(0..8).to_a.pack("C8")
|
22
|
-
end
|
23
|
-
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digest-murmurhash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: digest-simple
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,9 +66,10 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
|
-
description:
|
69
|
+
description: digest-murmurhash is class collections of use algorithm MurmurHash desiged
|
84
70
|
by Austin Appleby.
|
85
|
-
email:
|
71
|
+
email:
|
72
|
+
- co000ri@gmail.com
|
86
73
|
executables: []
|
87
74
|
extensions:
|
88
75
|
- ext/digest/murmurhash/extconf.rb
|
@@ -95,30 +82,27 @@ files:
|
|
95
82
|
- README.md
|
96
83
|
- Rakefile
|
97
84
|
- digest-murmurhash.gemspec
|
85
|
+
- ext/digest/murmurhash/1.c
|
86
|
+
- ext/digest/murmurhash/2.c
|
87
|
+
- ext/digest/murmurhash/2a.c
|
88
|
+
- ext/digest/murmurhash/3_x64_128.c
|
89
|
+
- ext/digest/murmurhash/3_x86_128.c
|
90
|
+
- ext/digest/murmurhash/3_x86_32.c
|
91
|
+
- ext/digest/murmurhash/64a.c
|
92
|
+
- ext/digest/murmurhash/64b.c
|
93
|
+
- ext/digest/murmurhash/aligned2.c
|
98
94
|
- ext/digest/murmurhash/extconf.rb
|
99
|
-
- ext/digest/murmurhash/
|
100
|
-
- ext/digest/murmurhash/
|
101
|
-
- ext/digest/murmurhash/
|
102
|
-
- ext/digest/murmurhash/murmurhash1.h
|
103
|
-
- ext/digest/murmurhash/murmurhash2.c
|
104
|
-
- ext/digest/murmurhash/murmurhash2.h
|
105
|
-
- ext/digest/murmurhash/murmurhash2a.c
|
106
|
-
- ext/digest/murmurhash/murmurhash2a.h
|
107
|
-
- ext/digest/murmurhash/murmurhash64a.c
|
108
|
-
- ext/digest/murmurhash/murmurhash64a.h
|
109
|
-
- ext/digest/murmurhash/murmurhash64b.c
|
110
|
-
- ext/digest/murmurhash/murmurhash64b.h
|
111
|
-
- ext/digest/murmurhash/murmurhash_aligned2.c
|
112
|
-
- ext/digest/murmurhash/murmurhash_aligned2.h
|
113
|
-
- ext/digest/murmurhash/murmurhash_neutral2.c
|
114
|
-
- ext/digest/murmurhash/murmurhash_neutral2.h
|
95
|
+
- ext/digest/murmurhash/init.c
|
96
|
+
- ext/digest/murmurhash/init.h
|
97
|
+
- ext/digest/murmurhash/neutral2.c
|
115
98
|
- lib/digest/murmurhash.rb
|
99
|
+
- lib/digest/murmurhash/base.rb
|
116
100
|
- spec/bench.rb
|
117
101
|
- spec/digest_spec.rb
|
118
102
|
- spec/exception_spec.rb
|
119
103
|
- spec/mem_spec.rb
|
120
104
|
- spec/spec_helper.rb
|
121
|
-
homepage:
|
105
|
+
homepage: https://github.com/ksss/digest-murmurhash
|
122
106
|
licenses:
|
123
107
|
- MIT
|
124
108
|
metadata: {}
|
@@ -141,7 +125,7 @@ rubyforge_project:
|
|
141
125
|
rubygems_version: 2.4.1
|
142
126
|
signing_key:
|
143
127
|
specification_version: 4
|
144
|
-
summary:
|
128
|
+
summary: digest-murmurhash is class collections of use algorithm MurmurHash desiged
|
145
129
|
by Austin Appleby.
|
146
130
|
test_files:
|
147
131
|
- spec/bench.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH_INCLUDED
|
2
|
-
# define MURMURHASH_INCLUDED
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
#if defined(_MSC_VER)
|
7
|
-
# define BIG_CONSTANT(x) (x)
|
8
|
-
// Other compilers
|
9
|
-
#else // defined(_MSC_VER)
|
10
|
-
# define BIG_CONSTANT(x) (x##LLU)
|
11
|
-
#endif // !defined(_MSC_VER)
|
12
|
-
|
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
|
31
|
-
#else
|
32
|
-
# define BIGENDIAN_P() 0
|
33
|
-
#endif
|
34
|
-
|
35
|
-
#define MURMURHASH_MAGIC 0x5bd1e995
|
36
|
-
#define MURMURHASH_MAGIC64A BIG_CONSTANT(0xc6a4a7935bd1e995)
|
37
|
-
|
38
|
-
void assign_by_endian_32(uint8_t *digest, uint64_t h);
|
39
|
-
void assign_by_endian_64(uint8_t *digest, uint64_t h);
|
40
|
-
|
41
|
-
uint32_t _murmur_finish32(VALUE self, uint32_t (*process)(const char *, uint32_t, uint32_t));
|
42
|
-
uint64_t _murmur_finish64(VALUE self, uint64_t (*process)(const char *, uint32_t, uint64_t));
|
43
|
-
uint32_t _murmur_s_digest32(int argc, VALUE *argv, VALUE klass, uint32_t (*process)(const char *, uint32_t, uint32_t));
|
44
|
-
uint64_t _murmur_s_digest64(int argc, VALUE *argv, VALUE klass, uint64_t (*process)(const char *, uint32_t, uint64_t));
|
45
|
-
|
46
|
-
#endif /* ifndef MURMURHASH_INCLUDED */
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH1_INCLUDED
|
2
|
-
# define MURMURHASH1_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur1_finish(VALUE self);
|
7
|
-
VALUE murmur1_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur1_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH1_INCLUDED */
|
11
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH2_INCLUDED
|
2
|
-
# define MURMURHASH2_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur2_finish(VALUE self);
|
7
|
-
VALUE murmur2_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur2_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH2_INCLUDED */
|
11
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH2A_INCLUDED
|
2
|
-
# define MURMURHASH2A_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur2a_finish(VALUE self);
|
7
|
-
VALUE murmur2a_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur2a_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH2A_INCLUDED */
|
11
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH64A_INCLUDED
|
2
|
-
# define MURMURHASH64A_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur64a_finish(VALUE self);
|
7
|
-
VALUE murmur64a_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur64a_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH64A_INCLUDED */
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH64B_INCLUDED
|
2
|
-
# define MURMURHASH64B_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur64b_finish(VALUE self);
|
7
|
-
VALUE murmur64b_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur64b_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH64B_INCLUDED */
|
11
|
-
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* MurmurHashAligned2 (C) Austin Appleby
|
3
|
-
*/
|
4
|
-
|
5
|
-
#include "murmurhash_aligned2.h"
|
6
|
-
|
7
|
-
uint32_t
|
8
|
-
murmur_hash_process_aligned2(const char * key, uint32_t len, uint32_t seed)
|
9
|
-
{
|
10
|
-
const uint32_t m = 0x5bd1e995;
|
11
|
-
const int r = 24;
|
12
|
-
|
13
|
-
uint32_t h = seed ^ len;
|
14
|
-
|
15
|
-
const unsigned char * data = (const unsigned char *)key;
|
16
|
-
|
17
|
-
while(len >= 4) {
|
18
|
-
uint32_t k;
|
19
|
-
|
20
|
-
k = data[0];
|
21
|
-
k |= data[1] << 8;
|
22
|
-
k |= data[2] << 16;
|
23
|
-
k |= data[3] << 24;
|
24
|
-
|
25
|
-
k *= m;
|
26
|
-
k ^= k >> r;
|
27
|
-
k *= m;
|
28
|
-
|
29
|
-
h *= m;
|
30
|
-
h ^= k;
|
31
|
-
|
32
|
-
data += 4;
|
33
|
-
len -= 4;
|
34
|
-
}
|
35
|
-
|
36
|
-
switch(len) {
|
37
|
-
case 3: h ^= data[2] << 16;
|
38
|
-
case 2: h ^= data[1] << 8;
|
39
|
-
case 1: h ^= data[0];
|
40
|
-
h *= m;
|
41
|
-
};
|
42
|
-
|
43
|
-
h ^= h >> 13;
|
44
|
-
h *= m;
|
45
|
-
h ^= h >> 15;
|
46
|
-
|
47
|
-
return h;
|
48
|
-
}
|
49
|
-
|
50
|
-
VALUE
|
51
|
-
murmur_aligned2_finish(VALUE self)
|
52
|
-
{
|
53
|
-
uint8_t digest[4];
|
54
|
-
uint32_t h;
|
55
|
-
|
56
|
-
h = _murmur_finish32(self, murmur_hash_process_aligned2);
|
57
|
-
assign_by_endian_32(digest, h);
|
58
|
-
return rb_str_new((const char*) digest, 4);
|
59
|
-
}
|
60
|
-
|
61
|
-
VALUE
|
62
|
-
murmur_aligned2_s_digest(int argc, VALUE *argv, VALUE klass)
|
63
|
-
{
|
64
|
-
uint8_t digest[4];
|
65
|
-
uint64_t h;
|
66
|
-
h = _murmur_s_digest32(argc, argv, klass, murmur_hash_process_aligned2);
|
67
|
-
assign_by_endian_32(digest, h);
|
68
|
-
return rb_str_new((const char*) digest, 4);
|
69
|
-
}
|
70
|
-
|
71
|
-
VALUE
|
72
|
-
murmur_aligned2_s_rawdigest(int argc, VALUE *argv, VALUE klass)
|
73
|
-
{
|
74
|
-
return ULL2NUM(_murmur_s_digest32(argc, argv, klass, murmur_hash_process_aligned2));
|
75
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH_ALIGNED2_INCLUDED
|
2
|
-
# define MURMURHASH_ALIGNED2_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur_aligned2_finish(VALUE self);
|
7
|
-
VALUE murmur_aligned2_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur_aligned2_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH_ALIGNED2_INCLUDED */
|
11
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#ifndef MURMURHASH_NEUTRAL2_INCLUDED
|
2
|
-
# define MURMURHASH_NEUTRAL2_INCLUDED
|
3
|
-
|
4
|
-
#include "murmurhash.h"
|
5
|
-
|
6
|
-
VALUE murmur_neutral2_finish(VALUE self);
|
7
|
-
VALUE murmur_neutral2_s_digest(int argc, VALUE *argv, VALUE klass);
|
8
|
-
VALUE murmur_neutral2_s_rawdigest(int argc, VALUE *argv, VALUE klass);
|
9
|
-
|
10
|
-
#endif /* ifndef MURMURHASH_NEUTRAL2_INCLUDED */
|
11
|
-
|