google_hash 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +17 -6
- data/VERSION +1 -1
- data/ext/template/google_hash.cpp.erb +1 -1
- metadata +18 -9
data/README
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
The "google_hash" gem.
|
2
2
|
|
3
3
|
Its goal. To boldly be faster than any hash hash before (cue star trek TNG theme).
|
4
4
|
|
5
|
-
|
5
|
+
Well, really the goal is a better hash for Ruby, either one that is faster or more space efficient than ruby's default.
|
6
|
+
To attempt to accomplish this, we wrap the google sparse and dense hashes [1] and see how they perform.
|
6
7
|
|
7
|
-
|
8
|
+
Time results (IntToInt hash, populating 500000 integers):
|
8
9
|
|
9
10
|
1.9.1p376 (mingw):
|
10
11
|
|
@@ -20,6 +21,11 @@ GoogleHashSparseIntToInt
|
|
20
21
|
0.53125 (populate)
|
21
22
|
0.078125 (each)
|
22
23
|
|
24
|
+
These also use significantly less memory, because (if you specify IntToInt, it stores only 4 bytes per int, instead of Ruby's
|
25
|
+
usual 20 bytes). This also frees up Ruby so it doesn't hvae to garbage collect as much. Yea!
|
26
|
+
|
27
|
+
See also the results.txt file
|
28
|
+
|
23
29
|
Usage:
|
24
30
|
|
25
31
|
a = GoogleHashDenseRubyToRuby.new
|
@@ -30,12 +36,14 @@ d = GoogleHashSparseIntToInt.new # :long => :long (longs are 8 byte ints on 64-
|
|
30
36
|
a[3] = 4
|
31
37
|
b[4] = 'abc'
|
32
38
|
b['abc'] = 'some complex object'
|
33
|
-
c[3] = 4 # all you can use are ints
|
39
|
+
c[3] = 4 # all you can use are ints...
|
34
40
|
|
35
41
|
a.each{|k, v| ... }
|
36
42
|
|
37
|
-
a.keys
|
38
|
-
|
43
|
+
a.keys
|
44
|
+
=> Array
|
45
|
+
a.values
|
46
|
+
=> Array
|
39
47
|
|
40
48
|
For a complete list, see types.txt, but it's all the various combinations of Ruby, Int, and Long.
|
41
49
|
|
@@ -58,6 +66,7 @@ ex: currently it uses longs internally instead of ints--if you want ints or char
|
|
58
66
|
|
59
67
|
if you want it to remember insertion order, I could do that, too, or native "store away" strings/bignums, whatever.
|
60
68
|
|
69
|
+
Could also add vectors, vector(pairs), priority queues, floats, native bignums, other more complex types, if anybody asks me to.
|
61
70
|
|
62
71
|
This is meant to be one more tool in the rubyists toolbelt when trying to optimize speed-wise, and plans to expand to more types, but at least with this release it has a #each method.
|
63
72
|
|
@@ -72,3 +81,5 @@ If you want to see the code/hack on it, run extconf.rb within the ext directory,
|
|
72
81
|
Related:
|
73
82
|
|
74
83
|
judy http://groups.google.com/group/ruby-talk-google/browse_thread/thread/05ed587925526a7f/314375891d12b672?lnk=raot
|
84
|
+
|
85
|
+
NArray gem : provides "native" type arrays (and X-D array)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -7,7 +7,7 @@
|
|
7
7
|
using google::<%= type %>_hash_map; // namespace where class lives by default
|
8
8
|
using std::cout;
|
9
9
|
using std::endl;
|
10
|
-
<% if OS.
|
10
|
+
<% if OS.posix? %>
|
11
11
|
#include <ext/hash_set>
|
12
12
|
<% end %>
|
13
13
|
using __gnu_cxx::hash; // or __gnu_cxx::hash, or maybe tr1::hash, depending on your OS
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- rogerdpack
|
@@ -9,19 +14,21 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-23 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: sane
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description: Ruby wrappers to the google hash library
|
26
33
|
email: rogerdpack@gmail.com
|
27
34
|
executables: []
|
@@ -133,18 +140,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
140
|
requirements:
|
134
141
|
- - ">="
|
135
142
|
- !ruby/object:Gem::Version
|
143
|
+
segments:
|
144
|
+
- 0
|
136
145
|
version: "0"
|
137
|
-
version:
|
138
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
147
|
requirements:
|
140
148
|
- - ">="
|
141
149
|
- !ruby/object:Gem::Version
|
150
|
+
segments:
|
151
|
+
- 0
|
142
152
|
version: "0"
|
143
|
-
version:
|
144
153
|
requirements: []
|
145
154
|
|
146
155
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.3.
|
156
|
+
rubygems_version: 1.3.6
|
148
157
|
signing_key:
|
149
158
|
specification_version: 3
|
150
159
|
summary: Ruby wrappers to the google hash library
|