cityhash 0.8.0 → 0.8.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.
@@ -1,3 +1,10 @@
1
+ ## 0.8.1 (May 18, 2013) ##
2
+
3
+ ### bugfixes
4
+ * do not segfalt with non-string input
5
+ * use proper compiler flag to compile crc version of cityhash lib (see README about installing gem on OSX,
6
+ on Linux everything should work out of the box)
7
+
1
8
  ## 0.8.0 (May 5, 2013) ##
2
9
 
3
10
  ### enhancements
data/README.md CHANGED
@@ -6,6 +6,10 @@ Ruby wrapper for google's cityhash.
6
6
 
7
7
  gem install cityhash
8
8
 
9
+ Since OSX uses `llvm-gcc-4.2` that doesn't support `-march=native` flag you have to compile `cityhash` lib with `clang++` compiler:
10
+
11
+ CXX=/usr/bin/clang++ gem install cityhash
12
+
9
13
  ### Usage
10
14
 
11
15
  ```ruby
@@ -1,6 +1,8 @@
1
1
  require 'mkmf'
2
2
 
3
- %w{g O3 Wall msse4.2}.each do |flag|
3
+ RbConfig::MAKEFILE_CONFIG['CXX'] = ENV['CXX'] if ENV['CXX']
4
+
5
+ %w{g O3 Wall march=native}.each do |flag|
4
6
  flag = "-#{flag}"
5
7
  $CPPFLAGS += " #{flag}" unless $CPPFLAGS.split.include? flag
6
8
  end
@@ -6,16 +6,22 @@ module CityHash
6
6
  HIGH64_MASK = 0xffffffffffffffff0000000000000000
7
7
 
8
8
  def self.hash32(input)
9
+ input = input.to_s
10
+
9
11
  Internal.hash32(input)
10
12
  end
11
13
 
12
14
  def self.hash64(input, seed1=nil, seed2=nil)
15
+ input = input.to_s
16
+
13
17
  return Internal.hash64(input) if seed1.nil?
14
18
  return Internal.hash64_with_seed(input, seed1.to_i) if seed2.nil?
15
19
  Internal.hash64_with_seeds(input, seed1.to_i, seed2.to_i)
16
20
  end
17
21
 
18
22
  def self.hash128(input, seed=nil)
23
+ input = input.to_s
24
+
19
25
  digest = if seed
20
26
  Internal.hash128_with_seed(input, packed_seed(seed))
21
27
  else
@@ -26,6 +32,8 @@ module CityHash
26
32
  end
27
33
 
28
34
  def self.hash128crc(input, seed=nil)
35
+ input = input.to_s
36
+
29
37
  digest = if seed
30
38
  Internal.hash128crc_with_seed(input, packed_seed(seed))
31
39
  else
@@ -36,6 +44,7 @@ module CityHash
36
44
  end
37
45
 
38
46
  def self.hash256crc(input)
47
+ input = input.to_s
39
48
  digest = Internal.hash256crc(input)
40
49
 
41
50
  [0..7, 8..15, 16..23].map { |r| digest[r].unpack('Q').first.to_s }.join.to_i
@@ -1,3 +1,3 @@
1
1
  module CityHash
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -9,33 +9,37 @@ describe CityHash do
9
9
  assert_equal 8581389452482819506, CityHash.hash64("test")
10
10
  end
11
11
 
12
- it "returns 64bit hash with a seed" do
12
+ it 'returns 64bit hash with a seed' do
13
13
  assert_equal 9154302171269876511, CityHash.hash64("test", 12345)
14
14
  end
15
15
 
16
- it "returns 64bit hash with seeds" do
16
+ it 'returns 64bit hash with seeds' do
17
17
  assert_equal 4854399283587686019, CityHash.hash64("test", 12345, 54321)
18
18
  end
19
19
 
20
- it "returns 128bit hash" do
20
+ it 'returns 128bit hash' do
21
21
  assert_equal 124124989950401219618153994964897029896, CityHash.hash128("test")
22
22
  end
23
23
 
24
- it "returns 128bit hash with seed" do
24
+ it 'returns 128bit hash with seed' do
25
25
  seed = (123 << 64) | 123
26
26
  assert_equal 1834994000056895780313918994795281207519, CityHash.hash128("test", seed)
27
27
  end
28
28
 
29
- it "returns 128bit crc hash" do
29
+ it 'returns 128bit crc hash' do
30
30
  assert_equal 124124989950401219618153994964897029896, CityHash.hash128crc("test")
31
31
  end
32
32
 
33
- it "returns 128bit crc hash with seed" do
33
+ it 'returns 128bit crc hash with seed' do
34
34
  seed = (123 << 64) | 123
35
35
  assert_equal 1834994000056895780313918994795281207519, CityHash.hash128crc("test", seed)
36
36
  end
37
37
 
38
- it "returns 256bit crc hash" do
38
+ it 'returns 256bit crc hash' do
39
39
  assert_equal 11964743055457135893972873789222488394617411264226841264756, CityHash.hash256crc("test")
40
40
  end
41
+
42
+ it 'converts input data to string' do
43
+ assert_equal CityHash.hash128('1337'), CityHash.hash128(1337)
44
+ end
41
45
  end
metadata CHANGED
@@ -1,33 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cityhash
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Vasiliy Ermolovich
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-05-05 00:00:00 Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: ruby bindings for google's cityhash
22
- email:
15
+ email:
23
16
  - younash@gmail.com
24
17
  executables: []
25
-
26
- extensions:
18
+ extensions:
27
19
  - ext/cityhash/extconf.rb
28
20
  extra_rdoc_files: []
29
-
30
- files:
21
+ files:
31
22
  - .gitignore
32
23
  - .travis.yml
33
24
  - CHANGELOG.md
@@ -47,37 +38,34 @@ files:
47
38
  - test/test_helper.rb
48
39
  homepage: http://github.com/nashby/cityhash
49
40
  licenses: []
50
-
51
41
  post_install_message:
52
42
  rdoc_options: []
53
-
54
- require_paths:
43
+ require_paths:
55
44
  - lib
56
- required_ruby_version: !ruby/object:Gem::Requirement
45
+ required_ruby_version: !ruby/object:Gem::Requirement
57
46
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ segments:
63
52
  - 0
64
- version: "0"
65
- required_rubygems_version: !ruby/object:Gem::Requirement
53
+ hash: 3315565900202712629
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
55
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ segments:
72
61
  - 0
73
- version: "0"
62
+ hash: 3315565900202712629
74
63
  requirements: []
75
-
76
64
  rubyforge_project: cityhash
77
65
  rubygems_version: 1.8.24
78
66
  signing_key:
79
67
  specification_version: 3
80
68
  summary: ruby bindings for google's cityhash
81
- test_files:
69
+ test_files:
82
70
  - test/cityhash_test.rb
83
71
  - test/test_helper.rb