google_hash 0.8.9 → 0.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d4a00aced4b559a55a20aec05d369d460b9137e
4
- data.tar.gz: cf14467fd332cf5463922939c51e63362ccabcc5
3
+ metadata.gz: 3e2e281069867860a9b95da176c64ea6cac6edd4
4
+ data.tar.gz: 6fefbaa4dd867690a8c98e71a673e3a1f2ce88a0
5
5
  SHA512:
6
- metadata.gz: 1d7e3c4cfb37e5f185adb0fa52cf87c016643ec86586e82251f83459e13b22a2842fe21c29f632fefb8ae935eb626f79475df31371de67885e4c64e7de2e956a
7
- data.tar.gz: 06d813011b63e66e22b5fb2a1000617346f061d5f3d13551690942c2d4d17216cb8f7c970fb06970213992150213d8a356010cf092449400a59adb07137de9df
6
+ metadata.gz: 20451dff5baf9e8c88718646f595588825dff169762abc1cd15c45c5de12890b5299e9ce92d28c0f2bbb8cd6d4c8ae92f79ce61d89a9218b43836ba068e87441
7
+ data.tar.gz: 1553b2b10b4d8850050efd971d6a2f6e5367a263c98b26ba9857086bed37bb0cc362991440e697942fa37356dd366905539aeedf1c177be9931edf4f0241c186
@@ -1,3 +1,7 @@
1
+ 0.9.0
2
+ fix possible segfault during GC, all using this recommended to upgrade to it!
3
+ only affected people using RubyToInt or RubyToX
4
+
1
5
  0.8.9
2
6
  hopefully fix build failure OS X newer xcode releases
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.9
1
+ 0.9.0
@@ -0,0 +1,3 @@
1
+ *.o
2
+ *.cpp
3
+ sparsehash-2.0.2
@@ -1,6 +1,6 @@
1
1
  rm *.cpp
2
2
  rm *.o
3
- rm *.so
4
- rm *.def
3
+ rm -f *.so
4
+ rm -f *.def
5
5
  rm *.bundle
6
6
  rm mkmf.log
@@ -39,7 +39,8 @@ else
39
39
  end
40
40
 
41
41
  ruby_key = {:convert_keys_from_ruby => "", :convert_keys_to_ruby => "", :key_type => "VALUE", :english_key_type => "ruby",
42
- :extra_hash_params => ", hashrb, eqrb", :unreachable_key => "current_instance"} # TODO unreachable -> NULL instead?
42
+ :extra_hash_params => ", hashrb, eqrb", :unreachable_key => "(VALUE) 0", :deleted_key => "(VALUE) -1"}
43
+ # VALUE is a 64bit pointer as far as I can tell...so using 0 OK here since they'll never be NULL in real C land
43
44
 
44
45
  int_key = {:assert_key_type => 'T_FIXNUM', :convert_keys_from_ruby => "FIX2INT",
45
46
  :convert_keys_to_ruby => "INT2FIX", :key_type => "int", :unreachable_key => "#{unreachable_int}"}
@@ -78,6 +79,7 @@ for key in [ruby_key, int_key, bignum_as_double_key, long_key] do
78
79
 
79
80
  # create local variables so that the template can look cleaner
80
81
  unreachable_key = options[:unreachable_key]
82
+ deleted_key = options[:deleted_key] || "(#{options[:unreachable_key]}) - 1"
81
83
  convert_keys_from_ruby = options[:convert_keys_from_ruby]
82
84
  convert_keys_to_ruby = options[:convert_keys_to_ruby]
83
85
  key_type = options[:key_type]
@@ -96,10 +96,22 @@ struct eqrb
96
96
  if(s1 == s2) {
97
97
  return true;
98
98
  }
99
-
100
- // this line from object.c's rb_eql
101
- // lookup 0.278 -> 0.26
99
+ // the weird part here is that eqrb is used during iteration
100
+ // to iterate over the entire "hash space" and see which objects are
101
+ // "live" and which are "dead" in its iterator (as well as being used at insertion time)
102
+ // during gc, it was calling in to a real ruby "==" for the "live" objects
103
+ // which, if they used any type of allocation -> segfault
104
+ // since we're only dealing with ruby VALUE's here, I think we're guaranteed that they can't be NULL
105
+ <% if type == 'dense' %>
106
+ if (s2 == <%= unreachable_key %> || s2 == <%= deleted_key %> || s1 == <%= unreachable_key %> || s1 == <%= deleted_key %>) {
107
+ <% elsif type == 'sparse' %>
108
+ if (s2 == <%= unreachable_key %> || s1 == <%= unreachable_key %>) {
109
+ <% end %>
110
+ return s1 == s2; // comparison with these freako keys is straight forward :)
111
+ }
102
112
 
113
+ // this line (cacheing id_eql) from object.c's rb_eql
114
+ // lookup 0.278 -> 0.26
103
115
  return RTEST(rb_funcall(s1, id_eql, 1, s2));
104
116
  }
105
117
  };
@@ -199,8 +211,8 @@ callback_alloc( VALUE klass )
199
211
  <% if type == 'dense' %>
200
212
  // needs both empty key and deleted keys [and different] for deletes...
201
213
  cbs->hash_map->set_empty_key(<%= unreachable_key %>);
202
- // in th eory could also call set_deleted_key "anytime" ...
203
- cbs->hash_map->set_deleted_key((<%= unreachable_key %>)-1); // hope this is also typically unreachable from ruby land [?]
214
+ // in theory could also call set_deleted_key "anytime" ... but why not do it now
215
+ cbs->hash_map->set_deleted_key(<%= deleted_key %>);
204
216
  <% elsif type == 'sparse' %>
205
217
  cbs->hash_map->set_deleted_key(<%= unreachable_key %>);
206
218
  <% end %>
@@ -8,6 +8,11 @@ rescue LoadError
8
8
  require 'rspec/autorun'
9
9
  end
10
10
 
11
+
12
+ RSpec.configure do |config|
13
+ config.expect_with(:rspec) { |c| c.syntax = :should } # silence warning
14
+ end
15
+
11
16
  describe "google_hash" do
12
17
 
13
18
  before do
@@ -113,12 +118,6 @@ describe "google_hash" do
113
118
  a['abc'].should == 'def'
114
119
  end
115
120
 
116
- it "should have better namespace" do
117
- pending do
118
- GoogleHash::Sparse
119
- end
120
- end
121
-
122
121
  it "should disallow non numeric keys" do
123
122
  lambda { @subject['33']}.should raise_error(TypeError)
124
123
  end
@@ -181,7 +180,7 @@ describe "google_hash" do
181
180
 
182
181
  it "should raise on errant values" do
183
182
  a = GoogleHashDenseIntToInt.new
184
- proc { a[3] = 'abc'}.should raise_error
183
+ proc { a[3] = 'abc'}.should raise_error(TypeError)
185
184
  end
186
185
 
187
186
  it "should do bignum values as doubles" do
@@ -232,7 +231,7 @@ describe "google_hash" do
232
231
  end
233
232
 
234
233
  it "should do bignum to doubles et al" do
235
- test_big_numbers( GoogleHashDenseDoubleToDouble.new)
234
+ test_big_numbers(GoogleHashDenseDoubleToDouble.new)
236
235
  end
237
236
 
238
237
  it "should allow for storing true BigNum" do
@@ -254,7 +253,18 @@ describe "google_hash" do
254
253
  sum.should == 7
255
254
  end
256
255
  end
257
-
256
+
257
+ it "should not call Ruby #== during GC" do
258
+ a = GoogleHashSparseRubyToRuby.new
259
+ b = Object.new
260
+ def b.eql?(something)
261
+ raise "should not call this during GC!"
262
+ end
263
+ a[b] = 3
264
+ GC.start # used to raise...
265
+ a.each{|k, v| } # just in case, this really shouldn't either
266
+ end
267
+
258
268
  it "should have nice inspect" do
259
269
  a = GoogleHashSparseIntToRuby.new
260
270
  a[3] = 4
@@ -262,7 +272,7 @@ describe "google_hash" do
262
272
  a.inspect.should == "GoogleHashSparseIntToRuby {3=>4,4=>5}"
263
273
  end
264
274
 
265
- it "should skip GC when native to native" do
275
+ it "should skip iterating during GC when native to native" do
266
276
  pending 'caring, get from gc_bench.rb'
267
277
  end
268
278
 
@@ -277,7 +287,7 @@ describe "google_hash" do
277
287
  keys << (1<<61)
278
288
  end
279
289
  keys.each{|k|
280
- it "should allow for setting the right keys #{k} #{c}" do
290
+ it "should allow for setting the right keys key=#{k} class=#{c} (1<<61=#{1<<61})" do
281
291
  instance = c.new
282
292
  instance[k].should == nil
283
293
  instance[k] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rogerdpack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sane
@@ -81,6 +81,7 @@ files:
81
81
  - Rakefile
82
82
  - TODO
83
83
  - VERSION
84
+ - ext/.gitignore
84
85
  - ext/clean.bat
85
86
  - ext/extconf.rb
86
87
  - ext/go.bat
@@ -211,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
212
  version: '0'
212
213
  requirements: []
213
214
  rubyforge_project:
214
- rubygems_version: 2.4.5
215
+ rubygems_version: 2.4.6
215
216
  signing_key:
216
217
  specification_version: 4
217
218
  summary: Ruby wrappers to the google hash library