rufus-tokyo 1.0.3 → 1.0.4

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.
Files changed (55) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGELOG.txt +6 -0
  3. data/Rakefile +91 -0
  4. data/doc/decision_table.numbers +0 -0
  5. data/lib/rufus/edo/README.txt +101 -0
  6. data/lib/rufus/edo/tabcore.rb +1 -3
  7. data/lib/rufus/tokyo.rb +1 -2
  8. data/lib/rufus/tokyo/cabinet/lib.rb +4 -7
  9. data/lib/rufus/tokyo/cabinet/table.rb +10 -13
  10. data/lib/rufus/tokyo/cabinet/util.rb +4 -1
  11. data/lib/rufus/tokyo/hmethods.rb +4 -4
  12. data/lib/rufus/tokyo/outlen.rb +5 -1
  13. data/lib/rufus/tokyo/tyrant/abstract.rb +8 -0
  14. data/lib/rufus/tokyo/tyrant/lib.rb +6 -6
  15. data/lib/rufus/tokyo/tyrant/table.rb +9 -1
  16. data/lib/rufus/tokyo/version.rb +32 -0
  17. data/rufus-tokyo.gemspec +135 -0
  18. data/spec/cabinet_btree_spec.rb +92 -0
  19. data/spec/cabinet_fixed_spec.rb +33 -0
  20. data/spec/cabinet_spec.rb +291 -0
  21. data/spec/cabinetconfig_spec.rb +82 -0
  22. data/spec/dystopia_core_spec.rb +124 -0
  23. data/spec/edo_cabinet_btree_spec.rb +123 -0
  24. data/spec/edo_cabinet_fixed_spec.rb +42 -0
  25. data/spec/edo_cabinet_spec.rb +286 -0
  26. data/spec/edo_ntyrant_spec.rb +224 -0
  27. data/spec/edo_ntyrant_table_spec.rb +296 -0
  28. data/spec/edo_table_spec.rb +292 -0
  29. data/spec/hmethods_spec.rb +73 -0
  30. data/spec/incr.lua +23 -0
  31. data/spec/openable_spec.rb +51 -0
  32. data/spec/shared_abstract_spec.rb +426 -0
  33. data/spec/shared_table_spec.rb +675 -0
  34. data/spec/shared_tyrant_spec.rb +42 -0
  35. data/spec/spec_base.rb +23 -0
  36. data/spec/start_tyrants.sh +28 -0
  37. data/spec/stop_tyrants.sh +9 -0
  38. data/spec/table_spec.rb +267 -0
  39. data/spec/tyrant_spec.rb +218 -0
  40. data/spec/tyrant_table_spec.rb +298 -0
  41. data/spec/util_list_spec.rb +197 -0
  42. data/spec/util_map_spec.rb +130 -0
  43. data/tasks/dev.rb +70 -0
  44. data/test/bm0.rb +353 -0
  45. data/test/bm1_compression.rb +54 -0
  46. data/test/con0.rb +30 -0
  47. data/test/mem.rb +49 -0
  48. data/test/mem1.rb +44 -0
  49. data/test/readme0.rb +17 -0
  50. data/test/readme1.rb +21 -0
  51. data/test/readme2.rb +15 -0
  52. data/test/readme3.rb +24 -0
  53. data/test/readmes_test.sh +17 -0
  54. metadata +81 -21
  55. data/MIGRATED.txt +0 -1
@@ -0,0 +1,54 @@
1
+
2
+ require 'rubygems'
3
+ require 'faker'
4
+ require 'benchmark'
5
+ require 'rufus/tokyo'
6
+
7
+ N = 100_000
8
+
9
+ NAME = Faker::Name.name
10
+
11
+ DATA = (0..N-1).collect { |i|
12
+ #{ 'name' => Faker::Name.name, 'sex' => 'male' }
13
+ { 'name' => NAME * 100, 'sex' => 'male' }
14
+ }
15
+
16
+ t0 = Rufus::Tokyo::Table.new('toto0.tdb')
17
+ t1 = Rufus::Tokyo::Table.new('toto1.tdb', :opts => 'ld')
18
+ t2 = Rufus::Tokyo::Table.new('toto2.tdb', :opts => 'lb')
19
+ #t3 = Rufus::Tokyo::Table.new('toto3.tdb', :opts => 'lt')
20
+
21
+ t0.clear
22
+ t1.clear
23
+ t2.clear
24
+ #t3.clear
25
+
26
+ Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
27
+ b.report('no compression') do
28
+ DATA.each_with_index { |row, i| t0["pk#{i}"] = row }
29
+ end
30
+ b.report('deflate') do
31
+ DATA.each_with_index { |row, i| t1["pk#{i}"] = row }
32
+ end
33
+ b.report('bzip2') do
34
+ DATA.each_with_index { |row, i| t2["pk#{i}"] = row }
35
+ end
36
+ #b.report('tcbs') do
37
+ # DATA.each_with_index { |row, i| t3["pk#{i}"] = row }
38
+ #end
39
+ end
40
+
41
+ t0.close
42
+ t1.close
43
+ t2.close
44
+ #t3.close
45
+
46
+ puts
47
+
48
+ puts 'no compression : ' + `ls -l toto0.tdb | awk '{ print $5 }'`
49
+ puts 'deflate : ' + `ls -l toto1.tdb | awk '{ print $5 }'`
50
+ puts 'bzip2 : ' + `ls -l toto2.tdb | awk '{ print $5 }'`
51
+ #puts 'tcbs : ' + `ls -l toto3.tdb | awk '{ print $5 }'`
52
+
53
+ puts
54
+
data/test/con0.rb ADDED
@@ -0,0 +1,30 @@
1
+
2
+ require 'rubygems'
3
+
4
+ require 'rufus/scheduler'
5
+ require 'rufus/tokyo/tyrant'
6
+ require 'rufus/edo/ntyrant'
7
+
8
+ SCHEDULER = Rufus::Scheduler.start_new
9
+
10
+ FFI_TABLE = Rufus::Tokyo::TyrantTable.new('127.0.0.1', 45001)
11
+ NET_TABLE = Rufus::Edo::NetTyrantTable.new('127.0.0.1', 45001)
12
+
13
+ def check_connection (table)
14
+ p [ table.class, table.stat ]
15
+ end
16
+
17
+ $interval = 0
18
+
19
+ BLOCK = lambda {
20
+ puts "=== #{Time.now}"
21
+ check_connection(FFI_TABLE)
22
+ check_connection(NET_TABLE)
23
+ $interval = $interval + 1
24
+ SCHEDULER.in("#{$interval}h", &BLOCK)
25
+ }
26
+
27
+ BLOCK.call
28
+
29
+ SCHEDULER.join
30
+
data/test/mem.rb ADDED
@@ -0,0 +1,49 @@
1
+
2
+ %w{ lib test }.each do |path|
3
+ path = File.expand_path(File.dirname(__FILE__) + '/../' + path)
4
+ $: << path unless $:.include?(path)
5
+ end
6
+
7
+ require 'fileutils'
8
+
9
+
10
+ def self_ps
11
+ ps = `ps -v #{$$}`.split("\n").last.split(' ')
12
+ %w{
13
+ pid stat time sl re pagein vsz rss lim tsiz pcpu pmem command
14
+ }.inject({}) { |h, k|
15
+ h[k.intern] = ps.shift; h
16
+ }
17
+ end
18
+
19
+ def pmem (msg)
20
+ p [ msg, "#{self_ps[:vsz].to_i / 1024}k" ]
21
+ end
22
+
23
+ pmem 'starting'
24
+
25
+ require 'rubygems'
26
+ require 'rufus/tokyo'
27
+
28
+ FileUtils.rm('test_mem.tch')
29
+
30
+ db = Rufus::Tokyo::Cabinet.new('test_mem.tch')
31
+
32
+ pmem 'wired to db'
33
+
34
+ 500_000.times { |i| db[i.to_s] = "value#{i}" }
35
+
36
+ pmem 'loaded 500_000 records'
37
+
38
+ db.each { |k, v| k }
39
+
40
+ pmem 'iterated 500_000 records'
41
+
42
+ a = db.collect { |k, v| k + v }
43
+
44
+ pmem 'collected 500_000 records'
45
+
46
+ db.close
47
+
48
+ pmem 'closed db'
49
+
data/test/mem1.rb ADDED
@@ -0,0 +1,44 @@
1
+
2
+ %w{ lib test }.each do |path|
3
+ path = File.expand_path(File.dirname(__FILE__) + '/../' + path)
4
+ $: << path unless $:.include?(path)
5
+ end
6
+
7
+ require 'fileutils'
8
+
9
+
10
+ def self_ps
11
+ ps = `ps -v #{$$}`.split("\n").last.split(' ')
12
+ %w{
13
+ pid stat time sl re pagein vsz rss lim tsiz pcpu pmem command
14
+ }.inject({}) { |h, k|
15
+ h[k.intern] = ps.shift; h
16
+ }
17
+ end
18
+
19
+ def pmem (msg)
20
+ p [ msg, "#{self_ps[:vsz].to_i / 1024}k" ]
21
+ end
22
+
23
+ pmem 'starting'
24
+
25
+ require 'rubygems'
26
+ require 'rufus/tokyo/util'
27
+
28
+ pmem 'required'
29
+
30
+ l = Rufus::Tokyo::List.new
31
+
32
+ 100000.times { |i| l << i.to_s }
33
+
34
+ pmem 'stored'
35
+
36
+ #100000.times { |i| l.delete_at(0) }
37
+ #100000.times { |i| s = l.delete_at(0); Rufus::Tokyo::CabinetLib.tcfree(s) }
38
+ s = nil
39
+ 100000.times { |i| s ||= l.delete_at(0); }
40
+ p s.class
41
+ p s.public_methods.sort
42
+
43
+ pmem 'cleared'
44
+
data/test/readme0.rb ADDED
@@ -0,0 +1,17 @@
1
+
2
+ require 'rubygems'
3
+ require 'rufus/tokyo'
4
+
5
+ db = Rufus::Tokyo::Cabinet.new('data.tch')
6
+
7
+ db['nada'] = 'surf'
8
+
9
+ p db['nada'] # => 'surf'
10
+ p db['lost'] # => nil
11
+
12
+ 5000.times { |i| db[i.to_s] = "x" }
13
+
14
+ p db.inject { |r, (k, v)| k } # => 4999
15
+
16
+ db.close
17
+
data/test/readme1.rb ADDED
@@ -0,0 +1,21 @@
1
+
2
+ require 'rubygems'
3
+ require 'rufus/tokyo'
4
+
5
+ t = Rufus::Tokyo::Table.new('table.tdb')
6
+
7
+ t['pk0'] = { 'name' => 'alfred', 'age' => '22' }
8
+ t['pk1'] = { 'name' => 'bob', 'age' => '18' }
9
+ t['pk2'] = { 'name' => 'charly', 'age' => '45' }
10
+ t['pk3'] = { 'name' => 'doug', 'age' => '77' }
11
+ t['pk4'] = { 'name' => 'ephrem', 'age' => '32' }
12
+
13
+ p t.query { |q|
14
+ q.add_condition 'age', :numge, '32'
15
+ q.order_by 'age'
16
+ }
17
+ # => [ {"name"=>"ephrem", :pk=>"pk4", "age"=>"32"},
18
+ # {"name"=>"charly", :pk=>"pk2", "age"=>"45"} ]
19
+
20
+ t.close
21
+
data/test/readme2.rb ADDED
@@ -0,0 +1,15 @@
1
+
2
+ # ttserver -port 45001 tmp/data.tch
3
+
4
+ require 'rubygems'
5
+ require 'rufus/tokyo/tyrant'
6
+
7
+ db = Rufus::Tokyo::Tyrant.new('localhost', 45001)
8
+
9
+ db['nada'] = 'surf'
10
+
11
+ p db['nada'] # => 'surf'
12
+ p db['lost'] # => nil
13
+
14
+ db.close
15
+
data/test/readme3.rb ADDED
@@ -0,0 +1,24 @@
1
+
2
+ # ttserver -port 45002 tmp/data.tct
3
+
4
+
5
+ require 'rubygems'
6
+ require 'rufus/tokyo/tyrant'
7
+
8
+ t = Rufus::Tokyo::TyrantTable.new('localhost', 45002)
9
+
10
+ t['pk0'] = { 'name' => 'alfred', 'age' => '22' }
11
+ t['pk1'] = { 'name' => 'bob', 'age' => '18' }
12
+ t['pk2'] = { 'name' => 'charly', 'age' => '45' }
13
+ t['pk3'] = { 'name' => 'doug', 'age' => '77' }
14
+ t['pk4'] = { 'name' => 'ephrem', 'age' => '32' }
15
+
16
+ p t.query { |q|
17
+ q.add_condition 'age', :numge, '32'
18
+ q.order_by 'age'
19
+ }
20
+ # => [ {"name"=>"ephrem", :pk=>"pk4", "age"=>"32"},
21
+ # {"name"=>"charly", :pk=>"pk2", "age"=>"45"} ]
22
+
23
+ t.close
24
+
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # testing the 4 samples in README.txt
5
+ #
6
+
7
+ [ -d tmp ] || mkdir tmp
8
+ nohup ttserver -port 45001 tmp/data.tch &
9
+ nohup ttserver -port 45002 tmp/data.tct &
10
+
11
+ ruby19 -Ilib test/readme0.rb
12
+ ruby19 -Ilib test/readme1.rb
13
+ ruby19 -Ilib test/readme2.rb
14
+ ruby19 -Ilib test/readme3.rb
15
+
16
+ killall ttserver
17
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-tokyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -12,10 +12,29 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-11-16 00:00:00 +09:00
15
+ date: 2009-12-25 00:00:00 +09:00
16
16
  default_executable:
17
- dependencies: []
18
-
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: ffi
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ version:
28
+ - !ruby/object:Gem::Dependency
29
+ name: yard
30
+ type: :development
31
+ version_requirement:
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: "0"
37
+ version:
19
38
  description: "\n\
20
39
  Ruby-ffi based lib to access Tokyo Cabinet and Tyrant.\n\n\
21
40
  The ffi-based structures are available via the Rufus::Tokyo namespace.\n\
@@ -27,56 +46,97 @@ executables: []
27
46
  extensions: []
28
47
 
29
48
  extra_rdoc_files:
49
+ - LICENSE.txt
30
50
  - README.rdoc
51
+ files:
52
+ - .gitignore
31
53
  - CHANGELOG.txt
32
54
  - CREDITS.txt
33
- files:
55
+ - LICENSE.txt
56
+ - README.rdoc
57
+ - Rakefile
58
+ - TODO.txt
59
+ - doc/decision_table.numbers
60
+ - lib/rufus-edo.rb
61
+ - lib/rufus-tokyo.rb
62
+ - lib/rufus/edo.rb
63
+ - lib/rufus/edo/README.txt
34
64
  - lib/rufus/edo/cabcore.rb
35
65
  - lib/rufus/edo/cabinet/abstract.rb
36
66
  - lib/rufus/edo/cabinet/table.rb
37
67
  - lib/rufus/edo/error.rb
68
+ - lib/rufus/edo/ntyrant.rb
38
69
  - lib/rufus/edo/ntyrant/abstract.rb
39
70
  - lib/rufus/edo/ntyrant/table.rb
40
- - lib/rufus/edo/ntyrant.rb
41
71
  - lib/rufus/edo/tabcore.rb
42
- - lib/rufus/edo.rb
72
+ - lib/rufus/tokyo.rb
43
73
  - lib/rufus/tokyo/cabinet/abstract.rb
44
74
  - lib/rufus/tokyo/cabinet/lib.rb
45
75
  - lib/rufus/tokyo/cabinet/table.rb
46
76
  - lib/rufus/tokyo/cabinet/util.rb
47
77
  - lib/rufus/tokyo/config.rb
78
+ - lib/rufus/tokyo/dystopia.rb
48
79
  - lib/rufus/tokyo/dystopia/core.rb
49
80
  - lib/rufus/tokyo/dystopia/lib.rb
50
81
  - lib/rufus/tokyo/dystopia/words.rb
51
- - lib/rufus/tokyo/dystopia.rb
52
82
  - lib/rufus/tokyo/hmethods.rb
53
83
  - lib/rufus/tokyo/openable.rb
54
84
  - lib/rufus/tokyo/outlen.rb
55
85
  - lib/rufus/tokyo/query.rb
56
86
  - lib/rufus/tokyo/transactions.rb
57
87
  - lib/rufus/tokyo/ttcommons.rb
88
+ - lib/rufus/tokyo/tyrant.rb
58
89
  - lib/rufus/tokyo/tyrant/abstract.rb
59
90
  - lib/rufus/tokyo/tyrant/ext.rb
60
91
  - lib/rufus/tokyo/tyrant/lib.rb
61
92
  - lib/rufus/tokyo/tyrant/table.rb
62
- - lib/rufus/tokyo/tyrant.rb
63
93
  - lib/rufus/tokyo/utils.rb
64
- - lib/rufus/tokyo.rb
65
- - lib/rufus-edo.rb
66
- - lib/rufus-tokyo.rb
67
- - CHANGELOG.txt
68
- - CREDITS.txt
69
- - LICENSE.txt
70
- - MIGRATED.txt
71
- - TODO.txt
72
- - README.rdoc
94
+ - lib/rufus/tokyo/version.rb
95
+ - rufus-tokyo.gemspec
96
+ - spec/cabinet_btree_spec.rb
97
+ - spec/cabinet_fixed_spec.rb
98
+ - spec/cabinet_spec.rb
99
+ - spec/cabinetconfig_spec.rb
100
+ - spec/dystopia_core_spec.rb
101
+ - spec/edo_cabinet_btree_spec.rb
102
+ - spec/edo_cabinet_fixed_spec.rb
103
+ - spec/edo_cabinet_spec.rb
104
+ - spec/edo_ntyrant_spec.rb
105
+ - spec/edo_ntyrant_table_spec.rb
106
+ - spec/edo_table_spec.rb
107
+ - spec/hmethods_spec.rb
108
+ - spec/incr.lua
109
+ - spec/openable_spec.rb
110
+ - spec/shared_abstract_spec.rb
111
+ - spec/shared_table_spec.rb
112
+ - spec/shared_tyrant_spec.rb
113
+ - spec/spec.rb
114
+ - spec/spec_base.rb
115
+ - spec/start_tyrants.sh
116
+ - spec/stop_tyrants.sh
117
+ - spec/table_spec.rb
118
+ - spec/tyrant_spec.rb
119
+ - spec/tyrant_table_spec.rb
120
+ - spec/util_list_spec.rb
121
+ - spec/util_map_spec.rb
122
+ - tasks/dev.rb
123
+ - test/bm0.rb
124
+ - test/bm1_compression.rb
125
+ - test/con0.rb
126
+ - test/mem.rb
127
+ - test/mem1.rb
128
+ - test/readme0.rb
129
+ - test/readme1.rb
130
+ - test/readme2.rb
131
+ - test/readme3.rb
132
+ - test/readmes_test.sh
73
133
  has_rdoc: true
74
- homepage: http://rufus.rubyforge.org/
134
+ homepage: http://github.com/jmettraux/rufus-tokyo/
75
135
  licenses: []
76
136
 
77
137
  post_install_message:
78
- rdoc_options: []
79
-
138
+ rdoc_options:
139
+ - --charset=UTF-8
80
140
  require_paths:
81
141
  - lib
82
142
  required_ruby_version: !ruby/object:Gem::Requirement
data/MIGRATED.txt DELETED
@@ -1 +0,0 @@
1
- to gemcutter.org indeed :)