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 +4 -4
- data/ChangeLog.txt +4 -0
- data/VERSION +1 -1
- data/ext/.gitignore +3 -0
- data/ext/clean.bat +2 -2
- data/ext/extconf.rb +3 -1
- data/ext/template/google_hash.cpp.erb +17 -5
- data/spec/spec.google_hash.rb +21 -11
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e2e281069867860a9b95da176c64ea6cac6edd4
|
|
4
|
+
data.tar.gz: 6fefbaa4dd867690a8c98e71a673e3a1f2ce88a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20451dff5baf9e8c88718646f595588825dff169762abc1cd15c45c5de12890b5299e9ce92d28c0f2bbb8cd6d4c8ae92f79ce61d89a9218b43836ba068e87441
|
|
7
|
+
data.tar.gz: 1553b2b10b4d8850050efd971d6a2f6e5367a263c98b26ba9857086bed37bb0cc362991440e697942fa37356dd366905539aeedf1c177be9931edf4f0241c186
|
data/ChangeLog.txt
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.9.0
|
data/ext/.gitignore
ADDED
data/ext/clean.bat
CHANGED
data/ext/extconf.rb
CHANGED
|
@@ -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 => "
|
|
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
|
-
//
|
|
101
|
-
//
|
|
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
|
|
203
|
-
cbs->hash_map->set_deleted_key(
|
|
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 %>
|
data/spec/spec.google_hash.rb
CHANGED
|
@@ -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(
|
|
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
|
|
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.
|
|
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-
|
|
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.
|
|
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
|