rufus-tokyo 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +9 -0
- data/CREDITS.txt +1 -0
- data/README.txt +6 -1
- data/TODO.txt +11 -7
- data/lib/rufus/edo/cabcore.rb +31 -16
- data/lib/rufus/edo/cabinet/abstract.rb +11 -2
- data/lib/rufus/edo/cabinet/table.rb +19 -2
- data/lib/rufus/edo/ntyrant/table.rb +13 -0
- data/lib/rufus/edo/tabcore.rb +10 -29
- data/lib/rufus/tokyo.rb +13 -1
- data/lib/rufus/tokyo/cabinet/abstract.rb +123 -31
- data/lib/rufus/tokyo/cabinet/lib.rb +32 -30
- data/lib/rufus/tokyo/cabinet/table.rb +77 -44
- data/lib/rufus/tokyo/cabinet/util.rb +130 -93
- data/lib/rufus/tokyo/config.rb +5 -2
- data/lib/rufus/tokyo/hmethods.rb +14 -7
- data/lib/rufus/tokyo/tyrant/abstract.rb +16 -3
- data/lib/rufus/tokyo/tyrant/lib.rb +16 -10
- data/lib/rufus/tokyo/tyrant/table.rb +0 -2
- metadata +6 -4
data/lib/rufus/tokyo/config.rb
CHANGED
@@ -33,7 +33,6 @@ module Tokyo
|
|
33
33
|
|
34
34
|
protected
|
35
35
|
|
36
|
-
#
|
37
36
|
# Given a path, a hash of parameters and a suffix,
|
38
37
|
#
|
39
38
|
# a) makes sure that the path has the given suffix or raises an exception
|
@@ -113,8 +112,12 @@ module Tokyo
|
|
113
112
|
|
114
113
|
:width => (params[:width] || 255).to_i,
|
115
114
|
# width of the value of each record (:fixed)
|
116
|
-
:limsiz => (params[:limsiz] || 26_8435_456).to_i
|
115
|
+
:limsiz => (params[:limsiz] || 26_8435_456).to_i,
|
117
116
|
# limit size of the database file (:fixed)
|
117
|
+
|
118
|
+
:dfunit => (params[:dfunit] || 0).to_i
|
119
|
+
# unit step number. If it is not more than 0,
|
120
|
+
# the auto defragmentation is disabled.
|
118
121
|
}
|
119
122
|
end
|
120
123
|
|
data/lib/rufus/tokyo/hmethods.rb
CHANGED
@@ -30,69 +30,76 @@ module Tokyo
|
|
30
30
|
# A mixin for Cabinet and Map, gathers all the hash-like methods
|
31
31
|
#
|
32
32
|
module HashMethods
|
33
|
+
|
33
34
|
include Enumerable
|
34
35
|
|
35
|
-
#
|
36
36
|
# The [] methods
|
37
37
|
#
|
38
38
|
# (assumes there's an underlying get(k) method)
|
39
39
|
#
|
40
40
|
def [] (k)
|
41
|
+
|
41
42
|
val = get(k)
|
43
|
+
|
42
44
|
return val unless val.nil?
|
43
45
|
return nil unless @default_proc
|
46
|
+
|
44
47
|
@default_proc.call(self, k)
|
45
48
|
end
|
46
49
|
|
47
|
-
#
|
48
50
|
# Returns an array of all the values
|
49
51
|
#
|
50
52
|
def values
|
53
|
+
|
51
54
|
collect { |k, v| v }
|
52
55
|
end
|
53
56
|
|
54
|
-
#
|
55
57
|
# Our classical 'each'
|
56
58
|
#
|
57
59
|
def each
|
60
|
+
|
58
61
|
keys.each { |k| yield(k, self[k]) }
|
59
62
|
end
|
60
63
|
|
61
|
-
#
|
62
64
|
# Turns this instance into a Ruby hash
|
63
65
|
#
|
64
66
|
def to_h
|
67
|
+
|
65
68
|
self.inject({}) { |h, (k, v)| h[k] = v; h }
|
66
69
|
end
|
67
70
|
|
68
|
-
#
|
69
71
|
# Turns this instance into an array of [ key, value ]
|
70
72
|
#
|
71
73
|
def to_a
|
74
|
+
|
72
75
|
self.collect { |e| e }
|
73
76
|
end
|
74
77
|
|
75
|
-
#
|
76
78
|
# Returns a new Ruby hash which is a merge of this Map and the given hash
|
77
79
|
#
|
78
80
|
def merge (h)
|
81
|
+
|
79
82
|
self.to_h.merge(h)
|
80
83
|
end
|
81
84
|
|
82
|
-
#
|
83
85
|
# Merges the entries in the given hash into this map
|
84
86
|
#
|
85
87
|
def merge! (h)
|
88
|
+
|
86
89
|
h.each { |k, v| self[k] = v }
|
90
|
+
|
87
91
|
self
|
88
92
|
end
|
89
93
|
|
90
94
|
def default (key=nil)
|
95
|
+
|
91
96
|
val = self[key]
|
97
|
+
|
92
98
|
val.nil? ? @default_proc.call(self, key) : val
|
93
99
|
end
|
94
100
|
|
95
101
|
def default= (val)
|
102
|
+
|
96
103
|
@default_proc = lambda { |h, k| val }
|
97
104
|
end
|
98
105
|
|
@@ -86,6 +86,7 @@ module Rufus::Tokyo
|
|
86
86
|
# Using the tyrant lib
|
87
87
|
#
|
88
88
|
def lib
|
89
|
+
|
89
90
|
TyrantLib
|
90
91
|
end
|
91
92
|
|
@@ -94,6 +95,7 @@ module Rufus::Tokyo
|
|
94
95
|
# DISABLED.
|
95
96
|
#
|
96
97
|
def copy (target_path)
|
98
|
+
|
97
99
|
#@db.copy(target_path)
|
98
100
|
raise 'not allowed to create files on the server'
|
99
101
|
end
|
@@ -109,11 +111,22 @@ module Rufus::Tokyo
|
|
109
111
|
#
|
110
112
|
def ext (func_name, key, value, opts={})
|
111
113
|
|
112
|
-
|
113
|
-
|
114
|
-
|
114
|
+
k = key.to_s
|
115
|
+
v = value.to_s
|
116
|
+
|
117
|
+
outlen_op(
|
118
|
+
:tcrdbext,
|
119
|
+
func_name.to_s,
|
120
|
+
compute_ext_opts(opts),
|
121
|
+
k, Rufus::Tokyo.blen(k),
|
122
|
+
v, Rufus::Tokyo.blen(v))
|
115
123
|
end
|
116
124
|
|
125
|
+
# Tyrant databases DO NOT support the 'defrag' call. Calling this method
|
126
|
+
# will raise an exception.
|
127
|
+
#
|
128
|
+
undef_method(:defrag)
|
129
|
+
|
117
130
|
protected
|
118
131
|
|
119
132
|
def do_call_misc (function, list_pointer)
|
@@ -75,22 +75,28 @@ module Rufus::Tokyo
|
|
75
75
|
attfunc :abs_rnum, :tcrdbrnum, [ :pointer ], :uint64
|
76
76
|
attfunc :abs_size, :tcrdbsize, [ :pointer ], :uint64
|
77
77
|
|
78
|
-
attfunc :
|
79
|
-
attfunc :
|
80
|
-
|
78
|
+
attfunc :abs_get, :tcrdbget, [ :pointer, :pointer, :int, :pointer ], :pointer
|
79
|
+
attfunc :abs_put, :tcrdbput, [ :pointer, :pointer, :int, :pointer, :int ], :int
|
80
|
+
|
81
|
+
attfunc :abs_out, :tcrdbout, [ :pointer, :pointer, :int ], :int
|
82
|
+
|
83
|
+
attfunc :abs_putkeep, :tcrdbputkeep, [ :pointer, :pointer, :int, :pointer, :int ], :int
|
81
84
|
|
82
85
|
attfunc :abs_iterinit, :tcrdbiterinit, [ :pointer ], :int
|
83
|
-
attfunc :
|
86
|
+
attfunc :abs_iternext, :tcrdbiternext, [ :pointer, :pointer ], :pointer
|
84
87
|
|
85
88
|
attfunc :abs_vanish, :tcrdbvanish, [ :pointer ], :int
|
86
89
|
|
87
90
|
attfunc :abs_sync, :tcrdbsync, [ :pointer ], :int
|
88
91
|
attfunc :abs_copy, :tcrdbcopy, [ :pointer, :string ], :int
|
89
92
|
|
90
|
-
attfunc :
|
93
|
+
attfunc :abs_fwmkeys, :tcrdbfwmkeys, [ :pointer, :pointer, :int, :int ], :pointer
|
91
94
|
attfunc :tcrdbmisc, [ :pointer, :string, :int, :pointer ], :pointer
|
92
95
|
|
93
|
-
attfunc :
|
96
|
+
attfunc :tcrdbext, [ :pointer, :string, :int, :pointer, :int, :pointer, :int, :pointer ], :pointer
|
97
|
+
|
98
|
+
attfunc :addint, :tcrdbaddint, [ :pointer, :string, :int, :int ], :int
|
99
|
+
attfunc :adddouble, :tcrdbadddouble, [ :pointer, :string, :int, :double ], :double
|
94
100
|
|
95
101
|
#
|
96
102
|
# table functions
|
@@ -99,12 +105,12 @@ module Rufus::Tokyo
|
|
99
105
|
|
100
106
|
attfunc :tab_genuid, :tcrdbtblgenuid, [ :pointer ], :int64
|
101
107
|
|
102
|
-
attfunc :tab_get, :tcrdbtblget, [ :pointer, :
|
108
|
+
attfunc :tab_get, :tcrdbtblget, [ :pointer, :pointer, :int ], :pointer
|
103
109
|
|
104
110
|
attfunc :tab_iterinit, :tcrdbiterinit, [ :pointer ], :int
|
105
|
-
attfunc :
|
111
|
+
attfunc :tab_iternext, :tcrdbiternext, [ :pointer, :pointer ], :pointer
|
106
112
|
|
107
|
-
attfunc :tab_put, :tcrdbtblput, [ :pointer, :
|
113
|
+
attfunc :tab_put, :tcrdbtblput, [ :pointer, :pointer, :int, :pointer ], :int
|
108
114
|
|
109
115
|
attfunc :tab_out, :tcrdbtblout, [ :pointer, :string, :int ], :int
|
110
116
|
|
@@ -119,7 +125,7 @@ module Rufus::Tokyo
|
|
119
125
|
|
120
126
|
attfunc :tab_setindex, :tcrdbtblsetindex, [ :pointer, :string, :int ], :int
|
121
127
|
|
122
|
-
attfunc :
|
128
|
+
attfunc :tab_fwmkeys, :tcrdbfwmkeys, [ :pointer, :pointer, :int, :int ], :pointer
|
123
129
|
|
124
130
|
#
|
125
131
|
# qry functions
|
@@ -47,7 +47,6 @@ module Rufus::Tokyo
|
|
47
47
|
|
48
48
|
attr_reader :host, :port
|
49
49
|
|
50
|
-
#
|
51
50
|
# Connects to the Tyrant table listening at the given host and port.
|
52
51
|
#
|
53
52
|
# You start such a Tyrant with :
|
@@ -133,7 +132,6 @@ module Rufus::Tokyo
|
|
133
132
|
"Tyrant tables don't support transactions", method_name)
|
134
133
|
end
|
135
134
|
|
136
|
-
#
|
137
135
|
# Returns the raw stat string from the Tyrant server.
|
138
136
|
#
|
139
137
|
def do_stat
|
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: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-02 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
- TODO.txt
|
69
69
|
has_rdoc: true
|
70
70
|
homepage: http://rufus.rubyforge.org/
|
71
|
+
licenses: []
|
72
|
+
|
71
73
|
post_install_message:
|
72
74
|
rdoc_options: []
|
73
75
|
|
@@ -88,9 +90,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
90
|
requirements:
|
89
91
|
- ffi
|
90
92
|
rubyforge_project: rufus
|
91
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.2
|
92
94
|
signing_key:
|
93
|
-
specification_version:
|
95
|
+
specification_version: 3
|
94
96
|
summary: ruby-ffi based lib to access Tokyo Cabinet and Tyrant
|
95
97
|
test_files:
|
96
98
|
- spec/spec.rb
|