rufus-tokyo 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +8 -0
- data/TODO.txt +3 -0
- data/lib/rufus/edo/cabcore.rb +2 -7
- data/lib/rufus/edo/cabinet/abstract.rb +2 -7
- data/lib/rufus/edo/cabinet/table.rb +2 -7
- data/lib/rufus/edo/error.rb +2 -7
- data/lib/rufus/edo/ntyrant/abstract.rb +18 -17
- data/lib/rufus/edo/ntyrant/table.rb +2 -2
- data/lib/rufus/edo/tabcore.rb +13 -1
- data/lib/rufus/tokyo/cabinet/abstract.rb +58 -7
- data/lib/rufus/tokyo/cabinet/lib.rb +22 -7
- data/lib/rufus/tokyo/cabinet/table.rb +20 -5
- data/lib/rufus/tokyo/cabinet/util.rb +2 -7
- data/lib/rufus/tokyo/config.rb +2 -7
- data/lib/rufus/tokyo/dystopia/lib.rb +2 -7
- data/lib/rufus/tokyo/dystopia/words.rb +2 -7
- data/lib/rufus/tokyo/dystopia.rb +2 -7
- data/lib/rufus/tokyo/hmethods.rb +2 -7
- data/lib/rufus/tokyo/query.rb +2 -7
- data/lib/rufus/tokyo/transactions.rb +2 -7
- data/lib/rufus/tokyo/{stats.rb → ttcommons.rb} +15 -10
- data/lib/rufus/tokyo/tyrant/abstract.rb +21 -13
- data/lib/rufus/tokyo/tyrant/lib.rb +17 -3
- data/lib/rufus/tokyo/tyrant/table.rb +4 -9
- data/lib/rufus/tokyo/tyrant.rb +2 -7
- data/lib/rufus/tokyo.rb +1 -1
- metadata +3 -3
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
= rufus-tokyo CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-tokyo - 0.1.12 released 2009/04/07
|
6
|
+
|
7
|
+
- todo : added ext method for calling embedded Lua function (Tyrant)
|
8
|
+
- todo : added transaction support for Rufus::Tokyo::Cabinet
|
9
|
+
- todo : mimicking query.count in rufus/edo
|
10
|
+
- todo : implemented query.count (TC 1.4.12 and TT 1.1.20 only) rufus/tokyo
|
11
|
+
|
12
|
+
|
5
13
|
== rufus-tokyo - 0.1.11 released 2009/03/25
|
6
14
|
|
7
15
|
- todo : autodetecting /usr/lib/libtokyocabinet.so and
|
data/TODO.txt
CHANGED
data/lib/rufus/edo/cabcore.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'rufus/tokyo/hmethods'
|
32
27
|
require 'rufus/tokyo/transactions'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'tokyocabinet' # gem install careo-tokyocabinet
|
32
27
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'tokyocabinet'
|
32
27
|
|
data/lib/rufus/edo/error.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Edo
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,20 +18,16 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'tokyotyrant' # gem install careo-tokyotyrant
|
32
27
|
|
33
28
|
require 'rufus/edo/error'
|
34
29
|
require 'rufus/edo/cabcore'
|
35
|
-
require 'rufus/tokyo/
|
30
|
+
require 'rufus/tokyo/ttcommons'
|
36
31
|
|
37
32
|
|
38
33
|
module Rufus::Edo
|
@@ -48,11 +43,10 @@ module Rufus::Edo
|
|
48
43
|
class NetTyrant
|
49
44
|
|
50
45
|
include Rufus::Edo::CabinetCore
|
51
|
-
include Rufus::Tokyo::
|
46
|
+
include Rufus::Tokyo::TyrantCommons
|
52
47
|
|
53
48
|
attr_reader :host, :port
|
54
49
|
|
55
|
-
#
|
56
50
|
# Connects to a given Tokyo Tyrant server.
|
57
51
|
#
|
58
52
|
# Note that if the port is not specified, the host parameter is expected
|
@@ -92,7 +86,6 @@ module Rufus::Edo
|
|
92
86
|
end
|
93
87
|
end
|
94
88
|
|
95
|
-
#
|
96
89
|
# Returns the 'weight' of the db (in bytes)
|
97
90
|
#
|
98
91
|
def weight
|
@@ -100,7 +93,6 @@ module Rufus::Edo
|
|
100
93
|
self.stat['size']
|
101
94
|
end
|
102
95
|
|
103
|
-
#
|
104
96
|
# isn't that a bit dangerous ? it creates a file on the server...
|
105
97
|
#
|
106
98
|
# DISABLED.
|
@@ -111,7 +103,6 @@ module Rufus::Edo
|
|
111
103
|
raise 'not allowed to create files on the server'
|
112
104
|
end
|
113
105
|
|
114
|
-
#
|
115
106
|
# Copies the current cabinet to a new file.
|
116
107
|
#
|
117
108
|
# Does it by copying each entry afresh to the target file. Spares some
|
@@ -122,7 +113,6 @@ module Rufus::Edo
|
|
122
113
|
raise NotImplementedError.new('not creating files locally')
|
123
114
|
end
|
124
115
|
|
125
|
-
#
|
126
116
|
# Deletes all the entries whose keys begin with the given prefix
|
127
117
|
#
|
128
118
|
def delete_keys_with_prefix (prefix)
|
@@ -131,7 +121,6 @@ module Rufus::Edo
|
|
131
121
|
nil
|
132
122
|
end
|
133
123
|
|
134
|
-
#
|
135
124
|
# Given a list of keys, returns a Hash { key => value } of the
|
136
125
|
# matching entries (in one sweep).
|
137
126
|
#
|
@@ -140,7 +129,6 @@ module Rufus::Edo
|
|
140
129
|
Hash[*@db.misc('getlist', keys)]
|
141
130
|
end
|
142
131
|
|
143
|
-
#
|
144
132
|
# Merges the given hash into this Tyrant and returns self.
|
145
133
|
#
|
146
134
|
def merge! (hash)
|
@@ -150,7 +138,6 @@ module Rufus::Edo
|
|
150
138
|
end
|
151
139
|
alias :lput :merge!
|
152
140
|
|
153
|
-
#
|
154
141
|
# Given a list of keys, deletes all the matching entries (in one sweep).
|
155
142
|
#
|
156
143
|
def ldelete (keys)
|
@@ -159,6 +146,20 @@ module Rufus::Edo
|
|
159
146
|
nil
|
160
147
|
end
|
161
148
|
|
149
|
+
# Calls a lua embedded function
|
150
|
+
# (http://tokyocabinet.sourceforge.net/tyrantdoc/#luaext)
|
151
|
+
#
|
152
|
+
# Options are :global_locking and :record_locking
|
153
|
+
#
|
154
|
+
# Returns the return value of the called function.
|
155
|
+
#
|
156
|
+
# Nil is returned in case of failure.
|
157
|
+
#
|
158
|
+
def ext (func_name, key, value, opts={})
|
159
|
+
|
160
|
+
@db.ext(func_name.to_s, key.to_s, value.to_s, compute_ext_opts(opts))
|
161
|
+
end
|
162
|
+
|
162
163
|
protected
|
163
164
|
|
164
165
|
def do_stat #:nodoc#
|
@@ -27,7 +27,7 @@ require 'tokyotyrant'
|
|
27
27
|
|
28
28
|
require 'rufus/edo/error'
|
29
29
|
require 'rufus/edo/tabcore'
|
30
|
-
require 'rufus/tokyo/
|
30
|
+
require 'rufus/tokyo/ttcommons'
|
31
31
|
|
32
32
|
|
33
33
|
module Rufus::Edo
|
@@ -48,7 +48,7 @@ module Rufus::Edo
|
|
48
48
|
class NetTyrantTable
|
49
49
|
|
50
50
|
include Rufus::Edo::TableCore
|
51
|
-
include Rufus::Tokyo::
|
51
|
+
include Rufus::Tokyo::TyrantCommons
|
52
52
|
|
53
53
|
attr_reader :host, :port
|
54
54
|
|
data/lib/rufus/edo/tabcore.rb
CHANGED
@@ -431,7 +431,19 @@ module Rufus::Edo
|
|
431
431
|
# Runs this query (returns a TableResultSet instance)
|
432
432
|
#
|
433
433
|
def run
|
434
|
-
TableResultSet.new(@table, @query.search, @opts)
|
434
|
+
@last_resultset = TableResultSet.new(@table, @query.search, @opts)
|
435
|
+
end
|
436
|
+
|
437
|
+
#
|
438
|
+
# Returns the count of results this query return when last run.
|
439
|
+
# Returns 0 if the query was not yet run.
|
440
|
+
#
|
441
|
+
def count
|
442
|
+
|
443
|
+
#@query.count
|
444
|
+
# not yet implemented by Hirabayashi-san
|
445
|
+
|
446
|
+
@last_resultset ? @last_resultset.size : 0
|
435
447
|
end
|
436
448
|
|
437
449
|
#
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,13 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
require 'rufus/tokyo/transactions'
|
24
27
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
28
|
|
31
29
|
module Rufus::Tokyo
|
32
30
|
|
@@ -53,6 +51,7 @@ module Rufus::Tokyo
|
|
53
51
|
class Cabinet
|
54
52
|
|
55
53
|
include HashMethods
|
54
|
+
include Transactions
|
56
55
|
|
57
56
|
#
|
58
57
|
# Creates/opens the cabinet, raises an exception in case of
|
@@ -396,8 +395,52 @@ module Rufus::Tokyo
|
|
396
395
|
call_misc('outlist', Rufus::Tokyo::List.new(keys))
|
397
396
|
end
|
398
397
|
|
398
|
+
# Warning : this method is low-level, you probably only need
|
399
|
+
# to use #transaction and a block.
|
400
|
+
#
|
401
|
+
# Direct call for 'transaction begin'.
|
402
|
+
#
|
403
|
+
def tranbegin
|
404
|
+
|
405
|
+
check_transaction_support
|
406
|
+
|
407
|
+
libcall(:tcadbtranbegin)
|
408
|
+
end
|
409
|
+
|
410
|
+
# Warning : this method is low-level, you probably only need
|
411
|
+
# to use #transaction and a block.
|
412
|
+
#
|
413
|
+
# Direct call for 'transaction commit'.
|
414
|
+
#
|
415
|
+
def trancommit
|
416
|
+
|
417
|
+
check_transaction_support
|
418
|
+
|
419
|
+
libcall(:tcadbtrancommit)
|
420
|
+
end
|
421
|
+
|
422
|
+
# Warning : this method is low-level, you probably only need
|
423
|
+
# to use #transaction and a block.
|
424
|
+
#
|
425
|
+
# Direct call for 'transaction abort'.
|
426
|
+
#
|
427
|
+
def tranabort
|
428
|
+
|
429
|
+
check_transaction_support
|
430
|
+
|
431
|
+
libcall(:tcadbtranabort)
|
432
|
+
end
|
433
|
+
|
399
434
|
protected
|
400
435
|
|
436
|
+
def check_transaction_support
|
437
|
+
|
438
|
+
raise(TokyoError.new(
|
439
|
+
"The version of Tokyo Cabinet you're using doesn't support " +
|
440
|
+
"transactions for non-table structures. Upgrade to TC >= 1.4.13.")
|
441
|
+
) unless lib.respond_to?(:tcadbtranbegin)
|
442
|
+
end
|
443
|
+
|
401
444
|
#
|
402
445
|
# wrapping tcadbmisc or tcrdbmisc
|
403
446
|
# (and taking care of freeing the list_pointer)
|
@@ -416,10 +459,18 @@ module Rufus::Tokyo
|
|
416
459
|
end
|
417
460
|
end
|
418
461
|
|
462
|
+
# calls the tcadbmisc function
|
463
|
+
#
|
419
464
|
def do_call_misc (function, list_pointer)
|
420
465
|
|
421
466
|
lib.tcadbmisc(@db, function, list_pointer)
|
422
467
|
end
|
468
|
+
|
469
|
+
def libcall (lib_method, *args)
|
470
|
+
|
471
|
+
(eval(%{ lib.#{lib_method}(@db, *args) }) == 1) or \
|
472
|
+
raise TokyoError.new("call to #{lib_method} failed")
|
473
|
+
end
|
423
474
|
end
|
424
475
|
end
|
425
476
|
|
@@ -42,14 +42,17 @@ module Rufus::Tokyo
|
|
42
42
|
/usr/local/lib/libtokyocabinet.so
|
43
43
|
})
|
44
44
|
|
45
|
-
|
45
|
+
begin
|
46
46
|
|
47
|
-
|
48
|
-
"didn't find Tokyo Cabinet libs on your system. " +
|
49
|
-
"Please install Tokyo Cabinet (http://tokyocabinet.sf.net)"
|
50
|
-
) unless path
|
47
|
+
ffi_lib(*paths)
|
51
48
|
|
52
|
-
|
49
|
+
rescue LoadError => le
|
50
|
+
raise(
|
51
|
+
"didn't find Tokyo Cabinet libs on your system. " +
|
52
|
+
"Please install Tokyo Cabinet (http://tokyocabinet.sf.net) " +
|
53
|
+
"(see also http://openwferu.rubyforge.org/tokyo.html)"
|
54
|
+
)
|
55
|
+
end
|
53
56
|
|
54
57
|
class << self
|
55
58
|
alias :attfunc :attach_function
|
@@ -97,6 +100,13 @@ module Rufus::Tokyo
|
|
97
100
|
|
98
101
|
attfunc :tcadbmisc, [ :pointer, :string, :pointer ], :pointer
|
99
102
|
|
103
|
+
begin # since TC 1.4.13
|
104
|
+
attfunc :tcadbtranbegin, [ :pointer ], :int
|
105
|
+
attfunc :tcadbtrancommit, [ :pointer ], :int
|
106
|
+
attfunc :tcadbtranabort, [ :pointer ], :int
|
107
|
+
rescue FFI::NotFoundError => nfe
|
108
|
+
end
|
109
|
+
|
100
110
|
#
|
101
111
|
# tctdb functions
|
102
112
|
#
|
@@ -154,7 +164,7 @@ module Rufus::Tokyo
|
|
154
164
|
attfunc :qry_addcond, :tctdbqryaddcond, [ :pointer, :string, :int, :string ], :void
|
155
165
|
attfunc :qry_setorder, :tctdbqrysetorder, [ :pointer, :string, :int ], :void
|
156
166
|
|
157
|
-
begin
|
167
|
+
begin # since TC 1.4.10
|
158
168
|
attfunc :qry_setmax, :tctdbqrysetmax, [ :pointer, :int ], :void
|
159
169
|
rescue FFI::NotFoundError => nfe
|
160
170
|
attfunc :qry_setlimit, :tctdbqrysetlimit, [ :pointer, :int, :int ], :void
|
@@ -162,6 +172,11 @@ module Rufus::Tokyo
|
|
162
172
|
|
163
173
|
attfunc :qry_search, :tctdbqrysearch, [ :pointer ], :pointer
|
164
174
|
|
175
|
+
begin # since TC 1.4.12
|
176
|
+
attfunc :qry_count, :tctdbqrycount, [ :pointer ], :int
|
177
|
+
rescue FFI::NotFoundError => nfe
|
178
|
+
end
|
179
|
+
|
165
180
|
#
|
166
181
|
# tcmap functions
|
167
182
|
#
|
@@ -287,6 +287,8 @@ module Rufus::Tokyo
|
|
287
287
|
#
|
288
288
|
def delete_keys_with_prefix (prefix)
|
289
289
|
|
290
|
+
# TODO : use ...searchout
|
291
|
+
|
290
292
|
ks = lib.tab_fwmkeys2(@db, prefix, -1) # -1 for no limit
|
291
293
|
#Rufus::Tokyo::List.new(ks).release.each { |k| self.delete(k) }
|
292
294
|
begin
|
@@ -335,7 +337,6 @@ module Rufus::Tokyo
|
|
335
337
|
a
|
336
338
|
end
|
337
339
|
|
338
|
-
#
|
339
340
|
# Warning : this method is low-level, you probably only need
|
340
341
|
# to use #transaction and a block.
|
341
342
|
#
|
@@ -345,7 +346,6 @@ module Rufus::Tokyo
|
|
345
346
|
libcall(:tctdbtranbegin)
|
346
347
|
end
|
347
348
|
|
348
|
-
#
|
349
349
|
# Warning : this method is low-level, you probably only need
|
350
350
|
# to use #transaction and a block.
|
351
351
|
#
|
@@ -355,7 +355,6 @@ module Rufus::Tokyo
|
|
355
355
|
libcall(:tctdbtrancommit)
|
356
356
|
end
|
357
357
|
|
358
|
-
#
|
359
358
|
# Warning : this method is low-level, you probably only need
|
360
359
|
# to use #transaction and a block.
|
361
360
|
#
|
@@ -403,7 +402,7 @@ module Rufus::Tokyo
|
|
403
402
|
err_code = lib.tab_ecode(@db)
|
404
403
|
err_msg = lib.tab_errmsg(err_code)
|
405
404
|
|
406
|
-
raise TokyoError
|
405
|
+
raise TokyoError.new("(err #{err_code}) #{err_msg}")
|
407
406
|
end
|
408
407
|
end
|
409
408
|
|
@@ -557,7 +556,23 @@ module Rufus::Tokyo
|
|
557
556
|
# Runs this query (returns a TableResultSet instance)
|
558
557
|
#
|
559
558
|
def run
|
560
|
-
|
559
|
+
|
560
|
+
@last_resultset =
|
561
|
+
TableResultSet.new(@table, lib.qry_search(@query), @opts)
|
562
|
+
end
|
563
|
+
|
564
|
+
#
|
565
|
+
# Gets the count of records returned by this query.
|
566
|
+
#
|
567
|
+
# Note : the 'real' impl is only available since TokyoCabinet 1.4.12.
|
568
|
+
#
|
569
|
+
def count
|
570
|
+
|
571
|
+
if lib.respond_to?(:qry_count)
|
572
|
+
lib.qry_count(@query)
|
573
|
+
else
|
574
|
+
@last_resultset ? @last_resultset.size : 0
|
575
|
+
end
|
561
576
|
end
|
562
577
|
|
563
578
|
#
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'rufus/tokyo/hmethods'
|
32
27
|
|
data/lib/rufus/tokyo/config.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Tokyo
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus::Tokyo
|
32
27
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus::Tokyo
|
32
27
|
|
data/lib/rufus/tokyo/dystopia.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'rufus/tokyo'
|
32
27
|
|
data/lib/rufus/tokyo/hmethods.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Tokyo
|
data/lib/rufus/tokyo/query.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Tokyo
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Tokyo
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,24 +18,19 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
module Rufus
|
32
27
|
module Tokyo
|
33
28
|
|
34
29
|
#
|
35
|
-
#
|
30
|
+
# #stat and #compte_ext_opts, that's all.
|
36
31
|
#
|
37
|
-
module
|
32
|
+
module TyrantCommons
|
38
33
|
|
39
|
-
#
|
40
34
|
# Returns a hash of information about the Tokyo Tyrant database (or table)
|
41
35
|
# at the other end of the connection.
|
42
36
|
#
|
@@ -48,6 +42,17 @@ module Tokyo
|
|
48
42
|
r
|
49
43
|
}
|
50
44
|
end
|
45
|
+
|
46
|
+
# Computes the :int option for the "ext" function (triggering
|
47
|
+
# tyrant embedded lua functions)
|
48
|
+
#
|
49
|
+
def compute_ext_opts (opts)
|
50
|
+
|
51
|
+
r = 0
|
52
|
+
r = r | 1 if opts[:record_locking]
|
53
|
+
r = r | 2 if opts[:global_locking]
|
54
|
+
r
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,16 +18,12 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
|
-
require 'rufus/tokyo/
|
26
|
+
require 'rufus/tokyo/ttcommons'
|
32
27
|
|
33
28
|
|
34
29
|
module Rufus::Tokyo
|
@@ -43,11 +38,10 @@ module Rufus::Tokyo
|
|
43
38
|
#
|
44
39
|
class Tyrant < Cabinet
|
45
40
|
|
46
|
-
include
|
41
|
+
include TyrantCommons
|
47
42
|
|
48
43
|
attr_reader :host, :port
|
49
44
|
|
50
|
-
#
|
51
45
|
# Connects to a given Tokyo Tyrant server.
|
52
46
|
#
|
53
47
|
# Note that if the port is not specified, the host parameter is expected
|
@@ -89,14 +83,12 @@ module Rufus::Tokyo
|
|
89
83
|
end
|
90
84
|
end
|
91
85
|
|
92
|
-
#
|
93
86
|
# Using the tyrant lib
|
94
87
|
#
|
95
88
|
def lib
|
96
89
|
TyrantLib
|
97
90
|
end
|
98
91
|
|
99
|
-
#
|
100
92
|
# isn't that a bit dangerous ? it creates a file on the server...
|
101
93
|
#
|
102
94
|
# DISABLED.
|
@@ -106,6 +98,22 @@ module Rufus::Tokyo
|
|
106
98
|
raise 'not allowed to create files on the server'
|
107
99
|
end
|
108
100
|
|
101
|
+
# Calls a lua embedded function
|
102
|
+
# (http://tokyocabinet.sourceforge.net/tyrantdoc/#luaext)
|
103
|
+
#
|
104
|
+
# Options are :global_locking and :record_locking
|
105
|
+
#
|
106
|
+
# Returns the return value of the called function.
|
107
|
+
#
|
108
|
+
# Nil is returned in case of failure.
|
109
|
+
#
|
110
|
+
def ext (func_name, key, value, opts={})
|
111
|
+
|
112
|
+
lib.tcrdbext2(
|
113
|
+
@db, func_name.to_s, compute_ext_opts(opts), key.to_s, value.to_s
|
114
|
+
) rescue nil
|
115
|
+
end
|
116
|
+
|
109
117
|
protected
|
110
118
|
|
111
119
|
def do_call_misc (function, list_pointer)
|
@@ -114,10 +122,10 @@ module Rufus::Tokyo
|
|
114
122
|
# opts always to 0 for now
|
115
123
|
end
|
116
124
|
|
117
|
-
#
|
118
125
|
# Returns the raw stat string from the Tyrant server.
|
119
126
|
#
|
120
127
|
def do_stat
|
128
|
+
|
121
129
|
lib.tcrdbstat(@db)
|
122
130
|
end
|
123
131
|
end
|
@@ -43,11 +43,18 @@ module Rufus::Tokyo
|
|
43
43
|
/usr/local/lib/libtokyotyrant.so
|
44
44
|
})
|
45
45
|
|
46
|
-
|
46
|
+
begin
|
47
|
+
|
48
|
+
ffi_lib(*paths)
|
47
49
|
|
48
|
-
|
50
|
+
rescue LoadError => le
|
51
|
+
raise(
|
52
|
+
"didn't find Tokyo Tyrant libs on your system. " +
|
53
|
+
"Please install Tokyo Tyrant (http://tokyocabinet.sf.net) " +
|
54
|
+
"(see also http://openwferu.rubyforge.org/tokyo.html)"
|
55
|
+
)
|
56
|
+
end
|
49
57
|
|
50
|
-
ffi_lib(path)
|
51
58
|
|
52
59
|
class << self
|
53
60
|
alias :attfunc :attach_function
|
@@ -83,6 +90,8 @@ module Rufus::Tokyo
|
|
83
90
|
attfunc :abs_fwmkeys2, :tcrdbfwmkeys2, [ :pointer, :string, :int ], :pointer
|
84
91
|
attfunc :tcrdbmisc, [ :pointer, :string, :int, :pointer ], :pointer
|
85
92
|
|
93
|
+
attfunc :tcrdbext2, [ :pointer, :string, :int, :string, :string ], :string
|
94
|
+
|
86
95
|
#
|
87
96
|
# table functions
|
88
97
|
|
@@ -128,5 +137,10 @@ module Rufus::Tokyo
|
|
128
137
|
end
|
129
138
|
|
130
139
|
attfunc :qry_search, :tcrdbqrysearch, [ :pointer ], :pointer
|
140
|
+
|
141
|
+
begin # since TC 1.4.21
|
142
|
+
attfunc :qry_count, :tcrdbqrysearchcount, [ :pointer ], :int
|
143
|
+
rescue FFI::NotFoundError => nfe
|
144
|
+
end
|
131
145
|
end
|
132
146
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,16 +18,12 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
|
-
require 'rufus/tokyo/
|
26
|
+
require 'rufus/tokyo/ttcommons'
|
32
27
|
|
33
28
|
|
34
29
|
module Rufus::Tokyo
|
@@ -47,7 +42,7 @@ module Rufus::Tokyo
|
|
47
42
|
#
|
48
43
|
class TyrantTable < Table
|
49
44
|
|
50
|
-
include
|
45
|
+
include TyrantCommons
|
51
46
|
|
52
47
|
|
53
48
|
attr_reader :host, :port
|
data/lib/rufus/tokyo/tyrant.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
4
3
|
#
|
@@ -19,14 +18,10 @@
|
|
19
18
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
20
|
# THE SOFTWARE.
|
22
|
-
#++
|
23
21
|
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
24
|
|
25
|
-
#
|
26
|
-
# "made in Japan"
|
27
|
-
#
|
28
|
-
# jmettraux@gmail.com
|
29
|
-
#
|
30
25
|
|
31
26
|
require 'rufus/tokyo'
|
32
27
|
|
data/lib/rufus/tokyo.rb
CHANGED
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.12
|
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-04-07 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,8 +52,8 @@ files:
|
|
52
52
|
- lib/rufus/tokyo/dystopia.rb
|
53
53
|
- lib/rufus/tokyo/hmethods.rb
|
54
54
|
- lib/rufus/tokyo/query.rb
|
55
|
-
- lib/rufus/tokyo/stats.rb
|
56
55
|
- lib/rufus/tokyo/transactions.rb
|
56
|
+
- lib/rufus/tokyo/ttcommons.rb
|
57
57
|
- lib/rufus/tokyo/tyrant/abstract.rb
|
58
58
|
- lib/rufus/tokyo/tyrant/lib.rb
|
59
59
|
- lib/rufus/tokyo/tyrant/table.rb
|