careo-tokyotyrant 1.3 → 1.3.0.1
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/lib/COPYING +504 -0
- data/lib/install.rb +37 -0
- data/lib/makedoc.sh +18 -0
- data/lib/overview.rd +141 -0
- data/lib/package.sh +15 -0
- data/lib/tcrtest.rb +918 -0
- data/lib/test.rb +27 -0
- data/lib/tokyotyrant.rb +1273 -0
- metadata +12 -3
data/lib/install.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
sitelibdir = Config::CONFIG.fetch("sitelibdir")
|
4
|
+
bindir = Config::CONFIG.fetch("bindir")
|
5
|
+
|
6
|
+
def copy(src, dest, mode)
|
7
|
+
p dest
|
8
|
+
open(src, "rb") do |infile|
|
9
|
+
open(dest, "wb") do |outfile|
|
10
|
+
while buf = infile.read(8192)
|
11
|
+
while buf.length > 0
|
12
|
+
wlen = outfile.write(buf)
|
13
|
+
buf = buf[wlen, buf.length]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
outfile.chmod(mode)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if ARGV.length > 0 && ARGV[0] == "uninstall"
|
22
|
+
printf("uninstalling the library from %s ... ", sitelibdir)
|
23
|
+
File.unlink("#{sitelibdir}/tokyotyrant.rb")
|
24
|
+
printf("ok\n")
|
25
|
+
printf("uninstalling the test command from %s ... ", bindir)
|
26
|
+
File.unlink("#{bindir}/tcrtest.rb")
|
27
|
+
printf("ok\n")
|
28
|
+
else
|
29
|
+
printf("installing the library into %s ... ", sitelibdir)
|
30
|
+
copy("tokyotyrant.rb", "#{sitelibdir}/tokyotyrant.rb", 0644)
|
31
|
+
printf("ok\n")
|
32
|
+
printf("installing the test command into %s ... ", bindir)
|
33
|
+
copy("tcrtest.rb", "#{bindir}/tcrtest.rb", 0755)
|
34
|
+
printf("ok\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
printf("done\n")
|
data/lib/makedoc.sh
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
|
3
|
+
LANG=C
|
4
|
+
LC_ALL=C
|
5
|
+
PATH="$PATH:/usr/local/bin:$HOME/bin:.:.."
|
6
|
+
export LANG LC_ALL PATH
|
7
|
+
|
8
|
+
rm -rf doc
|
9
|
+
|
10
|
+
rdoc --title "Tokyo Tyrant" -o doc tokyotyrant.rb
|
11
|
+
find doc -type f -name '*.html' |
|
12
|
+
while read file
|
13
|
+
do
|
14
|
+
fgrep -v '<a href="http://validator.w3.org/check/referer">[Validate]</a>' "$file" |
|
15
|
+
sed -e "s/’/'/g" -e 's/%%/<br\/>/g' > tmp.html
|
16
|
+
mv -f tmp.html "$file"
|
17
|
+
done
|
18
|
+
rm -f tmp.html
|
data/lib/overview.rd
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
= Pure Ruby Interface of Tokyo Tyrant
|
2
|
+
|
3
|
+
Tokyo Tyrant: network interface of Tokyo Cabinet
|
4
|
+
|
5
|
+
== INTRODUCTION
|
6
|
+
|
7
|
+
This module implements the pure Ruby client which connects to the server of Tokyo Tyrant and speaks its original binary protocol.
|
8
|
+
|
9
|
+
Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications.
|
10
|
+
|
11
|
+
The server features high concurrency due to thread-pool modeled implementation and the epoll/kqueue mechanism of the modern Linux/*BSD kernel. The server and its clients communicate with each other by simple binary protocol on TCP/IP. Protocols compatible with memcached and HTTP/1.1 are also supported so that almost all principal platforms and programming languages can use Tokyo Tyrant. High availability and high integrity are also featured due to such mechanisms as hot backup, update logging, and replication. The server can embed Lua, a lightweight script language so that you can define arbitrary operations of the database.
|
12
|
+
|
13
|
+
Because the server uses the abstract API of Tokyo Cabinet, all of the six APIs: the on-memory hash database API, the on-memory tree database API, the hash API, the B+ tree database API, the fixed-length database API, and the table database API, are available from the client with the common interface. Moreover, the table extension is provided to use specifidc features of the table database.
|
14
|
+
|
15
|
+
=== Setting
|
16
|
+
|
17
|
+
Get this package and extract it.
|
18
|
+
|
19
|
+
Enter the directory of the extracted package then perform installation.
|
20
|
+
|
21
|
+
su
|
22
|
+
ruby install.rb
|
23
|
+
|
24
|
+
The package `tokyotyrant' should be loaded in each source file of application programs.
|
25
|
+
|
26
|
+
require 'tokyotyrant'
|
27
|
+
|
28
|
+
All symbols of Tokyo Tyrant are defined in the module `TokyoTyrant'. You can access them without any prefix by including the module.
|
29
|
+
|
30
|
+
include TokyoTyrant
|
31
|
+
|
32
|
+
|
33
|
+
= EXAMPLE
|
34
|
+
|
35
|
+
The following code is an example to use a remote database.
|
36
|
+
|
37
|
+
require 'tokyotyrant'
|
38
|
+
include TokyoTyrant
|
39
|
+
|
40
|
+
# create the object
|
41
|
+
rdb = RDB::new
|
42
|
+
|
43
|
+
# connect to the server
|
44
|
+
if !rdb.open("localhost", 1978)
|
45
|
+
ecode = rdb.ecode
|
46
|
+
STDERR.printf("open error: %s\n", rdb.errmsg(ecode))
|
47
|
+
end
|
48
|
+
|
49
|
+
# store records
|
50
|
+
if !rdb.put("foo", "hop") ||
|
51
|
+
!rdb.put("bar", "step") ||
|
52
|
+
!rdb.put("baz", "jump")
|
53
|
+
ecode = rdb.ecode
|
54
|
+
STDERR.printf("put error: %s\n", rdb.errmsg(ecode))
|
55
|
+
end
|
56
|
+
|
57
|
+
# retrieve records
|
58
|
+
value = rdb.get("foo")
|
59
|
+
if value
|
60
|
+
printf("%s\n", value)
|
61
|
+
else
|
62
|
+
ecode = rdb.ecode
|
63
|
+
STDERR.printf("get error: %s\n", rdb.errmsg(ecode))
|
64
|
+
end
|
65
|
+
|
66
|
+
# traverse records
|
67
|
+
rdb.iterinit
|
68
|
+
while key = rdb.iternext
|
69
|
+
value = rdb.get(key)
|
70
|
+
if value
|
71
|
+
printf("%s:%s\n", key, value)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# hash-like usage
|
76
|
+
rdb["quux"] = "touchdown"
|
77
|
+
printf("%s\n", rdb["quux"])
|
78
|
+
rdb.each do |key, value|
|
79
|
+
printf("%s:%s\n", key, value)
|
80
|
+
end
|
81
|
+
|
82
|
+
# close the connection
|
83
|
+
if !rdb.close
|
84
|
+
ecode = rdb.ecode
|
85
|
+
STDERR.printf("close error: %s\n", rdb.errmsg(ecode))
|
86
|
+
end
|
87
|
+
|
88
|
+
The following code is an example to use a remote database with the table extension.
|
89
|
+
|
90
|
+
require 'tokyotyrant'
|
91
|
+
include TokyoTyrant
|
92
|
+
|
93
|
+
# create the object
|
94
|
+
rdb = RDBTBL::new
|
95
|
+
|
96
|
+
# connect to the server
|
97
|
+
if !rdb.open("localhost", 1978)
|
98
|
+
ecode = rdb.ecode
|
99
|
+
STDERR.printf("open error: %s\n", rdb.errmsg(ecode))
|
100
|
+
end
|
101
|
+
|
102
|
+
# store a record
|
103
|
+
pkey = rdb.genuid
|
104
|
+
cols = { "name" => "mikio", "age" => "30", "lang" => "ja,en,c" }
|
105
|
+
if !rdb.put(pkey, cols)
|
106
|
+
ecode = rdb.ecode
|
107
|
+
STDERR.printf("put error: %s\n", rdb.errmsg(ecode))
|
108
|
+
end
|
109
|
+
|
110
|
+
# store another record
|
111
|
+
cols = { "name" => "falcon", "age" => "31", "lang" => "ja", "skill" => "cook,blog" }
|
112
|
+
if !rdb.put("x12345", cols)
|
113
|
+
ecode = rdb.ecode
|
114
|
+
STDERR.printf("put error: %s\n", rdb.errmsg(ecode))
|
115
|
+
end
|
116
|
+
|
117
|
+
# search for records
|
118
|
+
qry = RDBQRY::new(rdb)
|
119
|
+
qry.addcond("age", RDBQRY::QCNUMGE, "20")
|
120
|
+
qry.addcond("lang", RDBQRY::QCSTROR, "ja,en")
|
121
|
+
qry.setorder("name", RDBQRY::QOSTRASC)
|
122
|
+
qry.setmax(10)
|
123
|
+
res = qry.search
|
124
|
+
res.each do |rkey|
|
125
|
+
rcols = rdb.get(rkey)
|
126
|
+
printf("name:%s\n", rcols["name"])
|
127
|
+
end
|
128
|
+
|
129
|
+
# close the connection
|
130
|
+
if !rdb.close
|
131
|
+
ecode = rdb.ecode
|
132
|
+
STDERR.printf("close error: %s\n", rdb.errmsg(ecode))
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
== LICENSE
|
137
|
+
|
138
|
+
Copyright (C) 2006-2008 Mikio Hirabayashi
|
139
|
+
All rights reserved.
|
140
|
+
|
141
|
+
Tokyo Tyrant is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version. Tokyo Tyrant is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tokyo Tyrant; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
data/lib/package.sh
ADDED
data/lib/tcrtest.rb
ADDED
@@ -0,0 +1,918 @@
|
|
1
|
+
#! /usr/bin/ruby -w
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------------------------------
|
4
|
+
# The test cases of the remote database API
|
5
|
+
# Copyright (C) 2006-2008 Mikio Hirabayashi
|
6
|
+
# This file is part of Tokyo Tyrant.
|
7
|
+
# Tokyo Tyrant is free software; you can redistribute it and/or modify it under the terms of
|
8
|
+
# the GNU Lesser General Public License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License or any later version. Tokyo Tyrant is distributed in the hope
|
10
|
+
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
12
|
+
# License for more details.
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License along with Tokyo
|
14
|
+
# Tyrant; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
15
|
+
# Boston, MA 02111-1307 USA.
|
16
|
+
#-------------------------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
|
19
|
+
require 'tokyotyrant'
|
20
|
+
include TokyoTyrant
|
21
|
+
|
22
|
+
|
23
|
+
# main routine
|
24
|
+
def main
|
25
|
+
ARGV.length >= 1 || usage
|
26
|
+
if ARGV[0] == "write"
|
27
|
+
rv = runwrite
|
28
|
+
elsif ARGV[0] == "read"
|
29
|
+
rv = runread
|
30
|
+
elsif ARGV[0] == "remove"
|
31
|
+
rv = runremove
|
32
|
+
elsif ARGV[0] == "rcat"
|
33
|
+
rv = runrcat
|
34
|
+
elsif ARGV[0] == "misc"
|
35
|
+
rv = runmisc
|
36
|
+
elsif ARGV[0] == "table"
|
37
|
+
rv = runtable
|
38
|
+
else
|
39
|
+
usage
|
40
|
+
end
|
41
|
+
GC.start
|
42
|
+
return rv
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# print the usage and exit
|
47
|
+
def usage
|
48
|
+
STDERR.printf("%s: test cases of the remote database API\n", $progname)
|
49
|
+
STDERR.printf("\n")
|
50
|
+
STDERR.printf("usage:\n")
|
51
|
+
STDERR.printf(" %s write [-port num] [-nr] [-rnd] host rnum\n", $progname)
|
52
|
+
STDERR.printf(" %s read [-port num] [-mul num] [-rnd] host rnum\n", $progname)
|
53
|
+
STDERR.printf(" %s remove [-port num] [-rnd] host rnum\n", $progname)
|
54
|
+
STDERR.printf(" %s rcat [-port num] [-shl num] [-dai|-dad] [-ext name] [-xlg|-xlr]" +
|
55
|
+
" host rnum\n", $progname)
|
56
|
+
STDERR.printf(" %s misc [-port num] host rnum\n", $progname)
|
57
|
+
STDERR.printf(" %s table [-port num] host rnum\n", $progname)
|
58
|
+
STDERR.printf("\n")
|
59
|
+
exit(1)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
# print error message of remote database
|
64
|
+
def eprint(rdb, func)
|
65
|
+
ecode = rdb.ecode
|
66
|
+
STDERR.printf("%s: %s: error: %d: %s\n", $progname, func, ecode, rdb.errmsg(ecode))
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# parse arguments of write command
|
71
|
+
def runwrite
|
72
|
+
host = nil
|
73
|
+
rnum = nil
|
74
|
+
port = 1978
|
75
|
+
nr = false
|
76
|
+
rnd = false
|
77
|
+
i = 1
|
78
|
+
while i < ARGV.length
|
79
|
+
if !host && ARGV[i] =~ /^-/
|
80
|
+
if ARGV[i] == "-port"
|
81
|
+
usage if (i += 1) >= ARGV.length
|
82
|
+
port = ARGV[i].to_i
|
83
|
+
elsif ARGV[i] == "-nr"
|
84
|
+
nr = true
|
85
|
+
elsif ARGV[i] == "-rnd"
|
86
|
+
rnd = true
|
87
|
+
else
|
88
|
+
usage
|
89
|
+
end
|
90
|
+
elsif !host
|
91
|
+
host = ARGV[i]
|
92
|
+
elsif !rnum
|
93
|
+
rnum = ARGV[i].to_i
|
94
|
+
else
|
95
|
+
usage
|
96
|
+
end
|
97
|
+
i += 1
|
98
|
+
end
|
99
|
+
usage if !host || !rnum || rnum < 1
|
100
|
+
rv = procwrite(host, port, rnum, nr, rnd)
|
101
|
+
return rv
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# parse arguments of read command
|
106
|
+
def runread
|
107
|
+
host = nil
|
108
|
+
port = 1978
|
109
|
+
mul = 0
|
110
|
+
rnd = false
|
111
|
+
i = 1
|
112
|
+
while i < ARGV.length
|
113
|
+
if !host && ARGV[i] =~ /^-/
|
114
|
+
if ARGV[i] == "-port"
|
115
|
+
usage if (i += 1) >= ARGV.length
|
116
|
+
port = ARGV[i].to_i
|
117
|
+
elsif ARGV[i] == "-mul"
|
118
|
+
usage if (i += 1) >= ARGV.length
|
119
|
+
mul = ARGV[i].to_i
|
120
|
+
elsif ARGV[i] == "-rnd"
|
121
|
+
rnd = true
|
122
|
+
else
|
123
|
+
usage
|
124
|
+
end
|
125
|
+
elsif !host
|
126
|
+
host = ARGV[i]
|
127
|
+
else
|
128
|
+
usage
|
129
|
+
end
|
130
|
+
i += 1
|
131
|
+
end
|
132
|
+
usage if !host
|
133
|
+
rv = procread(host, port, mul, rnd)
|
134
|
+
return rv
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# parse arguments of remove command
|
139
|
+
def runremove
|
140
|
+
host = nil
|
141
|
+
port = 1978
|
142
|
+
rnd = false
|
143
|
+
i = 1
|
144
|
+
while i < ARGV.length
|
145
|
+
if !host && ARGV[i] =~ /^-/
|
146
|
+
if ARGV[i] == "-port"
|
147
|
+
usage if (i += 1) >= ARGV.length
|
148
|
+
port = ARGV[i].to_i
|
149
|
+
elsif ARGV[i] == "-rnd"
|
150
|
+
rnd = true
|
151
|
+
else
|
152
|
+
usage
|
153
|
+
end
|
154
|
+
elsif !host
|
155
|
+
host = ARGV[i]
|
156
|
+
else
|
157
|
+
usage
|
158
|
+
end
|
159
|
+
i += 1
|
160
|
+
end
|
161
|
+
usage if !host
|
162
|
+
rv = procremove(host, port, rnd)
|
163
|
+
return rv
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
# parse arguments of rcat command
|
168
|
+
def runrcat
|
169
|
+
host = nil
|
170
|
+
rnum = nil
|
171
|
+
port = 1978
|
172
|
+
shl = 0
|
173
|
+
dai = false
|
174
|
+
dad = false
|
175
|
+
ext = nil
|
176
|
+
xopts = 0
|
177
|
+
i = 1
|
178
|
+
while i < ARGV.length
|
179
|
+
if !host && ARGV[i] =~ /^-/
|
180
|
+
if ARGV[i] == "-port"
|
181
|
+
usage if (i += 1) >= ARGV.length
|
182
|
+
port = ARGV[i].to_i
|
183
|
+
elsif ARGV[i] == "-shl"
|
184
|
+
usage if (i += 1) >= ARGV.length
|
185
|
+
shl = ARGV[i].to_i
|
186
|
+
elsif ARGV[i] == "-dai"
|
187
|
+
dai = true
|
188
|
+
elsif ARGV[i] == "-dad"
|
189
|
+
dad = true
|
190
|
+
elsif ARGV[i] == "-ext"
|
191
|
+
usage if (i += 1) >= ARGV.length
|
192
|
+
ext = ARGV[i]
|
193
|
+
elsif ARGV[i] == "-xlr"
|
194
|
+
xopts |= RDB::XOLCKREC
|
195
|
+
elsif ARGV[i] == "-xlg"
|
196
|
+
xopts |= RDB::XOLCKGLB
|
197
|
+
else
|
198
|
+
usage
|
199
|
+
end
|
200
|
+
elsif !host
|
201
|
+
host = ARGV[i]
|
202
|
+
elsif !rnum
|
203
|
+
rnum = ARGV[i].to_i
|
204
|
+
else
|
205
|
+
usage
|
206
|
+
end
|
207
|
+
i += 1
|
208
|
+
end
|
209
|
+
usage if !host || !rnum || rnum < 1
|
210
|
+
rv = procrcat(host, port, rnum, shl, dai, dad, ext, xopts)
|
211
|
+
return rv
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
# parse arguments of misc command
|
216
|
+
def runmisc
|
217
|
+
host = nil
|
218
|
+
rnum = nil
|
219
|
+
port = 1978
|
220
|
+
i = 1
|
221
|
+
while i < ARGV.length
|
222
|
+
if !host && ARGV[i] =~ /^-/
|
223
|
+
if ARGV[i] == "-port"
|
224
|
+
usage if (i += 1) >= ARGV.length
|
225
|
+
port = ARGV[i].to_i
|
226
|
+
else
|
227
|
+
usage
|
228
|
+
end
|
229
|
+
elsif !host
|
230
|
+
host = ARGV[i]
|
231
|
+
elsif !rnum
|
232
|
+
rnum = ARGV[i].to_i
|
233
|
+
else
|
234
|
+
usage
|
235
|
+
end
|
236
|
+
i += 1
|
237
|
+
end
|
238
|
+
usage if !host || !rnum || rnum < 1
|
239
|
+
rv = procmisc(host, port, rnum)
|
240
|
+
return rv
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
# parse arguments of table command
|
245
|
+
def runtable
|
246
|
+
host = nil
|
247
|
+
rnum = nil
|
248
|
+
port = 1978
|
249
|
+
i = 1
|
250
|
+
while i < ARGV.length
|
251
|
+
if !host && ARGV[i] =~ /^-/
|
252
|
+
if ARGV[i] == "-port"
|
253
|
+
usage if (i += 1) >= ARGV.length
|
254
|
+
port = ARGV[i].to_i
|
255
|
+
else
|
256
|
+
usage
|
257
|
+
end
|
258
|
+
elsif !host
|
259
|
+
host = ARGV[i]
|
260
|
+
elsif !rnum
|
261
|
+
rnum = ARGV[i].to_i
|
262
|
+
else
|
263
|
+
usage
|
264
|
+
end
|
265
|
+
i += 1
|
266
|
+
end
|
267
|
+
usage if !host || !rnum || rnum < 1
|
268
|
+
rv = proctable(host, port, rnum)
|
269
|
+
return rv
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
# perform write command
|
274
|
+
def procwrite(host, port, rnum, nr, rnd)
|
275
|
+
printf("<Writing Test>\n host=%s port=%d rnum=%d nr=%s rnd=%s\n\n",
|
276
|
+
host, port, rnum, nr, rnd)
|
277
|
+
err = false
|
278
|
+
stime = Time.now
|
279
|
+
rdb = RDB::new
|
280
|
+
if !rdb.open(host, port)
|
281
|
+
eprint(rdb, "open")
|
282
|
+
err = true
|
283
|
+
end
|
284
|
+
if !rnd && !rdb.vanish
|
285
|
+
eprint(rdb, "vanish")
|
286
|
+
err = true
|
287
|
+
end
|
288
|
+
for i in 1..rnum
|
289
|
+
buf = sprintf("%08d", rnd ? rand(rnum) + 1: i)
|
290
|
+
if nr
|
291
|
+
if !rdb.putnr(buf, buf)
|
292
|
+
eprint(rdb, "putnr")
|
293
|
+
err = true
|
294
|
+
break
|
295
|
+
end
|
296
|
+
else
|
297
|
+
if !rdb.put(buf, buf)
|
298
|
+
eprint(rdb, "put")
|
299
|
+
err = true
|
300
|
+
break
|
301
|
+
end
|
302
|
+
end
|
303
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
304
|
+
print('.')
|
305
|
+
if i == rnum || i % (rnum / 10) == 0
|
306
|
+
printf(" (%08d)\n", i)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
printf("record number: %d\n", rdb.rnum)
|
311
|
+
printf("size: %d\n", rdb.size)
|
312
|
+
if !rdb.close
|
313
|
+
eprint(rdb, "close")
|
314
|
+
err = true
|
315
|
+
end
|
316
|
+
printf("time: %.3f\n", Time.now - stime)
|
317
|
+
printf("%s\n\n", err ? "error" : "ok")
|
318
|
+
return err ? 1 : 0
|
319
|
+
end
|
320
|
+
|
321
|
+
|
322
|
+
# perform read command
|
323
|
+
def procread(host, port, mul, rnd)
|
324
|
+
printf("<Reading Test>\n host=%s port=%d mul=%d rnd=%s\n\n", host, port, mul, rnd)
|
325
|
+
err = false
|
326
|
+
stime = Time.now
|
327
|
+
rdb = RDB::new
|
328
|
+
if !rdb.open(host, port)
|
329
|
+
eprint(rdb, "open")
|
330
|
+
err = true
|
331
|
+
end
|
332
|
+
recs = Hash.new
|
333
|
+
rnum = rdb.rnum
|
334
|
+
for i in 1..rnum
|
335
|
+
buf = sprintf("%08d", rnd ? rand(rnum) + 1: i)
|
336
|
+
if mul > 1
|
337
|
+
recs[buf] = ""
|
338
|
+
if i % mul == 0
|
339
|
+
if rdb.mget(recs) < 0
|
340
|
+
eprint(rdb, "mget")
|
341
|
+
err = true
|
342
|
+
break
|
343
|
+
end
|
344
|
+
recs.clear
|
345
|
+
end
|
346
|
+
else
|
347
|
+
if !rdb.get(buf) && !rnd
|
348
|
+
eprint(rdb, "get")
|
349
|
+
err = true
|
350
|
+
break
|
351
|
+
end
|
352
|
+
end
|
353
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
354
|
+
print('.')
|
355
|
+
if i == rnum || i % (rnum / 10) == 0
|
356
|
+
printf(" (%08d)\n", i)
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
printf("record number: %d\n", rdb.rnum)
|
361
|
+
printf("size: %d\n", rdb.size)
|
362
|
+
if !rdb.close
|
363
|
+
eprint(rdb, "close")
|
364
|
+
err = true
|
365
|
+
end
|
366
|
+
printf("time: %.3f\n", Time.now - stime)
|
367
|
+
printf("%s\n\n", err ? "error" : "ok")
|
368
|
+
return err ? 1 : 0
|
369
|
+
end
|
370
|
+
|
371
|
+
|
372
|
+
# perform remove command
|
373
|
+
def procremove(host, port, rnd)
|
374
|
+
printf("<Removing Test>\n host=%s port=%d rnd=%s\n\n", host, port, rnd)
|
375
|
+
err = false
|
376
|
+
stime = Time.now
|
377
|
+
rdb = RDB::new
|
378
|
+
if !rdb.open(host, port)
|
379
|
+
eprint(rdb, "open")
|
380
|
+
err = true
|
381
|
+
end
|
382
|
+
rnum = rdb.rnum
|
383
|
+
for i in 1..rnum
|
384
|
+
buf = sprintf("%08d", rnd ? rand(rnum) + 1: i)
|
385
|
+
if !rdb.out(buf) && !rnd
|
386
|
+
eprint(rdb, "out")
|
387
|
+
err = true
|
388
|
+
break
|
389
|
+
end
|
390
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
391
|
+
print('.')
|
392
|
+
if i == rnum || i % (rnum / 10) == 0
|
393
|
+
printf(" (%08d)\n", i)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
printf("record number: %d\n", rdb.rnum)
|
398
|
+
printf("size: %d\n", rdb.size)
|
399
|
+
if !rdb.close
|
400
|
+
eprint(rdb, "close")
|
401
|
+
err = true
|
402
|
+
end
|
403
|
+
printf("time: %.3f\n", Time.now - stime)
|
404
|
+
printf("%s\n\n", err ? "error" : "ok")
|
405
|
+
return err ? 1 : 0
|
406
|
+
end
|
407
|
+
|
408
|
+
|
409
|
+
# perform rcat command
|
410
|
+
def procrcat(host, port, rnum, shl, dai, dad, ext, xopts)
|
411
|
+
printf("<Random Concatenating Test>\n host=%s port=%d rnum=%d shl=%d dai=%s dad=%s" +
|
412
|
+
" ext=%s xopts=%d\n\n", host, port, rnum, shl, dai, dad, ext ? ext : "", xopts)
|
413
|
+
err = false
|
414
|
+
stime = Time.now
|
415
|
+
rdb = RDB::new
|
416
|
+
if !rdb.open(host, port)
|
417
|
+
eprint(rdb, "open")
|
418
|
+
err = true
|
419
|
+
end
|
420
|
+
if !rdb.vanish
|
421
|
+
eprint(rdb, "vanish")
|
422
|
+
err = true
|
423
|
+
end
|
424
|
+
for i in 1..rnum
|
425
|
+
buf = sprintf("%08d", rand(rnum) + 1)
|
426
|
+
if shl > 0
|
427
|
+
if !rdb.putshl(buf, buf, shl)
|
428
|
+
eprint(rdb, "putshl")
|
429
|
+
err = true
|
430
|
+
break
|
431
|
+
end
|
432
|
+
elsif dai
|
433
|
+
if !rdb.addint(buf, 1)
|
434
|
+
eprint(rdb, "addint")
|
435
|
+
err = true
|
436
|
+
break
|
437
|
+
end
|
438
|
+
elsif dad
|
439
|
+
if !rdb.adddouble(buf, 1.0)
|
440
|
+
eprint(rdb, "adddouble")
|
441
|
+
err = true
|
442
|
+
break
|
443
|
+
end
|
444
|
+
elsif ext
|
445
|
+
if !rdb.ext(ext, buf, buf, xopts) && rdb.ecode != RDB::EMISC
|
446
|
+
eprint(rdb, "ext")
|
447
|
+
err = true
|
448
|
+
break
|
449
|
+
end
|
450
|
+
else
|
451
|
+
if !rdb.putcat(buf, buf)
|
452
|
+
eprint(rdb, "putcat")
|
453
|
+
err = true
|
454
|
+
break
|
455
|
+
end
|
456
|
+
end
|
457
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
458
|
+
print('.')
|
459
|
+
if i == rnum || i % (rnum / 10) == 0
|
460
|
+
printf(" (%08d)\n", i)
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
printf("record number: %d\n", rdb.rnum)
|
465
|
+
printf("size: %d\n", rdb.size)
|
466
|
+
if !rdb.close
|
467
|
+
eprint(rdb, "close")
|
468
|
+
err = true
|
469
|
+
end
|
470
|
+
printf("time: %.3f\n", Time.now - stime)
|
471
|
+
printf("%s\n\n", err ? "error" : "ok")
|
472
|
+
return err ? 1 : 0
|
473
|
+
end
|
474
|
+
|
475
|
+
|
476
|
+
# perform misc command
|
477
|
+
def procmisc(host, port, rnum)
|
478
|
+
printf("<Miscellaneous Test>\n host=%s port=%d rnum=%d\n\n", host, port, rnum)
|
479
|
+
err = false
|
480
|
+
stime = Time.now
|
481
|
+
rdb = RDB::new
|
482
|
+
if !rdb.open(host, port)
|
483
|
+
eprint(rdb, "open")
|
484
|
+
err = true
|
485
|
+
end
|
486
|
+
if !rdb.vanish
|
487
|
+
eprint(rdb, "vanish")
|
488
|
+
err = true
|
489
|
+
end
|
490
|
+
printf("writing:\n")
|
491
|
+
for i in 1..rnum
|
492
|
+
buf = sprintf("%08d", i)
|
493
|
+
if rand(10) > 0
|
494
|
+
if !rdb.putkeep(buf, buf)
|
495
|
+
eprint(rdb, "putkeep")
|
496
|
+
err = true
|
497
|
+
break
|
498
|
+
end
|
499
|
+
else
|
500
|
+
if !rdb.putnr(buf, buf)
|
501
|
+
eprint(rdb, "putnr")
|
502
|
+
err = true
|
503
|
+
break
|
504
|
+
end
|
505
|
+
end
|
506
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
507
|
+
print('.')
|
508
|
+
if i == rnum || i % (rnum / 10) == 0
|
509
|
+
printf(" (%08d)\n", i)
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
printf("reading:\n")
|
514
|
+
for i in 1..rnum
|
515
|
+
kbuf = sprintf("%08d", i)
|
516
|
+
vbuf = rdb.get(kbuf)
|
517
|
+
if !vbuf
|
518
|
+
eprint(rdb, "get")
|
519
|
+
err = true
|
520
|
+
break
|
521
|
+
end
|
522
|
+
if vbuf != kbuf
|
523
|
+
eprint(rdb, "(validation)")
|
524
|
+
err = true
|
525
|
+
break
|
526
|
+
end
|
527
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
528
|
+
print('.')
|
529
|
+
if i == rnum || i % (rnum / 10) == 0
|
530
|
+
printf(" (%08d)\n", i)
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|
534
|
+
if rdb.rnum != rnum
|
535
|
+
eprint(rdb, "rnum")
|
536
|
+
err = true
|
537
|
+
end
|
538
|
+
printf("random writing:\n")
|
539
|
+
for i in 1..rnum
|
540
|
+
kbuf = sprintf("%08d", rand(rnum) + 1)
|
541
|
+
vbuf = "*" * rand(32)
|
542
|
+
if !rdb.put(kbuf, vbuf)
|
543
|
+
eprint(rdb, "put")
|
544
|
+
err = true
|
545
|
+
break
|
546
|
+
end
|
547
|
+
rbuf = rdb.get(kbuf)
|
548
|
+
if !rbuf
|
549
|
+
eprint(rdb, "get")
|
550
|
+
err = true
|
551
|
+
break
|
552
|
+
end
|
553
|
+
if rbuf != vbuf
|
554
|
+
eprint(rdb, "(validation)")
|
555
|
+
err = true
|
556
|
+
break
|
557
|
+
end
|
558
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
559
|
+
print('.')
|
560
|
+
if i == rnum || i % (rnum / 10) == 0
|
561
|
+
printf(" (%08d)\n", i)
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|
565
|
+
printf("random erasing:\n")
|
566
|
+
for i in 1..rnum
|
567
|
+
kbuf = sprintf("%08d", rand(rnum) + 1)
|
568
|
+
if !rdb.out(kbuf) && rdb.ecode != RDB::ENOREC
|
569
|
+
eprint(rdb, "out")
|
570
|
+
err = true
|
571
|
+
break
|
572
|
+
end
|
573
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
574
|
+
print('.')
|
575
|
+
if i == rnum || i % (rnum / 10) == 0
|
576
|
+
printf(" (%08d)\n", i)
|
577
|
+
end
|
578
|
+
end
|
579
|
+
end
|
580
|
+
printf("script extension calling:\n")
|
581
|
+
for i in 1..rnum
|
582
|
+
buf = sprintf("(%d)", rand(rnum) + 1)
|
583
|
+
name = "put"
|
584
|
+
case rand(7)
|
585
|
+
when 1
|
586
|
+
name = "putkeep"
|
587
|
+
when 2
|
588
|
+
name = "putcat"
|
589
|
+
when 3
|
590
|
+
name = "out"
|
591
|
+
when 4
|
592
|
+
name = "get"
|
593
|
+
when 5
|
594
|
+
name = "iterinit"
|
595
|
+
when 6
|
596
|
+
name = "iternext"
|
597
|
+
end
|
598
|
+
xbuf = rdb.ext(name, buf, buf)
|
599
|
+
if !xbuf && rdb.ecode != RDB::EMISC
|
600
|
+
eprint(rdb, "ext")
|
601
|
+
err = true
|
602
|
+
break
|
603
|
+
end
|
604
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
605
|
+
print('.')
|
606
|
+
if i == rnum || i % (rnum / 10) == 0
|
607
|
+
printf(" (%08d)\n", i)
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
printf("checking iterator:\n")
|
612
|
+
if !rdb.iterinit
|
613
|
+
eprint(rdb, "iterinit")
|
614
|
+
err = true
|
615
|
+
end
|
616
|
+
inum = 0
|
617
|
+
while key = rdb.iternext
|
618
|
+
inum += 1
|
619
|
+
value = rdb.get(key)
|
620
|
+
if !value
|
621
|
+
eprint(rdb, "get")
|
622
|
+
err = true
|
623
|
+
break
|
624
|
+
end
|
625
|
+
if rnum > 250 && inum % (rnum / 250) == 0
|
626
|
+
print('.')
|
627
|
+
if inum == rnum || inum % (rnum / 10) == 0
|
628
|
+
printf(" (%08d)\n", inum)
|
629
|
+
end
|
630
|
+
end
|
631
|
+
end
|
632
|
+
printf(" (%08d)\n", inum) if rnum > 250
|
633
|
+
if rdb.ecode != RDB::ENOREC || inum != rdb.rnum
|
634
|
+
eprint(rdb, "(validation)")
|
635
|
+
err = true
|
636
|
+
end
|
637
|
+
keys = rdb.fwmkeys("0", 10)
|
638
|
+
if rdb.rnum >= 10 && keys.size != 10
|
639
|
+
eprint(rdb, "fwmkeys")
|
640
|
+
err = true
|
641
|
+
end
|
642
|
+
printf("checking counting:\n")
|
643
|
+
for i in 1..rnum
|
644
|
+
buf = sprintf("[%d]", rand(rnum) + 1)
|
645
|
+
if rand(2) == 0
|
646
|
+
if !rdb.addint(buf, 123) && rdb.ecode != RDB::EKEEP
|
647
|
+
eprint(rdb, "addint")
|
648
|
+
err = true
|
649
|
+
break
|
650
|
+
end
|
651
|
+
else
|
652
|
+
if !rdb.adddouble(buf, 123.456) && rdb.ecode != RDB::EKEEP
|
653
|
+
eprint(rdb, "addint")
|
654
|
+
err = true
|
655
|
+
break
|
656
|
+
end
|
657
|
+
end
|
658
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
659
|
+
print('.')
|
660
|
+
if i == rnum || i % (rnum / 10) == 0
|
661
|
+
printf(" (%08d)\n", i)
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
665
|
+
printf("checking versatile functions:\n")
|
666
|
+
args = []
|
667
|
+
for i in 1..rnum
|
668
|
+
if rand(10) == 0
|
669
|
+
name = "putlist"
|
670
|
+
case rand(3)
|
671
|
+
when 1
|
672
|
+
name = "outlist"
|
673
|
+
when 2
|
674
|
+
name = "getlist"
|
675
|
+
end
|
676
|
+
if !rdb.misc(name, args)
|
677
|
+
eprint(rdb, "misc")
|
678
|
+
err = true
|
679
|
+
break
|
680
|
+
end
|
681
|
+
args = []
|
682
|
+
else
|
683
|
+
buf = sprintf("(%d)", rand(rnum))
|
684
|
+
args.push(buf)
|
685
|
+
end
|
686
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
687
|
+
print('.')
|
688
|
+
if i == rnum || i % (rnum / 10) == 0
|
689
|
+
printf(" (%08d)\n", i)
|
690
|
+
end
|
691
|
+
end
|
692
|
+
end
|
693
|
+
if !rdb.stat
|
694
|
+
eprint(rdb, "stat")
|
695
|
+
err = true
|
696
|
+
end
|
697
|
+
if !rdb.sync
|
698
|
+
eprint(rdb, "sync")
|
699
|
+
err = true
|
700
|
+
end
|
701
|
+
if !rdb.vanish
|
702
|
+
eprint(rdb, "vanish")
|
703
|
+
err = true
|
704
|
+
end
|
705
|
+
printf("checking hash-like updating:\n")
|
706
|
+
for i in 1..rnum
|
707
|
+
buf = sprintf("[%d]", rand(rnum))
|
708
|
+
case rand(4)
|
709
|
+
when 0
|
710
|
+
rdb[buf] = buf
|
711
|
+
when 1
|
712
|
+
value = rdb[buf]
|
713
|
+
when 2
|
714
|
+
res = rdb.has_key?(buf)
|
715
|
+
when 3
|
716
|
+
rdb.delete(buf)
|
717
|
+
end
|
718
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
719
|
+
print('.')
|
720
|
+
if i == rnum || i % (rnum / 10) == 0
|
721
|
+
printf(" (%08d)\n", i)
|
722
|
+
end
|
723
|
+
end
|
724
|
+
end
|
725
|
+
printf("checking hash-like iterator:\n")
|
726
|
+
inum = 0
|
727
|
+
rdb.each do |tkey, tvalue|
|
728
|
+
if inum > 0 && rnum > 250 && inum % (rnum / 250) == 0
|
729
|
+
print('.')
|
730
|
+
if inum == rnum || inum % (rnum / 10) == 0
|
731
|
+
printf(" (%08d)\n", inum)
|
732
|
+
end
|
733
|
+
end
|
734
|
+
inum += 1
|
735
|
+
end
|
736
|
+
printf(" (%08d)\n", inum) if rnum > 250
|
737
|
+
rdb.clear
|
738
|
+
printf("record number: %d\n", rdb.rnum)
|
739
|
+
printf("size: %d\n", rdb.size)
|
740
|
+
if !rdb.close
|
741
|
+
eprint(rdb, "close")
|
742
|
+
err = true
|
743
|
+
end
|
744
|
+
printf("time: %.3f\n", Time.now - stime)
|
745
|
+
printf("%s\n\n", err ? "error" : "ok")
|
746
|
+
return err ? 1 : 0
|
747
|
+
end
|
748
|
+
|
749
|
+
|
750
|
+
# perform table command
|
751
|
+
def proctable(host, port, rnum)
|
752
|
+
printf("<Table Extension Test>\n host=%s port=%d rnum=%d\n\n", host, port, rnum)
|
753
|
+
err = false
|
754
|
+
stime = Time.now
|
755
|
+
rdb = RDBTBL::new
|
756
|
+
if !rdb.open(host, port)
|
757
|
+
eprint(rdb, "open")
|
758
|
+
err = true
|
759
|
+
end
|
760
|
+
if !rdb.vanish
|
761
|
+
eprint(rdb, "vanish")
|
762
|
+
err = true
|
763
|
+
end
|
764
|
+
if !rdb.setindex("", RDBTBL::ITDECIMAL)
|
765
|
+
eprint(rdb, "setindex")
|
766
|
+
err = true
|
767
|
+
end
|
768
|
+
if !rdb.setindex("str", RDBTBL::ITLEXICAL)
|
769
|
+
eprint(rdb, "setindex")
|
770
|
+
err = true
|
771
|
+
end
|
772
|
+
if !rdb.setindex("num", RDBTBL::ITDECIMAL)
|
773
|
+
eprint(rdb, "setindex")
|
774
|
+
err = true
|
775
|
+
end
|
776
|
+
printf("writing:\n")
|
777
|
+
for i in 1..rnum
|
778
|
+
id = rdb.genuid
|
779
|
+
cols = {
|
780
|
+
"str" => id,
|
781
|
+
"num" => rand(id) + 1,
|
782
|
+
"type" => rand(32) + 1,
|
783
|
+
}
|
784
|
+
vbuf = ""
|
785
|
+
num = rand(5)
|
786
|
+
pt = 0
|
787
|
+
for j in 1..num
|
788
|
+
pt += rand(5) + 1
|
789
|
+
vbuf += "," if vbuf.length > 0
|
790
|
+
vbuf += pt.to_s
|
791
|
+
end
|
792
|
+
cols["flag"] = vbuf if vbuf.length > 0
|
793
|
+
if !rdb.put(id, cols)
|
794
|
+
eprint(rdb, "put")
|
795
|
+
err = true
|
796
|
+
break
|
797
|
+
end
|
798
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
799
|
+
print('.')
|
800
|
+
if i == rnum || i % (rnum / 10) == 0
|
801
|
+
printf(" (%08d)\n", i)
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
printf("reading:\n")
|
806
|
+
for i in 1..rnum
|
807
|
+
if !rdb.get(i)
|
808
|
+
eprint(rdb, "get")
|
809
|
+
err = true
|
810
|
+
break
|
811
|
+
end
|
812
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
813
|
+
print('.')
|
814
|
+
if i == rnum || i % (rnum / 10) == 0
|
815
|
+
printf(" (%08d)\n", i)
|
816
|
+
end
|
817
|
+
end
|
818
|
+
end
|
819
|
+
recs = { 1 => "", 2 => "", 3 => "", 4 => "" }
|
820
|
+
if rdb.mget(recs) != 4 || recs.size != 4 || recs["1"]["str"] != "1"
|
821
|
+
eprint(rdb, "mget")
|
822
|
+
err = true
|
823
|
+
end
|
824
|
+
printf("removing:\n")
|
825
|
+
for i in 1..rnum
|
826
|
+
if rand(2) == 0 && !rdb.out(i)
|
827
|
+
eprint(rdb, "out")
|
828
|
+
err = true
|
829
|
+
break
|
830
|
+
end
|
831
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
832
|
+
print('.')
|
833
|
+
if i == rnum || i % (rnum / 10) == 0
|
834
|
+
printf(" (%08d)\n", i)
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|
838
|
+
printf("searching:\n")
|
839
|
+
qry = RDBQRY::new(rdb)
|
840
|
+
names = [ "", "str", "num", "type", "flag", "c1" ]
|
841
|
+
ops = [ RDBQRY::QCSTREQ, RDBQRY::QCSTRINC, RDBQRY::QCSTRBW, RDBQRY::QCSTREW, RDBQRY::QCSTRAND,
|
842
|
+
RDBQRY::QCSTROR, RDBQRY::QCSTROREQ, RDBQRY::QCSTRRX, RDBQRY::QCNUMEQ, RDBQRY::QCNUMGT,
|
843
|
+
RDBQRY::QCNUMGE, RDBQRY::QCNUMLT, RDBQRY::QCNUMLE, RDBQRY::QCNUMBT, RDBQRY::QCNUMOREQ ]
|
844
|
+
types = [ RDBQRY::QOSTRASC, RDBQRY::QOSTRDESC, RDBQRY::QONUMASC, RDBQRY::QONUMDESC ]
|
845
|
+
for i in 1..rnum
|
846
|
+
qry = RDBQRY::new(rdb) if rand(10) > 0
|
847
|
+
cnum = rand(4)
|
848
|
+
for j in 1..cnum
|
849
|
+
name = names[rand(names.length)]
|
850
|
+
op = ops[rand(ops.length)]
|
851
|
+
op |= RDBQRY::QCNEGATE if rand(20) == 0
|
852
|
+
op |= RDBQRY::QCNOIDX if rand(20) == 0
|
853
|
+
expr = rand(i).to_s
|
854
|
+
expr += "," + rand(i).to_s if rand(10) == 0
|
855
|
+
expr += "," + rand(i).to_s if rand(10) == 0
|
856
|
+
qry.addcond(name, op, expr)
|
857
|
+
end
|
858
|
+
if rand(3) != 0
|
859
|
+
name = names[rand(names.length)]
|
860
|
+
type = types[rand(types.length)]
|
861
|
+
qry.setorder(name, type)
|
862
|
+
end
|
863
|
+
if rand(20) == 0
|
864
|
+
qry.setmax(10)
|
865
|
+
res = qry.searchget
|
866
|
+
res.each do |cols|
|
867
|
+
pkey = cols[""]
|
868
|
+
str = cols["str"]
|
869
|
+
if !pkey || !str || pkey != str
|
870
|
+
eprint(rdb, "searchget")
|
871
|
+
err = true
|
872
|
+
break
|
873
|
+
end
|
874
|
+
end
|
875
|
+
onum = rdb.rnum
|
876
|
+
if !qry.searchout
|
877
|
+
eprint(rdb, "searchout")
|
878
|
+
err = true
|
879
|
+
break
|
880
|
+
end
|
881
|
+
if rdb.rnum != onum - res.size
|
882
|
+
eprint(rdb, "(validation)")
|
883
|
+
err = true
|
884
|
+
break
|
885
|
+
end
|
886
|
+
else
|
887
|
+
qry.setmax(rand(i)) if rand(3) != 0
|
888
|
+
res = qry.search
|
889
|
+
end
|
890
|
+
if rnum > 250 && i % (rnum / 250) == 0
|
891
|
+
print('.')
|
892
|
+
if i == rnum || i % (rnum / 10) == 0
|
893
|
+
printf(" (%08d)\n", i)
|
894
|
+
end
|
895
|
+
end
|
896
|
+
end
|
897
|
+
printf("record number: %d\n", rdb.rnum)
|
898
|
+
printf("size: %d\n", rdb.size)
|
899
|
+
if !rdb.close
|
900
|
+
eprint(rdb, "close")
|
901
|
+
err = true
|
902
|
+
end
|
903
|
+
printf("time: %.3f\n", Time.now - stime)
|
904
|
+
printf("%s\n\n", err ? "error" : "ok")
|
905
|
+
return err ? 1 : 0
|
906
|
+
end
|
907
|
+
|
908
|
+
|
909
|
+
# execute main
|
910
|
+
STDOUT.sync = true
|
911
|
+
$progname = $0.dup
|
912
|
+
$progname.gsub!(/.*\//, "")
|
913
|
+
srand
|
914
|
+
exit(main)
|
915
|
+
|
916
|
+
|
917
|
+
|
918
|
+
# END OF FILE
|