rufus-tokyo 0.1.14 → 1.0.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.
- data/CHANGELOG.txt +9 -0
- data/CREDITS.txt +10 -1
- data/README.rdoc +9 -11
- data/TODO.txt +17 -5
- data/lib/rufus/edo/cabcore.rb +29 -6
- data/lib/rufus/edo/ntyrant/abstract.rb +1 -1
- data/lib/rufus/edo/ntyrant/table.rb +14 -0
- data/lib/rufus/edo/tabcore.rb +45 -18
- data/lib/rufus/tokyo.rb +1 -1
- data/lib/rufus/tokyo/cabinet/abstract.rb +33 -32
- data/lib/rufus/tokyo/cabinet/lib.rb +12 -17
- data/lib/rufus/tokyo/cabinet/table.rb +53 -20
- data/lib/rufus/tokyo/dystopia.rb +10 -7
- data/lib/rufus/tokyo/dystopia/core.rb +198 -0
- data/lib/rufus/tokyo/dystopia/lib.rb +65 -3
- data/lib/rufus/tokyo/dystopia/words.rb +1 -1
- data/lib/rufus/tokyo/outlen.rb +46 -0
- data/lib/rufus/tokyo/query.rb +9 -1
- data/lib/rufus/tokyo/tyrant/abstract.rb +4 -26
- data/lib/rufus/tokyo/tyrant/ext.rb +52 -0
- data/lib/rufus/tokyo/tyrant/lib.rb +6 -6
- data/lib/rufus/tokyo/tyrant/table.rb +3 -1
- data/lib/rufus/tokyo/utils.rb +44 -0
- data/spec/spec.rb +3 -1
- metadata +6 -2
@@ -0,0 +1,52 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009, Adam Keys, John Mettraux
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
module Rufus::Tokyo
|
27
|
+
|
28
|
+
module Ext
|
29
|
+
|
30
|
+
# Calls a lua embedded function
|
31
|
+
# (http://tokyocabinet.sourceforge.net/tyrantdoc/#luaext)
|
32
|
+
#
|
33
|
+
# Options are :global_locking and :record_locking
|
34
|
+
#
|
35
|
+
# Returns the return value of the called function.
|
36
|
+
#
|
37
|
+
# Nil is returned in case of failure.
|
38
|
+
#
|
39
|
+
def ext (func_name, key='', value='', opts={})
|
40
|
+
|
41
|
+
k = key.to_s
|
42
|
+
v = value.to_s
|
43
|
+
|
44
|
+
outlen_op(
|
45
|
+
:tcrdbext,
|
46
|
+
func_name.to_s,
|
47
|
+
compute_ext_opts(opts),
|
48
|
+
k, Rufus::Tokyo.blen(k),
|
49
|
+
v, Rufus::Tokyo.blen(v))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -35,13 +35,14 @@ module Rufus::Tokyo
|
|
35
35
|
#
|
36
36
|
# find Tokyo Tyrant lib
|
37
37
|
|
38
|
-
paths = Array(ENV['TOKYO_TYRANT_LIB'] || %w
|
38
|
+
paths = Array(ENV['TOKYO_TYRANT_LIB'] || %w[
|
39
39
|
/usr/lib/libtokyotyrant.so
|
40
|
+
/usr/lib64/libtokyotyrant.so
|
40
41
|
/opt/local/lib/libtokyotyrant.dylib
|
41
42
|
/opt/local/lib/libtokyotyrant.so
|
42
43
|
/usr/local/lib/libtokyotyrant.dylib
|
43
44
|
/usr/local/lib/libtokyotyrant.so
|
44
|
-
|
45
|
+
])
|
45
46
|
|
46
47
|
begin
|
47
48
|
|
@@ -145,9 +146,8 @@ module Rufus::Tokyo
|
|
145
146
|
attfunc :qry_search, :tcrdbqrysearch, [ :pointer ], :pointer
|
146
147
|
attfunc :qry_searchout, :tcrdbqrysearchout, [ :pointer ], :int
|
147
148
|
|
148
|
-
|
149
|
-
|
150
|
-
rescue FFI::NotFoundError => nfe
|
151
|
-
end
|
149
|
+
# since TC 1.4.21
|
150
|
+
attfunc :qry_count, :tcrdbqrysearchcount, [ :pointer ], :int
|
152
151
|
end
|
153
152
|
end
|
153
|
+
|
@@ -43,6 +43,8 @@ module Rufus::Tokyo
|
|
43
43
|
class TyrantTable < Table
|
44
44
|
|
45
45
|
include TyrantCommons
|
46
|
+
include Outlen
|
47
|
+
include Ext
|
46
48
|
|
47
49
|
|
48
50
|
attr_reader :host, :port
|
@@ -81,7 +83,7 @@ module Rufus::Tokyo
|
|
81
83
|
@port = port
|
82
84
|
|
83
85
|
(lib.tcrdbopen(@db, host, port) == 1) ||
|
84
|
-
raise("couldn't connect to tyrant at #{host}:#{port}")
|
86
|
+
raise(TokyoError.new("couldn't connect to tyrant at #{host}:#{port}"))
|
85
87
|
|
86
88
|
if self.stat['type'] != 'table'
|
87
89
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
module Rufus
|
26
|
+
module Tokyo
|
27
|
+
|
28
|
+
# Makes sure all the keys and the values in the given collection (Hash or
|
29
|
+
# Array) are turned into strings.
|
30
|
+
#
|
31
|
+
def self.h_or_a_to_s (c)
|
32
|
+
|
33
|
+
if c.is_a?(Hash)
|
34
|
+
c.inject({}) { |h, (k, v)| h[k.to_s] = v.to_s; h }
|
35
|
+
elsif c.is_a?(Array)
|
36
|
+
c.collect { |v| v.to_s }
|
37
|
+
else
|
38
|
+
raise(ArgumentError.new('expected Array or Hash instance'))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/spec/spec.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.
|
4
|
+
version: 1.0.0
|
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-07-23 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,17 +47,21 @@ files:
|
|
47
47
|
- lib/rufus/tokyo/cabinet/table.rb
|
48
48
|
- lib/rufus/tokyo/cabinet/util.rb
|
49
49
|
- lib/rufus/tokyo/config.rb
|
50
|
+
- lib/rufus/tokyo/dystopia/core.rb
|
50
51
|
- lib/rufus/tokyo/dystopia/lib.rb
|
51
52
|
- lib/rufus/tokyo/dystopia/words.rb
|
52
53
|
- lib/rufus/tokyo/dystopia.rb
|
53
54
|
- lib/rufus/tokyo/hmethods.rb
|
55
|
+
- lib/rufus/tokyo/outlen.rb
|
54
56
|
- lib/rufus/tokyo/query.rb
|
55
57
|
- lib/rufus/tokyo/transactions.rb
|
56
58
|
- lib/rufus/tokyo/ttcommons.rb
|
57
59
|
- lib/rufus/tokyo/tyrant/abstract.rb
|
60
|
+
- lib/rufus/tokyo/tyrant/ext.rb
|
58
61
|
- lib/rufus/tokyo/tyrant/lib.rb
|
59
62
|
- lib/rufus/tokyo/tyrant/table.rb
|
60
63
|
- lib/rufus/tokyo/tyrant.rb
|
64
|
+
- lib/rufus/tokyo/utils.rb
|
61
65
|
- lib/rufus/tokyo.rb
|
62
66
|
- lib/rufus-edo.rb
|
63
67
|
- lib/rufus-tokyo.rb
|