murmur_redux 1.0.1 → 1.0.3
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/.gitignore +0 -0
- data/.ruby-gemset +0 -0
- data/.ruby-version +0 -0
- data/Gemfile +0 -2
- data/README.md +6 -1
- data/Rakefile +7 -3
- data/ext/murmur_native/extconf.rb +0 -0
- data/ext/murmur_native/murmur_native.c +0 -0
- data/lib/murmur_redux.rb +0 -0
- data/lib/murmur_redux/errors.rb +0 -0
- data/lib/murmur_redux/hash.rb +8 -10
- data/lib/murmur_redux/version.rb +1 -1
- data/murmur_redux.gemspec +1 -1
- data/spec/minitest_helper.rb +4 -0
- data/spec/murmur_native_spec.rb +20 -18
- data/spec/murmur_redux/hash_spec.rb +2 -2
- metadata +4 -6
- data/.rspec +0 -2
- data/Guardfile +0 -24
- data/spec/spec_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6120028ad8ef0e982f87e14f20562fa1340a5dcc
|
4
|
+
data.tar.gz: 2a5d6875492e07c35ab42a102b4358882397e2f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 880ff7831d0597f967b2fbeb6c674cdd49cd055c6e1482bfca9b397bd5ded25bc961a4476a023edf7ce2d49a408ceae40bfa8b45db79ccdba07a560ddfad5a02
|
7
|
+
data.tar.gz: 951b44887394b9cbda557304a33a591578e0eaadbd0d17ce2027996b34a8026572687ccb41a41be18a2484b889bae69e1f29e9ddaca5b16ca34e58d1d157813a
|
data/.gitignore
CHANGED
File without changes
|
data/.ruby-gemset
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# Murmur redux
|
2
2
|
|
3
|
-
A
|
3
|
+
A simple wrapper around murmurhash3 C extension originally based on murmurhash3-ruby gem[0]
|
4
|
+
|
5
|
+
> MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup. It was created by Austin Appleby in , and exists in a number of variants, all of which have been released into the public domain. When compared to other popular hash functions, MurmurHash performed well in a random distribution of regular keys.[1]
|
4
6
|
|
5
7
|
It defaults to `MurmurHash3_x86_128` which is a nice combination of low latency and with good collision resistence.
|
6
8
|
|
9
|
+
- [0] - [Github repo for murmurhash3-ruby gem](https://github.com/funny-falcon/murmurhash3-ruby)
|
10
|
+
- [1] - [Wikipedia article](http://en.wikipedia.org/wiki/MurmurHash)
|
11
|
+
|
7
12
|
## Installation
|
8
13
|
|
9
14
|
Include the gem in your Gemfile:
|
data/Rakefile
CHANGED
@@ -3,9 +3,13 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/testtask'
|
5
5
|
require 'rake/extensiontask'
|
6
|
-
require 'rspec/core/rake_task'
|
7
6
|
|
8
|
-
RSpec::Core::RakeTask.new(:spec)
|
9
7
|
Rake::ExtensionTask.new 'murmur_native'
|
10
8
|
|
11
|
-
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.libs << 'spec'
|
11
|
+
t.pattern = 'spec/*_spec.rb'
|
12
|
+
t.pattern = 'spec/**/*_spec.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
task default: %i(compile test)
|
File without changes
|
File without changes
|
data/lib/murmur_redux.rb
CHANGED
File without changes
|
data/lib/murmur_redux/errors.rb
CHANGED
File without changes
|
data/lib/murmur_redux/hash.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
module MurmurRedux
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
ints = MurmurRedux::V128.str_hash(string)
|
2
|
+
module Hash
|
3
|
+
def self.digest(string)
|
4
|
+
ints = MurmurRedux::V128.str_hash(string)
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
generate_hex_string(ints)
|
7
|
+
end
|
9
8
|
|
10
|
-
|
9
|
+
private
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
def self.generate_hex_string(ints)
|
12
|
+
ints.pack('L*').unpack('H*').first
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
data/lib/murmur_redux/version.rb
CHANGED
data/murmur_redux.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.author = 'Marian Posaceanu'
|
12
12
|
gem.email = 'contact@marianposaceanu.com'
|
13
13
|
gem.files = `git ls-files`.split("\n")
|
14
|
-
gem.test_files = `git ls-files -- {
|
14
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
15
15
|
gem.require_paths = ['lib', 'ext']
|
16
16
|
gem.homepage = 'https://github.com/dakull/murmur_redux'
|
17
17
|
gem.extensions = FileList["ext/**/extconf.rb"]
|
data/spec/murmur_native_spec.rb
CHANGED
@@ -1,46 +1,48 @@
|
|
1
|
+
require_relative './minitest_helper.rb'
|
2
|
+
|
1
3
|
shared_examples_128 = proc do
|
2
4
|
it 'should make correct hash for string' do
|
3
|
-
murmur.str_hash('asdfqwer', 0).
|
4
|
-
murmur.str_hash('asdfqwerzxcvyui', 0).
|
5
|
-
murmur.str_hash('asdfqwerzxcvyuio', 0).
|
6
|
-
murmur.str_hash('asdfqwerzxcvyuio!', 0).
|
5
|
+
murmur.str_hash('asdfqwer', 0).must_equal([0xd6d7d367, 0xcb41f064, 0x8973cd72, 0xc345e72e])
|
6
|
+
murmur.str_hash('asdfqwerzxcvyui', 0).must_equal([0x007b2172f, 0x64ecae1b, 0x1813b5a5, 0x9c674ee6])
|
7
|
+
murmur.str_hash('asdfqwerzxcvyuio', 0).must_equal([0xf508df57, 0xbb38f3fd, 0xf48c9d98, 0xb65c36cd])
|
8
|
+
murmur.str_hash('asdfqwerzxcvyuio!', 0).must_equal([0x8a011755, 0xb13d463f, 0x8386d32a, 0x0df8884c])
|
7
9
|
end
|
8
10
|
|
9
11
|
it 'should make correct hash for 32bit integer' do
|
10
|
-
murmur.int32_hash(1717859169).
|
11
|
-
murmur.int32_hash(1717859169).
|
12
|
+
murmur.int32_hash(1717859169).must_equal([0x20b48108, 0x10369ceb, 0x3ad523cc, 0xdacb587f])
|
13
|
+
murmur.int32_hash(1717859169).must_equal(murmur.str_hash('asdf'))
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'should make correct hash for 64bit integer' do
|
15
|
-
murmur.int64_hash(0x12345678).
|
16
|
-
murmur.int64_hash(0x1234567812345678).
|
17
|
+
murmur.int64_hash(0x12345678).must_equal(murmur.str_hash("\x78\x56\x34\x12\x00\x00\x00\x00"))
|
18
|
+
murmur.int64_hash(0x1234567812345678).must_equal(murmur.str_hash("\x78\x56\x34\x12\x78\x56\x34\x12"))
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'should make correct fmix for 64bit integer' do
|
20
|
-
murmur.fmix(1717859169).
|
21
|
-
murmur.fmix(12345678912345678).
|
22
|
+
murmur.fmix(1717859169).must_equal(0xbefb9076a3712207)
|
23
|
+
murmur.fmix(12345678912345678).must_equal(0x197ef59146f5221c)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
shared_examples_32 = proc do
|
26
28
|
it 'should make correct hash for string' do
|
27
|
-
murmur.str_hash('asdfqwer', 0).
|
28
|
-
murmur.str_hash('asdfqwerty', 0).
|
29
|
-
murmur.str_hash('asd', 0).
|
29
|
+
murmur.str_hash('asdfqwer', 0).must_equal(0xa46b5209)
|
30
|
+
murmur.str_hash('asdfqwerty', 0).must_equal(0xa3cfe04b)
|
31
|
+
murmur.str_hash('asd', 0).must_equal(0x14570c6f)
|
30
32
|
end
|
31
33
|
|
32
34
|
it 'should make correct hash for 32bit integer' do
|
33
|
-
murmur.int32_hash(1717859169).
|
34
|
-
murmur.int32_hash(1717859169).
|
35
|
+
murmur.int32_hash(1717859169).must_equal(0x1b20e026)
|
36
|
+
murmur.int32_hash(1717859169).must_equal(murmur.str_hash('asdf'))
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'should make correct hash for 64bit integer' do
|
38
|
-
murmur.int64_hash(0x12345678).
|
39
|
-
murmur.int64_hash(0x1234567812345678).
|
40
|
+
murmur.int64_hash(0x12345678).must_equal(murmur.str_hash("\x78\x56\x34\x12\x00\x00\x00\x00"))
|
41
|
+
murmur.int64_hash(0x1234567812345678).must_equal(murmur.str_hash("\x78\x56\x34\x12\x78\x56\x34\x12"))
|
40
42
|
end
|
41
43
|
|
42
44
|
it 'should make correct fmix for 32bit integer' do
|
43
|
-
murmur.fmix(1717859169).
|
45
|
+
murmur.fmix(1717859169).must_equal(0x17561734)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../minitest_helper.rb'
|
2
2
|
|
3
3
|
describe MurmurRedux::Hash do
|
4
4
|
let(:string_to_digest) { 'Hello, world!' }
|
@@ -6,6 +6,6 @@ describe MurmurRedux::Hash do
|
|
6
6
|
it 'digests an argument supplied string into a hexadecimal representation' do
|
7
7
|
digested_string = MurmurRedux::Hash.digest(string_to_digest)
|
8
8
|
|
9
|
-
|
9
|
+
digested_string.must_equal 'df65d6d2d12d51f164c5f3a85066322c'
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: murmur_redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marian Posaceanu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple wrapper around murmurhash3 C extension originally based on https://github.com/funny-falcon/murmurhash3-ruby
|
14
14
|
email: contact@marianposaceanu.com
|
@@ -18,11 +18,9 @@ extensions:
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- .gitignore
|
21
|
-
- .rspec
|
22
21
|
- .ruby-gemset
|
23
22
|
- .ruby-version
|
24
23
|
- Gemfile
|
25
|
-
- Guardfile
|
26
24
|
- README.md
|
27
25
|
- Rakefile
|
28
26
|
- ext/murmur_native/extconf.rb
|
@@ -32,9 +30,9 @@ files:
|
|
32
30
|
- lib/murmur_redux/hash.rb
|
33
31
|
- lib/murmur_redux/version.rb
|
34
32
|
- murmur_redux.gemspec
|
33
|
+
- spec/minitest_helper.rb
|
35
34
|
- spec/murmur_native_spec.rb
|
36
35
|
- spec/murmur_redux/hash_spec.rb
|
37
|
-
- spec/spec_helper.rb
|
38
36
|
homepage: https://github.com/dakull/murmur_redux
|
39
37
|
licenses:
|
40
38
|
- MIT
|
@@ -56,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
54
|
version: '0'
|
57
55
|
requirements: []
|
58
56
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.0.
|
57
|
+
rubygems_version: 2.0.0
|
60
58
|
signing_key:
|
61
59
|
specification_version: 4
|
62
60
|
summary: A simple wrapper around murmurhash3 C extension.
|
data/.rspec
DELETED
data/Guardfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard :rspec do
|
5
|
-
watch(%r{^spec/.+_spec\.rb$})
|
6
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
-
watch('spec/spec_helper.rb') { "spec" }
|
8
|
-
|
9
|
-
# Rails example
|
10
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
-
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
-
watch('config/routes.rb') { "spec/routing" }
|
15
|
-
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
-
|
17
|
-
# Capybara features specs
|
18
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
-
|
20
|
-
# Turnip features and steps
|
21
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
-
end
|
24
|
-
|