murmurhash 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6513d7c953acb5a8037c43749308c5e75754a6c
4
+ data.tar.gz: b557b9315a2e7d65e861bd89e6112aa4059b08c6
5
+ SHA512:
6
+ metadata.gz: 385ca12c021cc24043f165f505741a607fdcc53ce63814da3dfd3b03fee70424015d51f09b6bb5906a397d4e695c91aa6201144ffd62ae277f9dcafc89c31842
7
+ data.tar.gz: 9f20710e4ef599584998db3277840409e2e0e132e8fceb926c40677c0a01ec6ca54a21f0b0b031a4eaf2923507a5da6e1845f8b0eb87aede7222d49e9f859d42
data/LICENSE ADDED
File without changes
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+
3
+ create_makefile('murmurhash/murmurhash')
@@ -0,0 +1,59 @@
1
+ #include "ruby.h"
2
+ #include <stdint.h>
3
+
4
+
5
+ /* murmur hash 64A implementation */
6
+ VALUE hash_64_2A(VALUE self, VALUE value) {
7
+ int64_t buf_len = RSTRING_LEN(value);
8
+ char* buf = RSTRING_PTR(value);
9
+
10
+ const int32_t seed = 0x1234ABCDL;
11
+ const int64_t m = 0xc6a4a7935bd1e995LL;
12
+ const int r = 47;
13
+
14
+ int64_t h = seed ^ (buf_len * m);
15
+
16
+ int64_t * data = (int64_t *)buf;
17
+ int64_t * end = data + (buf_len / 8);
18
+
19
+ while(data != end)
20
+ {
21
+ int64_t k = *data++;
22
+
23
+ k *= m;
24
+ uint64_t k1 = k;
25
+ k ^= k1 >> r;
26
+ k *= m;
27
+
28
+ h ^= k;
29
+ h *= m;
30
+ }
31
+
32
+ char * data2 = (char*)data;
33
+
34
+ switch(buf_len & 7)
35
+ {
36
+ case 7: h ^= (int64_t)data2[6] << 48;
37
+ case 6: h ^= (int64_t)data2[5] << 40;
38
+ case 5: h ^= (int64_t)data2[4] << 32;
39
+ case 4: h ^= (int64_t)data2[3] << 24;
40
+ case 3: h ^= (int64_t)data2[2] << 16;
41
+ case 2: h ^= (int64_t)data2[1] << 8;
42
+ case 1: h ^= (int64_t)data2[0];
43
+ h *= m;
44
+ };
45
+
46
+ uint64_t h1 = h;
47
+ h ^= h1 >> r;
48
+ h *= m;
49
+ uint64_t h2 = h;
50
+ h ^= h2 >> r;
51
+
52
+ return LL2NUM(h);
53
+ }
54
+
55
+ void Init_murmurhash() {
56
+ VALUE Murmurhash = rb_define_module("Murmurhash");
57
+ rb_define_module_function(Murmurhash, "hash2A", hash_64_2A, 1);
58
+ }
59
+
@@ -0,0 +1,4 @@
1
+ module Murmurhash
2
+ end
3
+
4
+ require "murmurhash/murmurhash"
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: murmurhash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ted@ximalaya.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: murmur hash alogrithm
14
+ email: ted@ximalaya.com
15
+ executables: []
16
+ extensions:
17
+ - ext/murmurhash/extconf.rb
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - ext/murmurhash/extconf.rb
22
+ - ext/murmurhash/murmurhash.c
23
+ - lib/murmurhash.rb
24
+ homepage: http://www.ximalaya.com
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Many hash alogrithm.
48
+ test_files: []