heroku-tokyotyrant 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/README.rdoc +231 -0
- data/Rakefile +72 -0
- data/benchmarks/balancer.rb +101 -0
- data/benchmarks/bulk_db.rb +74 -0
- data/benchmarks/bulk_table.rb +87 -0
- data/benchmarks/db.rb +114 -0
- data/benchmarks/table.rb +161 -0
- data/ext/extconf.rb +43 -0
- data/ext/tokyo/bin/tcamgr +0 -0
- data/ext/tokyo/bin/tcamttest +0 -0
- data/ext/tokyo/bin/tcatest +0 -0
- data/ext/tokyo/bin/tcbmgr +0 -0
- data/ext/tokyo/bin/tcbmttest +0 -0
- data/ext/tokyo/bin/tcbtest +0 -0
- data/ext/tokyo/bin/tcfmgr +0 -0
- data/ext/tokyo/bin/tcfmttest +0 -0
- data/ext/tokyo/bin/tcftest +0 -0
- data/ext/tokyo/bin/tchmgr +0 -0
- data/ext/tokyo/bin/tchmttest +0 -0
- data/ext/tokyo/bin/tchtest +0 -0
- data/ext/tokyo/bin/tcrmgr +0 -0
- data/ext/tokyo/bin/tcrmttest +0 -0
- data/ext/tokyo/bin/tcrtest +0 -0
- data/ext/tokyo/bin/tctmgr +0 -0
- data/ext/tokyo/bin/tctmttest +0 -0
- data/ext/tokyo/bin/tcttest +0 -0
- data/ext/tokyo/bin/tcucodec +0 -0
- data/ext/tokyo/bin/tcumttest +0 -0
- data/ext/tokyo/bin/tcutest +0 -0
- data/ext/tokyo/bin/ttserver +0 -0
- data/ext/tokyo/bin/ttulmgr +0 -0
- data/ext/tokyo/bin/ttultest +0 -0
- data/ext/tokyo/include/tcadb.h +548 -0
- data/ext/tokyo/include/tcbdb.h +1101 -0
- data/ext/tokyo/include/tcfdb.h +858 -0
- data/ext/tokyo/include/tchdb.h +871 -0
- data/ext/tokyo/include/tcrdb.h +801 -0
- data/ext/tokyo/include/tctdb.h +1086 -0
- data/ext/tokyo/include/tculog.h +392 -0
- data/ext/tokyo/include/tcutil.h +4184 -0
- data/ext/tokyo/include/ttutil.h +494 -0
- data/ext/tokyo/lib/libtokyocabinet.9.4.0.dylib +0 -0
- data/ext/tokyo/lib/libtokyocabinet.9.dylib +0 -0
- data/ext/tokyo/lib/libtokyocabinet.a +0 -0
- data/ext/tokyo/lib/libtokyocabinet.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.3.22.0.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.3.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.a +0 -0
- data/ext/tokyo/lib/libtokyotyrant.dylib +0 -0
- data/ext/tokyo/lib/pkgconfig/tokyocabinet.pc +14 -0
- data/ext/tokyo/lib/pkgconfig/tokyotyrant.pc +14 -0
- data/ext/tokyo/lib/ttskeldir.bundle +0 -0
- data/ext/tokyo/lib/ttskelmock.bundle +0 -0
- data/ext/tokyo/lib/ttskelnull.bundle +0 -0
- data/ext/tokyo/lib/ttskelproxy.bundle +0 -0
- data/ext/tokyo/libexec/tcawmgr.cgi +0 -0
- data/ext/tokyo/sbin/ttservctl +163 -0
- data/ext/tokyo/share/man/man1/tcamgr.1 +97 -0
- data/ext/tokyo/share/man/man1/tcamttest.1 +35 -0
- data/ext/tokyo/share/man/man1/tcatest.1 +55 -0
- data/ext/tokyo/share/man/man1/tcbmgr.1 +125 -0
- data/ext/tokyo/share/man/man1/tcbmttest.1 +81 -0
- data/ext/tokyo/share/man/man1/tcbtest.1 +107 -0
- data/ext/tokyo/share/man/man1/tcfmgr.1 +98 -0
- data/ext/tokyo/share/man/man1/tcfmttest.1 +62 -0
- data/ext/tokyo/share/man/man1/tcftest.1 +73 -0
- data/ext/tokyo/share/man/man1/tchmgr.1 +110 -0
- data/ext/tokyo/share/man/man1/tchmttest.1 +85 -0
- data/ext/tokyo/share/man/man1/tchtest.1 +95 -0
- data/ext/tokyo/share/man/man1/tcrmgr.1 +164 -0
- data/ext/tokyo/share/man/man1/tcrmttest.1 +55 -0
- data/ext/tokyo/share/man/man1/tcrtest.1 +89 -0
- data/ext/tokyo/share/man/man1/tctmgr.1 +140 -0
- data/ext/tokyo/share/man/man1/tctmttest.1 +92 -0
- data/ext/tokyo/share/man/man1/tcttest.1 +105 -0
- data/ext/tokyo/share/man/man1/tcucodec.1 +162 -0
- data/ext/tokyo/share/man/man1/tcumttest.1 +41 -0
- data/ext/tokyo/share/man/man1/tcutest.1 +81 -0
- data/ext/tokyo/share/man/man1/ttserver.1 +84 -0
- data/ext/tokyo/share/man/man1/ttulmgr.1 +40 -0
- data/ext/tokyo/share/man/man1/ttultest.1 +16 -0
- data/ext/tokyo/share/man/man3/tcadb.3 +676 -0
- data/ext/tokyo/share/man/man3/tcbdb.3 +1355 -0
- data/ext/tokyo/share/man/man3/tcfdb.3 +975 -0
- data/ext/tokyo/share/man/man3/tchdb.3 +898 -0
- data/ext/tokyo/share/man/man3/tclist.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmap.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmdb.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmpool.3 +1 -0
- data/ext/tokyo/share/man/man3/tcrdb.3 +1309 -0
- data/ext/tokyo/share/man/man3/tctdb.3 +1110 -0
- data/ext/tokyo/share/man/man3/tctree.3 +1 -0
- data/ext/tokyo/share/man/man3/tculog.3 +15 -0
- data/ext/tokyo/share/man/man3/tcutil.3 +4518 -0
- data/ext/tokyo/share/man/man3/tcxstr.3 +1 -0
- data/ext/tokyo/share/man/man3/tokyocabinet.3 +132 -0
- data/ext/tokyo/share/man/man3/ttutil.3 +14 -0
- data/ext/tokyo/share/man/man8/ttservctl.8 +37 -0
- data/ext/tokyo/share/tokyocabinet/COPYING +504 -0
- data/ext/tokyo/share/tokyocabinet/ChangeLog +1252 -0
- data/ext/tokyo/share/tokyocabinet/THANKS +12 -0
- data/ext/tokyo/share/tokyocabinet/doc/benchmark.pdf +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/common.css +211 -0
- data/ext/tokyo/share/tokyocabinet/doc/icon16.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/index.html +156 -0
- data/ext/tokyo/share/tokyocabinet/doc/index.ja.html +197 -0
- data/ext/tokyo/share/tokyocabinet/doc/logo-ja.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/logo.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/spex-en.html +7145 -0
- data/ext/tokyo/share/tokyocabinet/doc/spex-ja.html +7476 -0
- data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.pdf +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.ppt +0 -0
- data/ext/tokyo/share/tokyotyrant/COPYING +504 -0
- data/ext/tokyo/share/tokyotyrant/ChangeLog +578 -0
- data/ext/tokyo/share/tokyotyrant/THANKS +15 -0
- data/ext/tokyo/share/tokyotyrant/doc/common.css +211 -0
- data/ext/tokyo/share/tokyotyrant/doc/index.html +79 -0
- data/ext/tokyo/share/tokyotyrant/doc/spex.html +2264 -0
- data/ext/tokyo/share/tokyotyrant/ext/mapreduce.lua +57 -0
- data/ext/tokyo/share/tokyotyrant/ext/queue.lua +55 -0
- data/ext/tokyo/share/tokyotyrant/ext/senatus.lua +532 -0
- data/ext/tokyo/share/tokyotyrant/ext/usherette.lua +438 -0
- data/ext/tokyo_tyrant.c +147 -0
- data/ext/tokyo_tyrant.h +48 -0
- data/ext/tokyo_tyrant_db.c +227 -0
- data/ext/tokyo_tyrant_db.h +8 -0
- data/ext/tokyo_tyrant_module.c +453 -0
- data/ext/tokyo_tyrant_module.h +10 -0
- data/ext/tokyo_tyrant_query.c +226 -0
- data/ext/tokyo_tyrant_query.h +9 -0
- data/ext/tokyo_tyrant_table.c +319 -0
- data/ext/tokyo_tyrant_table.h +8 -0
- data/ext/tokyocabinet-1.4.41/COPYING +504 -0
- data/ext/tokyocabinet-1.4.41/ChangeLog +1252 -0
- data/ext/tokyocabinet-1.4.41/Makefile.in +825 -0
- data/ext/tokyocabinet-1.4.41/README +38 -0
- data/ext/tokyocabinet-1.4.41/THANKS +12 -0
- data/ext/tokyocabinet-1.4.41/bros/Makefile +133 -0
- data/ext/tokyocabinet-1.4.41/bros/bdbtest.c +438 -0
- data/ext/tokyocabinet-1.4.41/bros/cdbtest.c +219 -0
- data/ext/tokyocabinet-1.4.41/bros/cmpsqltctest.c +186 -0
- data/ext/tokyocabinet-1.4.41/bros/gdbmtest.c +216 -0
- data/ext/tokyocabinet-1.4.41/bros/mapreporter +72 -0
- data/ext/tokyocabinet-1.4.41/bros/maptest.cc +677 -0
- data/ext/tokyocabinet-1.4.41/bros/ndbmtest.c +204 -0
- data/ext/tokyocabinet-1.4.41/bros/qdbmtest.c +375 -0
- data/ext/tokyocabinet-1.4.41/bros/reporter +141 -0
- data/ext/tokyocabinet-1.4.41/bros/result.xls +0 -0
- data/ext/tokyocabinet-1.4.41/bros/sdbmtest.c +204 -0
- data/ext/tokyocabinet-1.4.41/bros/sqltest.c +404 -0
- data/ext/tokyocabinet-1.4.41/bros/tctest.c +748 -0
- data/ext/tokyocabinet-1.4.41/bros/tdbtest.c +205 -0
- data/ext/tokyocabinet-1.4.41/configure +7402 -0
- data/ext/tokyocabinet-1.4.41/configure.in +362 -0
- data/ext/tokyocabinet-1.4.41/doc/benchmark.pdf +0 -0
- data/ext/tokyocabinet-1.4.41/doc/common.css +211 -0
- data/ext/tokyocabinet-1.4.41/doc/icon16.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/index.html +156 -0
- data/ext/tokyocabinet-1.4.41/doc/index.ja.html +197 -0
- data/ext/tokyocabinet-1.4.41/doc/logo-ja.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/logo.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/spex-en.html +7145 -0
- data/ext/tokyocabinet-1.4.41/doc/spex-ja.html +7476 -0
- data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.pdf +0 -0
- data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.ppt +0 -0
- data/ext/tokyocabinet-1.4.41/example/Makefile +113 -0
- data/ext/tokyocabinet-1.4.41/example/tcadbex.c +55 -0
- data/ext/tokyocabinet-1.4.41/example/tcbdbex.c +64 -0
- data/ext/tokyocabinet-1.4.41/example/tcfdbex.c +60 -0
- data/ext/tokyocabinet-1.4.41/example/tchdbex.c +60 -0
- data/ext/tokyocabinet-1.4.41/example/tctchat.c +97 -0
- data/ext/tokyocabinet-1.4.41/example/tctchat.tmpl +141 -0
- data/ext/tokyocabinet-1.4.41/example/tctdbex.c +85 -0
- data/ext/tokyocabinet-1.4.41/example/tctsearch.c +95 -0
- data/ext/tokyocabinet-1.4.41/example/tctsearch.tmpl +122 -0
- data/ext/tokyocabinet-1.4.41/example/tcutilex.c +77 -0
- data/ext/tokyocabinet-1.4.41/f.tsv +2 -0
- data/ext/tokyocabinet-1.4.41/lab/calccomp +118 -0
- data/ext/tokyocabinet-1.4.41/lab/datechange +56 -0
- data/ext/tokyocabinet-1.4.41/lab/diffcheck +45 -0
- data/ext/tokyocabinet-1.4.41/lab/htmltotsv +102 -0
- data/ext/tokyocabinet-1.4.41/lab/magic +19 -0
- data/ext/tokyocabinet-1.4.41/lab/printenv.cgi +27 -0
- data/ext/tokyocabinet-1.4.41/lab/stepcount +26 -0
- data/ext/tokyocabinet-1.4.41/lab/stopwatch +61 -0
- data/ext/tokyocabinet-1.4.41/lab/tabcheck +43 -0
- data/ext/tokyocabinet-1.4.41/lab/wgettsv +239 -0
- data/ext/tokyocabinet-1.4.41/lab/widthcheck +57 -0
- data/ext/tokyocabinet-1.4.41/man/htmltoman +104 -0
- data/ext/tokyocabinet-1.4.41/man/tcadb.3 +676 -0
- data/ext/tokyocabinet-1.4.41/man/tcamgr.1 +97 -0
- data/ext/tokyocabinet-1.4.41/man/tcamttest.1 +35 -0
- data/ext/tokyocabinet-1.4.41/man/tcatest.1 +55 -0
- data/ext/tokyocabinet-1.4.41/man/tcbdb.3 +1355 -0
- data/ext/tokyocabinet-1.4.41/man/tcbmgr.1 +125 -0
- data/ext/tokyocabinet-1.4.41/man/tcbmttest.1 +81 -0
- data/ext/tokyocabinet-1.4.41/man/tcbtest.1 +107 -0
- data/ext/tokyocabinet-1.4.41/man/tcfdb.3 +975 -0
- data/ext/tokyocabinet-1.4.41/man/tcfmgr.1 +98 -0
- data/ext/tokyocabinet-1.4.41/man/tcfmttest.1 +62 -0
- data/ext/tokyocabinet-1.4.41/man/tcftest.1 +73 -0
- data/ext/tokyocabinet-1.4.41/man/tchdb.3 +898 -0
- data/ext/tokyocabinet-1.4.41/man/tchmgr.1 +110 -0
- data/ext/tokyocabinet-1.4.41/man/tchmttest.1 +85 -0
- data/ext/tokyocabinet-1.4.41/man/tchtest.1 +95 -0
- data/ext/tokyocabinet-1.4.41/man/tclist.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmap.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmdb.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmpool.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tctdb.3 +1110 -0
- data/ext/tokyocabinet-1.4.41/man/tctmgr.1 +140 -0
- data/ext/tokyocabinet-1.4.41/man/tctmttest.1 +92 -0
- data/ext/tokyocabinet-1.4.41/man/tctree.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcttest.1 +105 -0
- data/ext/tokyocabinet-1.4.41/man/tcucodec.1 +162 -0
- data/ext/tokyocabinet-1.4.41/man/tcumttest.1 +41 -0
- data/ext/tokyocabinet-1.4.41/man/tcutest.1 +81 -0
- data/ext/tokyocabinet-1.4.41/man/tcutil.3 +4518 -0
- data/ext/tokyocabinet-1.4.41/man/tcxstr.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tokyocabinet.3 +132 -0
- data/ext/tokyocabinet-1.4.41/md5.c +381 -0
- data/ext/tokyocabinet-1.4.41/md5.h +101 -0
- data/ext/tokyocabinet-1.4.41/myconf.c +493 -0
- data/ext/tokyocabinet-1.4.41/myconf.h +549 -0
- data/ext/tokyocabinet-1.4.41/tcadb.c +4339 -0
- data/ext/tokyocabinet-1.4.41/tcadb.h +548 -0
- data/ext/tokyocabinet-1.4.41/tcamgr.c +1019 -0
- data/ext/tokyocabinet-1.4.41/tcamttest.c +542 -0
- data/ext/tokyocabinet-1.4.41/tcatest.c +1845 -0
- data/ext/tokyocabinet-1.4.41/tcawmgr.c +482 -0
- data/ext/tokyocabinet-1.4.41/tcbdb.c +4180 -0
- data/ext/tokyocabinet-1.4.41/tcbdb.h +1101 -0
- data/ext/tokyocabinet-1.4.41/tcbmgr.c +1012 -0
- data/ext/tokyocabinet-1.4.41/tcbmttest.c +1810 -0
- data/ext/tokyocabinet-1.4.41/tcbtest.c +2586 -0
- data/ext/tokyocabinet-1.4.41/tcfdb.c +2746 -0
- data/ext/tokyocabinet-1.4.41/tcfdb.h +858 -0
- data/ext/tokyocabinet-1.4.41/tcfmgr.c +786 -0
- data/ext/tokyocabinet-1.4.41/tcfmttest.c +1220 -0
- data/ext/tokyocabinet-1.4.41/tcftest.c +1695 -0
- data/ext/tokyocabinet-1.4.41/tchdb.c +5153 -0
- data/ext/tokyocabinet-1.4.41/tchdb.h +871 -0
- data/ext/tokyocabinet-1.4.41/tchmgr.c +842 -0
- data/ext/tokyocabinet-1.4.41/tchmttest.c +1757 -0
- data/ext/tokyocabinet-1.4.41/tchtest.c +2129 -0
- data/ext/tokyocabinet-1.4.41/tctdb.c +6199 -0
- data/ext/tokyocabinet-1.4.41/tctdb.h +1086 -0
- data/ext/tokyocabinet-1.4.41/tctmgr.c +1241 -0
- data/ext/tokyocabinet-1.4.41/tctmttest.c +1563 -0
- data/ext/tokyocabinet-1.4.41/tcttest.c +2062 -0
- data/ext/tokyocabinet-1.4.41/tcucodec.c +1357 -0
- data/ext/tokyocabinet-1.4.41/tcumttest.c +578 -0
- data/ext/tokyocabinet-1.4.41/tcutest.c +1875 -0
- data/ext/tokyocabinet-1.4.41/tcutil.c +10528 -0
- data/ext/tokyocabinet-1.4.41/tcutil.h +4184 -0
- data/ext/tokyocabinet-1.4.41/tokyocabinet.idl +336 -0
- data/ext/tokyocabinet-1.4.41/tokyocabinet.pc.in +14 -0
- data/ext/tokyotyrant-1.1.39/COPYING +504 -0
- data/ext/tokyotyrant-1.1.39/ChangeLog +578 -0
- data/ext/tokyotyrant-1.1.39/Makefile.in +365 -0
- data/ext/tokyotyrant-1.1.39/README +38 -0
- data/ext/tokyotyrant-1.1.39/THANKS +15 -0
- data/ext/tokyotyrant-1.1.39/configure +6979 -0
- data/ext/tokyotyrant-1.1.39/configure.in +300 -0
- data/ext/tokyotyrant-1.1.39/doc/common.css +211 -0
- data/ext/tokyotyrant-1.1.39/doc/index.html +79 -0
- data/ext/tokyotyrant-1.1.39/doc/spex.html +2264 -0
- data/ext/tokyotyrant-1.1.39/example/Makefile +68 -0
- data/ext/tokyotyrant-1.1.39/example/httptest.pl +88 -0
- data/ext/tokyotyrant-1.1.39/example/mcftest.pl +39 -0
- data/ext/tokyotyrant-1.1.39/example/mctest.pl +43 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex.c +49 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex.o +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.c +79 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.o +0 -0
- data/ext/tokyotyrant-1.1.39/ext/mapreduce.lua +57 -0
- data/ext/tokyotyrant-1.1.39/ext/queue.lua +55 -0
- data/ext/tokyotyrant-1.1.39/ext/senatus.lua +532 -0
- data/ext/tokyotyrant-1.1.39/ext/usherette.lua +438 -0
- data/ext/tokyotyrant-1.1.39/lab/datechange +56 -0
- data/ext/tokyotyrant-1.1.39/lab/diffcheck +45 -0
- data/ext/tokyotyrant-1.1.39/lab/fibonacci.lua +20 -0
- data/ext/tokyotyrant-1.1.39/lab/footprint.lua +67 -0
- data/ext/tokyotyrant-1.1.39/lab/highlow.lua +88 -0
- data/ext/tokyotyrant-1.1.39/lab/killdualmaster +12 -0
- data/ext/tokyotyrant-1.1.39/lab/rundualmaster +38 -0
- data/ext/tokyotyrant-1.1.39/lab/stepcount +26 -0
- data/ext/tokyotyrant-1.1.39/lab/tabcheck +43 -0
- data/ext/tokyotyrant-1.1.39/lab/ushrtregister.pl +55 -0
- data/ext/tokyotyrant-1.1.39/lab/widthcheck +57 -0
- data/ext/tokyotyrant-1.1.39/man/htmltoman +100 -0
- data/ext/tokyotyrant-1.1.39/man/tcrdb.3 +1309 -0
- data/ext/tokyotyrant-1.1.39/man/tcrmgr.1 +164 -0
- data/ext/tokyotyrant-1.1.39/man/tcrmttest.1 +55 -0
- data/ext/tokyotyrant-1.1.39/man/tcrtest.1 +89 -0
- data/ext/tokyotyrant-1.1.39/man/tculog.3 +15 -0
- data/ext/tokyotyrant-1.1.39/man/ttservctl.8 +37 -0
- data/ext/tokyotyrant-1.1.39/man/ttserver.1 +84 -0
- data/ext/tokyotyrant-1.1.39/man/ttulmgr.1 +40 -0
- data/ext/tokyotyrant-1.1.39/man/ttultest.1 +16 -0
- data/ext/tokyotyrant-1.1.39/man/ttutil.3 +14 -0
- data/ext/tokyotyrant-1.1.39/myconf.c +169 -0
- data/ext/tokyotyrant-1.1.39/myconf.h +408 -0
- data/ext/tokyotyrant-1.1.39/scrext.c +2394 -0
- data/ext/tokyotyrant-1.1.39/scrext.h +96 -0
- data/ext/tokyotyrant-1.1.39/tcrdb.c +2637 -0
- data/ext/tokyotyrant-1.1.39/tcrdb.h +801 -0
- data/ext/tokyotyrant-1.1.39/tcrmgr.c +1559 -0
- data/ext/tokyotyrant-1.1.39/tcrmttest.c +915 -0
- data/ext/tokyotyrant-1.1.39/tcrtest.c +1542 -0
- data/ext/tokyotyrant-1.1.39/tculog.c +1211 -0
- data/ext/tokyotyrant-1.1.39/tculog.h +392 -0
- data/ext/tokyotyrant-1.1.39/tokyotyrant.idl +143 -0
- data/ext/tokyotyrant-1.1.39/tokyotyrant.pc.in +14 -0
- data/ext/tokyotyrant-1.1.39/ttservctl +163 -0
- data/ext/tokyotyrant-1.1.39/ttserver.c +3583 -0
- data/ext/tokyotyrant-1.1.39/ttskeldir.c +141 -0
- data/ext/tokyotyrant-1.1.39/ttskelmock.c +64 -0
- data/ext/tokyotyrant-1.1.39/ttskelnull.c +79 -0
- data/ext/tokyotyrant-1.1.39/ttskelproxy.c +74 -0
- data/ext/tokyotyrant-1.1.39/ttulmgr.c +266 -0
- data/ext/tokyotyrant-1.1.39/ttultest.c +371 -0
- data/ext/tokyotyrant-1.1.39/ttutil.c +1510 -0
- data/ext/tokyotyrant-1.1.39/ttutil.h +494 -0
- data/lib/tokyo_tyrant/balancer.rb +189 -0
- data/spec/ext.lua +4 -0
- data/spec/plu_db.rb +538 -0
- data/spec/spec.rb +1 -0
- data/spec/spec_base.rb +17 -0
- data/spec/start_tyrants.sh +36 -0
- data/spec/stop_tyrants.sh +9 -0
- data/spec/tokyo_tyrant_balancer_db_spec.rb +160 -0
- data/spec/tokyo_tyrant_balancer_table_spec.rb +177 -0
- data/spec/tokyo_tyrant_query_spec.rb +159 -0
- data/spec/tokyo_tyrant_spec.rb +254 -0
- data/spec/tokyo_tyrant_table_spec.rb +301 -0
- metadata +402 -0
@@ -0,0 +1,1563 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* The test cases of the table database API
|
3
|
+
* Copyright (C) 2006-2009 Mikio Hirabayashi
|
4
|
+
* This file is part of Tokyo Cabinet.
|
5
|
+
* Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
|
6
|
+
* the GNU Lesser General Public License as published by the Free Software Foundation; either
|
7
|
+
* version 2.1 of the License or any later version. Tokyo Cabinet is distributed in the hope
|
8
|
+
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
10
|
+
* License for more details.
|
11
|
+
* You should have received a copy of the GNU Lesser General Public License along with Tokyo
|
12
|
+
* Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
13
|
+
* Boston, MA 02111-1307 USA.
|
14
|
+
*************************************************************************************************/
|
15
|
+
|
16
|
+
|
17
|
+
#include <tcutil.h>
|
18
|
+
#include <tctdb.h>
|
19
|
+
#include "myconf.h"
|
20
|
+
|
21
|
+
#define RECBUFSIZ 48 // buffer for records
|
22
|
+
|
23
|
+
typedef struct { // type of structure for write thread
|
24
|
+
TCTDB *tdb;
|
25
|
+
int rnum;
|
26
|
+
bool rnd;
|
27
|
+
int id;
|
28
|
+
} TARGWRITE;
|
29
|
+
|
30
|
+
typedef struct { // type of structure for read thread
|
31
|
+
TCTDB *tdb;
|
32
|
+
int rnum;
|
33
|
+
bool rnd;
|
34
|
+
int id;
|
35
|
+
} TARGREAD;
|
36
|
+
|
37
|
+
typedef struct { // type of structure for remove thread
|
38
|
+
TCTDB *tdb;
|
39
|
+
int rnum;
|
40
|
+
bool rnd;
|
41
|
+
int id;
|
42
|
+
} TARGREMOVE;
|
43
|
+
|
44
|
+
typedef struct { // type of structure for wicked thread
|
45
|
+
TCTDB *tdb;
|
46
|
+
int rnum;
|
47
|
+
int id;
|
48
|
+
} TARGWICKED;
|
49
|
+
|
50
|
+
typedef struct { // type of structure for typical thread
|
51
|
+
TCTDB *tdb;
|
52
|
+
int rnum;
|
53
|
+
int rratio;
|
54
|
+
int id;
|
55
|
+
} TARGTYPICAL;
|
56
|
+
|
57
|
+
|
58
|
+
/* global variables */
|
59
|
+
const char *g_progname; // program name
|
60
|
+
unsigned int g_randseed; // random seed
|
61
|
+
int g_dbgfd; // debugging output
|
62
|
+
|
63
|
+
|
64
|
+
/* function prototypes */
|
65
|
+
int main(int argc, char **argv);
|
66
|
+
static void usage(void);
|
67
|
+
static void iprintf(const char *format, ...);
|
68
|
+
static void iputchar(int c);
|
69
|
+
static void eprint(TCTDB *tdb, int line, const char *func);
|
70
|
+
static void sysprint(void);
|
71
|
+
static int myrand(int range);
|
72
|
+
static int myrandnd(int range);
|
73
|
+
static int runwrite(int argc, char **argv);
|
74
|
+
static int runread(int argc, char **argv);
|
75
|
+
static int runremove(int argc, char **argv);
|
76
|
+
static int runwicked(int argc, char **argv);
|
77
|
+
static int runtypical(int argc, char **argv);
|
78
|
+
static int procwrite(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
79
|
+
int opts, int rcnum, int lcnum, int ncnum, int xmsiz, int dfunit,
|
80
|
+
int iflags, int omode, bool rnd);
|
81
|
+
static int procread(const char *path, int tnum, int rcnum, int lcnum, int ncnum,
|
82
|
+
int xmsiz, int dfunit, int omode, bool rnd);
|
83
|
+
static int procremove(const char *path, int tnum, int rcnum, int lcnum, int ncnum,
|
84
|
+
int xmsiz, int dfunit, int omode, bool rnd);
|
85
|
+
static int procwicked(const char *path, int tnum, int rnum, int opts, int omode);
|
86
|
+
static int proctypical(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
87
|
+
int opts, int rcnum, int lcnum, int ncnum, int xmsiz, int dfunit,
|
88
|
+
int omode, int rratio);
|
89
|
+
static void *threadwrite(void *targ);
|
90
|
+
static void *threadread(void *targ);
|
91
|
+
static void *threadremove(void *targ);
|
92
|
+
static void *threadwicked(void *targ);
|
93
|
+
static void *threadtypical(void *targ);
|
94
|
+
|
95
|
+
|
96
|
+
/* main routine */
|
97
|
+
int main(int argc, char **argv){
|
98
|
+
g_progname = argv[0];
|
99
|
+
const char *ebuf = getenv("TCRNDSEED");
|
100
|
+
g_randseed = ebuf ? tcatoix(ebuf) : tctime() * 1000;
|
101
|
+
srand(g_randseed);
|
102
|
+
ebuf = getenv("TCDBGFD");
|
103
|
+
g_dbgfd = ebuf ? tcatoix(ebuf) : UINT16_MAX;
|
104
|
+
if(argc < 2) usage();
|
105
|
+
int rv = 0;
|
106
|
+
if(!strcmp(argv[1], "write")){
|
107
|
+
rv = runwrite(argc, argv);
|
108
|
+
} else if(!strcmp(argv[1], "read")){
|
109
|
+
rv = runread(argc, argv);
|
110
|
+
} else if(!strcmp(argv[1], "remove")){
|
111
|
+
rv = runremove(argc, argv);
|
112
|
+
} else if(!strcmp(argv[1], "wicked")){
|
113
|
+
rv = runwicked(argc, argv);
|
114
|
+
} else if(!strcmp(argv[1], "typical")){
|
115
|
+
rv = runtypical(argc, argv);
|
116
|
+
} else {
|
117
|
+
usage();
|
118
|
+
}
|
119
|
+
if(rv != 0){
|
120
|
+
printf("FAILED: TCRNDSEED=%u PID=%d", g_randseed, (int)getpid());
|
121
|
+
for(int i = 0; i < argc; i++){
|
122
|
+
printf(" %s", argv[i]);
|
123
|
+
}
|
124
|
+
printf("\n\n");
|
125
|
+
}
|
126
|
+
return rv;
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
/* print the usage and exit */
|
131
|
+
static void usage(void){
|
132
|
+
fprintf(stderr, "%s: test cases of the table database API of Tokyo Cabinet\n", g_progname);
|
133
|
+
fprintf(stderr, "\n");
|
134
|
+
fprintf(stderr, "usage:\n");
|
135
|
+
fprintf(stderr, " %s write [-tl] [-td|-tb|-tt|-tx] [-rc num] [-lc num] [-nc num]"
|
136
|
+
" [-xm num] [-df num] [-ip] [-is] [-in] [-it] [-if] [-ix] [-nl|-nb] [-rnd]"
|
137
|
+
" path tnum rnum [bnum [apow [fpow]]]\n", g_progname);
|
138
|
+
fprintf(stderr, " %s read [-rc num] [-lc num] [-nc num] [-xm num] [-df num] [-nl|-nb] [-rnd]"
|
139
|
+
" path tnum\n", g_progname);
|
140
|
+
fprintf(stderr, " %s remove [-rc num] [-lc num] [-nc num] [-xm num] [-df num]"
|
141
|
+
" [-nl|-nb] [-rnd] path tnum\n", g_progname);
|
142
|
+
fprintf(stderr, " %s wicked [-tl] [-td|-tb|-tt|-tx] [-nl|-nb] path tnum rnum\n", g_progname);
|
143
|
+
fprintf(stderr, " %s typical [-tl] [-td|-tb|-tt|-tx] [-rc num] [-lc num] [-nc num]"
|
144
|
+
" [-xm num] [-df num] [-nl|-nb] [-rr num] path tnum rnum [bnum [apow [fpow]]]\n",
|
145
|
+
g_progname);
|
146
|
+
fprintf(stderr, "\n");
|
147
|
+
exit(1);
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
/* print formatted information string and flush the buffer */
|
152
|
+
static void iprintf(const char *format, ...){
|
153
|
+
va_list ap;
|
154
|
+
va_start(ap, format);
|
155
|
+
vprintf(format, ap);
|
156
|
+
fflush(stdout);
|
157
|
+
va_end(ap);
|
158
|
+
}
|
159
|
+
|
160
|
+
|
161
|
+
/* print a character and flush the buffer */
|
162
|
+
static void iputchar(int c){
|
163
|
+
putchar(c);
|
164
|
+
fflush(stdout);
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
/* print error message of table database */
|
169
|
+
static void eprint(TCTDB *tdb, int line, const char *func){
|
170
|
+
const char *path = tctdbpath(tdb);
|
171
|
+
int ecode = tctdbecode(tdb);
|
172
|
+
fprintf(stderr, "%s: %s: %d: %s: error: %d: %s\n",
|
173
|
+
g_progname, path ? path : "-", line, func, ecode, tctdberrmsg(ecode));
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
/* print system information */
|
178
|
+
static void sysprint(void){
|
179
|
+
TCMAP *info = tcsysinfo();
|
180
|
+
if(info){
|
181
|
+
tcmapiterinit(info);
|
182
|
+
const char *kbuf;
|
183
|
+
while((kbuf = tcmapiternext2(info)) != NULL){
|
184
|
+
iprintf("sys_%s: %s\n", kbuf, tcmapiterval2(kbuf));
|
185
|
+
}
|
186
|
+
tcmapdel(info);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
/* get a random number */
|
192
|
+
static int myrand(int range){
|
193
|
+
if(range < 2) return 0;
|
194
|
+
int high = (unsigned int)rand() >> 4;
|
195
|
+
int low = range * (rand() / (RAND_MAX + 1.0));
|
196
|
+
low &= (unsigned int)INT_MAX >> 4;
|
197
|
+
return (high + low) % range;
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
/* get a random number based on normal distribution */
|
202
|
+
static int myrandnd(int range){
|
203
|
+
int num = (int)tcdrandnd(range >> 1, range / 10);
|
204
|
+
return (num < 0 || num >= range) ? 0 : num;
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
/* parse arguments of write command */
|
209
|
+
static int runwrite(int argc, char **argv){
|
210
|
+
char *path = NULL;
|
211
|
+
char *tstr = NULL;
|
212
|
+
char *rstr = NULL;
|
213
|
+
char *bstr = NULL;
|
214
|
+
char *astr = NULL;
|
215
|
+
char *fstr = NULL;
|
216
|
+
int opts = 0;
|
217
|
+
int rcnum = 0;
|
218
|
+
int lcnum = 0;
|
219
|
+
int ncnum = 0;
|
220
|
+
int xmsiz = -1;
|
221
|
+
int dfunit = 0;
|
222
|
+
int iflags = 0;
|
223
|
+
int omode = 0;
|
224
|
+
bool rnd = false;
|
225
|
+
for(int i = 2; i < argc; i++){
|
226
|
+
if(!path && argv[i][0] == '-'){
|
227
|
+
if(!strcmp(argv[i], "-tl")){
|
228
|
+
opts |= TDBTLARGE;
|
229
|
+
} else if(!strcmp(argv[i], "-td")){
|
230
|
+
opts |= TDBTDEFLATE;
|
231
|
+
} else if(!strcmp(argv[i], "-tb")){
|
232
|
+
opts |= TDBTBZIP;
|
233
|
+
} else if(!strcmp(argv[i], "-tt")){
|
234
|
+
opts |= TDBTTCBS;
|
235
|
+
} else if(!strcmp(argv[i], "-tx")){
|
236
|
+
opts |= TDBTEXCODEC;
|
237
|
+
} else if(!strcmp(argv[i], "-rc")){
|
238
|
+
if(++i >= argc) usage();
|
239
|
+
rcnum = tcatoix(argv[i]);
|
240
|
+
} else if(!strcmp(argv[i], "-lc")){
|
241
|
+
if(++i >= argc) usage();
|
242
|
+
lcnum = tcatoix(argv[i]);
|
243
|
+
} else if(!strcmp(argv[i], "-nc")){
|
244
|
+
if(++i >= argc) usage();
|
245
|
+
ncnum = tcatoix(argv[i]);
|
246
|
+
} else if(!strcmp(argv[i], "-xm")){
|
247
|
+
if(++i >= argc) usage();
|
248
|
+
xmsiz = tcatoix(argv[i]);
|
249
|
+
} else if(!strcmp(argv[i], "-df")){
|
250
|
+
if(++i >= argc) usage();
|
251
|
+
dfunit = tcatoix(argv[i]);
|
252
|
+
} else if(!strcmp(argv[i], "-ip")){
|
253
|
+
iflags |= 1 << 0;
|
254
|
+
} else if(!strcmp(argv[i], "-is")){
|
255
|
+
iflags |= 1 << 1;
|
256
|
+
} else if(!strcmp(argv[i], "-in")){
|
257
|
+
iflags |= 1 << 2;
|
258
|
+
} else if(!strcmp(argv[i], "-it")){
|
259
|
+
iflags |= 1 << 3;
|
260
|
+
} else if(!strcmp(argv[i], "-if")){
|
261
|
+
iflags |= 1 << 4;
|
262
|
+
} else if(!strcmp(argv[i], "-ix")){
|
263
|
+
iflags |= 1 << 5;
|
264
|
+
} else if(!strcmp(argv[i], "-nl")){
|
265
|
+
omode |= TDBONOLCK;
|
266
|
+
} else if(!strcmp(argv[i], "-nb")){
|
267
|
+
omode |= TDBOLCKNB;
|
268
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
269
|
+
rnd = true;
|
270
|
+
} else {
|
271
|
+
usage();
|
272
|
+
}
|
273
|
+
} else if(!path){
|
274
|
+
path = argv[i];
|
275
|
+
} else if(!tstr){
|
276
|
+
tstr = argv[i];
|
277
|
+
} else if(!rstr){
|
278
|
+
rstr = argv[i];
|
279
|
+
} else if(!bstr){
|
280
|
+
bstr = argv[i];
|
281
|
+
} else if(!astr){
|
282
|
+
astr = argv[i];
|
283
|
+
} else if(!fstr){
|
284
|
+
fstr = argv[i];
|
285
|
+
} else {
|
286
|
+
usage();
|
287
|
+
}
|
288
|
+
}
|
289
|
+
if(!path || !tstr || !rstr) usage();
|
290
|
+
int tnum = tcatoix(tstr);
|
291
|
+
int rnum = tcatoix(rstr);
|
292
|
+
if(tnum < 1 || rnum < 1) usage();
|
293
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
294
|
+
int apow = astr ? tcatoix(astr) : -1;
|
295
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
296
|
+
int rv = procwrite(path, tnum, rnum, bnum, apow, fpow, opts, rcnum, lcnum, ncnum,
|
297
|
+
xmsiz, dfunit, iflags, omode, rnd);
|
298
|
+
return rv;
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
/* parse arguments of read command */
|
303
|
+
static int runread(int argc, char **argv){
|
304
|
+
char *path = NULL;
|
305
|
+
char *tstr = NULL;
|
306
|
+
int rcnum = 0;
|
307
|
+
int lcnum = 0;
|
308
|
+
int ncnum = 0;
|
309
|
+
int xmsiz = -1;
|
310
|
+
int dfunit = 0;
|
311
|
+
int omode = 0;
|
312
|
+
bool rnd = false;
|
313
|
+
for(int i = 2; i < argc; i++){
|
314
|
+
if(!path && argv[i][0] == '-'){
|
315
|
+
if(!strcmp(argv[i], "-rc")){
|
316
|
+
if(++i >= argc) usage();
|
317
|
+
rcnum = tcatoix(argv[i]);
|
318
|
+
} else if(!strcmp(argv[i], "-lc")){
|
319
|
+
if(++i >= argc) usage();
|
320
|
+
lcnum = tcatoix(argv[i]);
|
321
|
+
} else if(!strcmp(argv[i], "-nc")){
|
322
|
+
if(++i >= argc) usage();
|
323
|
+
ncnum = tcatoix(argv[i]);
|
324
|
+
} else if(!strcmp(argv[i], "-xm")){
|
325
|
+
if(++i >= argc) usage();
|
326
|
+
xmsiz = tcatoix(argv[i]);
|
327
|
+
} else if(!strcmp(argv[i], "-df")){
|
328
|
+
if(++i >= argc) usage();
|
329
|
+
dfunit = tcatoix(argv[i]);
|
330
|
+
} else if(!strcmp(argv[i], "-nl")){
|
331
|
+
omode |= TDBONOLCK;
|
332
|
+
} else if(!strcmp(argv[i], "-nb")){
|
333
|
+
omode |= TDBOLCKNB;
|
334
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
335
|
+
rnd = true;
|
336
|
+
} else {
|
337
|
+
usage();
|
338
|
+
}
|
339
|
+
} else if(!path){
|
340
|
+
path = argv[i];
|
341
|
+
} else if(!tstr){
|
342
|
+
tstr = argv[i];
|
343
|
+
} else {
|
344
|
+
usage();
|
345
|
+
}
|
346
|
+
}
|
347
|
+
if(!path || !tstr) usage();
|
348
|
+
int tnum = tcatoix(tstr);
|
349
|
+
if(tnum < 1) usage();
|
350
|
+
int rv = procread(path, tnum, rcnum, lcnum, ncnum, xmsiz, dfunit, omode, rnd);
|
351
|
+
return rv;
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
/* parse arguments of remove command */
|
356
|
+
static int runremove(int argc, char **argv){
|
357
|
+
char *path = NULL;
|
358
|
+
char *tstr = NULL;
|
359
|
+
int rcnum = 0;
|
360
|
+
int lcnum = 0;
|
361
|
+
int ncnum = 0;
|
362
|
+
int xmsiz = -1;
|
363
|
+
int dfunit = 0;
|
364
|
+
int omode = 0;
|
365
|
+
bool rnd = false;
|
366
|
+
for(int i = 2; i < argc; i++){
|
367
|
+
if(!path && argv[i][0] == '-'){
|
368
|
+
if(!strcmp(argv[i], "-rc")){
|
369
|
+
if(++i >= argc) usage();
|
370
|
+
rcnum = tcatoix(argv[i]);
|
371
|
+
} else if(!strcmp(argv[i], "-lc")){
|
372
|
+
if(++i >= argc) usage();
|
373
|
+
lcnum = tcatoix(argv[i]);
|
374
|
+
} else if(!strcmp(argv[i], "-nc")){
|
375
|
+
if(++i >= argc) usage();
|
376
|
+
ncnum = tcatoix(argv[i]);
|
377
|
+
} else if(!strcmp(argv[i], "-xm")){
|
378
|
+
if(++i >= argc) usage();
|
379
|
+
xmsiz = tcatoix(argv[i]);
|
380
|
+
} else if(!strcmp(argv[i], "-df")){
|
381
|
+
if(++i >= argc) usage();
|
382
|
+
dfunit = tcatoix(argv[i]);
|
383
|
+
} else if(!strcmp(argv[i], "-nl")){
|
384
|
+
omode |= TDBONOLCK;
|
385
|
+
} else if(!strcmp(argv[i], "-nb")){
|
386
|
+
omode |= TDBOLCKNB;
|
387
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
388
|
+
rnd = true;
|
389
|
+
} else {
|
390
|
+
usage();
|
391
|
+
}
|
392
|
+
} else if(!path){
|
393
|
+
path = argv[i];
|
394
|
+
} else if(!tstr){
|
395
|
+
tstr = argv[i];
|
396
|
+
} else {
|
397
|
+
usage();
|
398
|
+
}
|
399
|
+
}
|
400
|
+
if(!path || !tstr) usage();
|
401
|
+
int tnum = tcatoix(tstr);
|
402
|
+
if(tnum < 1) usage();
|
403
|
+
int rv = procremove(path, tnum, rcnum, lcnum, ncnum, xmsiz, dfunit, omode, rnd);
|
404
|
+
return rv;
|
405
|
+
}
|
406
|
+
|
407
|
+
|
408
|
+
/* parse arguments of wicked command */
|
409
|
+
static int runwicked(int argc, char **argv){
|
410
|
+
char *path = NULL;
|
411
|
+
char *tstr = NULL;
|
412
|
+
char *rstr = NULL;
|
413
|
+
int opts = 0;
|
414
|
+
int omode = 0;
|
415
|
+
for(int i = 2; i < argc; i++){
|
416
|
+
if(!path && argv[i][0] == '-'){
|
417
|
+
if(!strcmp(argv[i], "-tl")){
|
418
|
+
opts |= TDBTLARGE;
|
419
|
+
} else if(!strcmp(argv[i], "-td")){
|
420
|
+
opts |= TDBTDEFLATE;
|
421
|
+
} else if(!strcmp(argv[i], "-tb")){
|
422
|
+
opts |= TDBTBZIP;
|
423
|
+
} else if(!strcmp(argv[i], "-tt")){
|
424
|
+
opts |= TDBTTCBS;
|
425
|
+
} else if(!strcmp(argv[i], "-tx")){
|
426
|
+
opts |= TDBTEXCODEC;
|
427
|
+
} else if(!strcmp(argv[i], "-nl")){
|
428
|
+
omode |= TDBONOLCK;
|
429
|
+
} else if(!strcmp(argv[i], "-nb")){
|
430
|
+
omode |= TDBOLCKNB;
|
431
|
+
} else {
|
432
|
+
usage();
|
433
|
+
}
|
434
|
+
} else if(!path){
|
435
|
+
path = argv[i];
|
436
|
+
} else if(!tstr){
|
437
|
+
tstr = argv[i];
|
438
|
+
} else if(!rstr){
|
439
|
+
rstr = argv[i];
|
440
|
+
} else {
|
441
|
+
usage();
|
442
|
+
}
|
443
|
+
}
|
444
|
+
if(!path || !tstr || !rstr) usage();
|
445
|
+
int tnum = tcatoix(tstr);
|
446
|
+
int rnum = tcatoix(rstr);
|
447
|
+
if(tnum < 1 || rnum < 1) usage();
|
448
|
+
int rv = procwicked(path, tnum, rnum, opts, omode);
|
449
|
+
return rv;
|
450
|
+
}
|
451
|
+
|
452
|
+
|
453
|
+
/* parse arguments of typical command */
|
454
|
+
static int runtypical(int argc, char **argv){
|
455
|
+
char *path = NULL;
|
456
|
+
char *tstr = NULL;
|
457
|
+
char *rstr = NULL;
|
458
|
+
char *bstr = NULL;
|
459
|
+
char *astr = NULL;
|
460
|
+
char *fstr = NULL;
|
461
|
+
int opts = 0;
|
462
|
+
int rcnum = 0;
|
463
|
+
int lcnum = 0;
|
464
|
+
int ncnum = 0;
|
465
|
+
int xmsiz = -1;
|
466
|
+
int dfunit = 0;
|
467
|
+
int omode = 0;
|
468
|
+
int rratio = -1;
|
469
|
+
for(int i = 2; i < argc; i++){
|
470
|
+
if(!path && argv[i][0] == '-'){
|
471
|
+
if(!strcmp(argv[i], "-tl")){
|
472
|
+
opts |= TDBTLARGE;
|
473
|
+
} else if(!strcmp(argv[i], "-td")){
|
474
|
+
opts |= TDBTDEFLATE;
|
475
|
+
} else if(!strcmp(argv[i], "-tb")){
|
476
|
+
opts |= TDBTBZIP;
|
477
|
+
} else if(!strcmp(argv[i], "-tt")){
|
478
|
+
opts |= TDBTTCBS;
|
479
|
+
} else if(!strcmp(argv[i], "-tx")){
|
480
|
+
opts |= TDBTEXCODEC;
|
481
|
+
} else if(!strcmp(argv[i], "-rc")){
|
482
|
+
if(++i >= argc) usage();
|
483
|
+
rcnum = tcatoix(argv[i]);
|
484
|
+
} else if(!strcmp(argv[i], "-lc")){
|
485
|
+
if(++i >= argc) usage();
|
486
|
+
lcnum = tcatoix(argv[i]);
|
487
|
+
} else if(!strcmp(argv[i], "-nc")){
|
488
|
+
if(++i >= argc) usage();
|
489
|
+
ncnum = tcatoix(argv[i]);
|
490
|
+
} else if(!strcmp(argv[i], "-xm")){
|
491
|
+
if(++i >= argc) usage();
|
492
|
+
xmsiz = tcatoix(argv[i]);
|
493
|
+
} else if(!strcmp(argv[i], "-df")){
|
494
|
+
if(++i >= argc) usage();
|
495
|
+
dfunit = tcatoix(argv[i]);
|
496
|
+
} else if(!strcmp(argv[i], "-nl")){
|
497
|
+
omode |= TDBONOLCK;
|
498
|
+
} else if(!strcmp(argv[i], "-nb")){
|
499
|
+
omode |= TDBOLCKNB;
|
500
|
+
} else if(!strcmp(argv[i], "-rr")){
|
501
|
+
if(++i >= argc) usage();
|
502
|
+
rratio = tcatoix(argv[i]);
|
503
|
+
} else {
|
504
|
+
usage();
|
505
|
+
}
|
506
|
+
} else if(!path){
|
507
|
+
path = argv[i];
|
508
|
+
} else if(!tstr){
|
509
|
+
tstr = argv[i];
|
510
|
+
} else if(!rstr){
|
511
|
+
rstr = argv[i];
|
512
|
+
} else if(!bstr){
|
513
|
+
bstr = argv[i];
|
514
|
+
} else if(!astr){
|
515
|
+
astr = argv[i];
|
516
|
+
} else if(!fstr){
|
517
|
+
fstr = argv[i];
|
518
|
+
} else {
|
519
|
+
usage();
|
520
|
+
}
|
521
|
+
}
|
522
|
+
if(!path || !tstr || !rstr) usage();
|
523
|
+
int tnum = tcatoix(tstr);
|
524
|
+
int rnum = tcatoix(rstr);
|
525
|
+
if(tnum < 1 || rnum < 1) usage();
|
526
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
527
|
+
int apow = astr ? tcatoix(astr) : -1;
|
528
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
529
|
+
int rv = proctypical(path, tnum, rnum, bnum, apow, fpow, opts, rcnum, lcnum, ncnum,
|
530
|
+
xmsiz, dfunit, omode, rratio);
|
531
|
+
return rv;
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
/* perform write command */
|
536
|
+
static int procwrite(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
537
|
+
int opts, int rcnum, int lcnum, int ncnum, int xmsiz, int dfunit,
|
538
|
+
int iflags, int omode, bool rnd){
|
539
|
+
iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d bnum=%d apow=%d fpow=%d"
|
540
|
+
" opts=%d rcnum=%d lcnum=%d ncnum=%d xmsiz=%d dfunit=%d iflags=%d"
|
541
|
+
" omode=%d rnd=%d\n\n",
|
542
|
+
g_randseed, path, tnum, rnum, bnum, apow, fpow, opts, rcnum, lcnum, ncnum,
|
543
|
+
xmsiz, dfunit, iflags, omode, rnd);
|
544
|
+
bool err = false;
|
545
|
+
double stime = tctime();
|
546
|
+
TCTDB *tdb = tctdbnew();
|
547
|
+
if(g_dbgfd >= 0) tctdbsetdbgfd(tdb, g_dbgfd);
|
548
|
+
if(!tctdbsetmutex(tdb)){
|
549
|
+
eprint(tdb, __LINE__, "tctdbsetmutex");
|
550
|
+
err = true;
|
551
|
+
}
|
552
|
+
if(!tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
553
|
+
eprint(tdb, __LINE__, "tctdbsetcodecfunc");
|
554
|
+
err = true;
|
555
|
+
}
|
556
|
+
if(!tctdbtune(tdb, bnum, apow, fpow, opts)){
|
557
|
+
eprint(tdb, __LINE__, "tctdbtune");
|
558
|
+
err = true;
|
559
|
+
}
|
560
|
+
if(!tctdbsetcache(tdb, rcnum, lcnum, ncnum)){
|
561
|
+
eprint(tdb, __LINE__, "tctdbsetcache");
|
562
|
+
err = true;
|
563
|
+
}
|
564
|
+
if(xmsiz >= 0 && !tctdbsetxmsiz(tdb, xmsiz)){
|
565
|
+
eprint(tdb, __LINE__, "tctdbsetxmsiz");
|
566
|
+
err = true;
|
567
|
+
}
|
568
|
+
if(dfunit >= 0 && !tctdbsetdfunit(tdb, dfunit)){
|
569
|
+
eprint(tdb, __LINE__, "tctdbsetdfunit");
|
570
|
+
err = true;
|
571
|
+
}
|
572
|
+
if(!tctdbopen(tdb, path, TDBOWRITER | TDBOCREAT | TDBOTRUNC | omode)){
|
573
|
+
eprint(tdb, __LINE__, "tctdbopen");
|
574
|
+
err = true;
|
575
|
+
}
|
576
|
+
if((iflags & (1 << 0)) && !tctdbsetindex(tdb, "", TDBITDECIMAL)){
|
577
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
578
|
+
err = true;
|
579
|
+
}
|
580
|
+
if((iflags & (1 << 1)) && !tctdbsetindex(tdb, "str", TDBITLEXICAL)){
|
581
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
582
|
+
err = true;
|
583
|
+
}
|
584
|
+
if((iflags & (1 << 2)) && !tctdbsetindex(tdb, "num", TDBITDECIMAL)){
|
585
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
586
|
+
err = true;
|
587
|
+
}
|
588
|
+
if((iflags & (1 << 3)) && !tctdbsetindex(tdb, "type", TDBITDECIMAL)){
|
589
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
590
|
+
err = true;
|
591
|
+
}
|
592
|
+
if((iflags & (1 << 4)) && !tctdbsetindex(tdb, "flag", TDBITTOKEN)){
|
593
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
594
|
+
err = true;
|
595
|
+
}
|
596
|
+
if((iflags & (1 << 5)) && !tctdbsetindex(tdb, "text", TDBITQGRAM)){
|
597
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
598
|
+
err = true;
|
599
|
+
}
|
600
|
+
TARGWRITE targs[tnum];
|
601
|
+
pthread_t threads[tnum];
|
602
|
+
if(tnum == 1){
|
603
|
+
targs[0].tdb = tdb;
|
604
|
+
targs[0].rnum = rnum;
|
605
|
+
targs[0].rnd = rnd;
|
606
|
+
targs[0].id = 0;
|
607
|
+
if(threadwrite(targs) != NULL) err = true;
|
608
|
+
} else {
|
609
|
+
for(int i = 0; i < tnum; i++){
|
610
|
+
targs[i].tdb = tdb;
|
611
|
+
targs[i].rnum = rnum;
|
612
|
+
targs[i].rnd = rnd;
|
613
|
+
targs[i].id = i;
|
614
|
+
if(pthread_create(threads + i, NULL, threadwrite, targs + i) != 0){
|
615
|
+
eprint(tdb, __LINE__, "pthread_create");
|
616
|
+
targs[i].id = -1;
|
617
|
+
err = true;
|
618
|
+
}
|
619
|
+
}
|
620
|
+
for(int i = 0; i < tnum; i++){
|
621
|
+
if(targs[i].id == -1) continue;
|
622
|
+
void *rv;
|
623
|
+
if(pthread_join(threads[i], &rv) != 0){
|
624
|
+
eprint(tdb, __LINE__, "pthread_join");
|
625
|
+
err = true;
|
626
|
+
} else if(rv){
|
627
|
+
err = true;
|
628
|
+
}
|
629
|
+
}
|
630
|
+
}
|
631
|
+
iprintf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
|
632
|
+
iprintf("size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
|
633
|
+
sysprint();
|
634
|
+
if(!tctdbclose(tdb)){
|
635
|
+
eprint(tdb, __LINE__, "tctdbclose");
|
636
|
+
err = true;
|
637
|
+
}
|
638
|
+
tctdbdel(tdb);
|
639
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
640
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
641
|
+
return err ? 1 : 0;
|
642
|
+
}
|
643
|
+
|
644
|
+
|
645
|
+
/* perform read command */
|
646
|
+
static int procread(const char *path, int tnum, int rcnum, int lcnum, int ncnum,
|
647
|
+
int xmsiz, int dfunit, int omode, bool rnd){
|
648
|
+
iprintf("<Reading Test>\n seed=%u path=%s tnum=%d rcnum=%d lcnum=%d ncnum=%d"
|
649
|
+
" xmsiz=%d dfunit=%d omode=%d rnd=%d\n\n",
|
650
|
+
g_randseed, path, tnum, rcnum, lcnum, ncnum, xmsiz, dfunit, omode, rnd);
|
651
|
+
bool err = false;
|
652
|
+
double stime = tctime();
|
653
|
+
TCTDB *tdb = tctdbnew();
|
654
|
+
if(g_dbgfd >= 0) tctdbsetdbgfd(tdb, g_dbgfd);
|
655
|
+
if(!tctdbsetmutex(tdb)){
|
656
|
+
eprint(tdb, __LINE__, "tctdbsetmutex");
|
657
|
+
err = true;
|
658
|
+
}
|
659
|
+
if(!tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
660
|
+
eprint(tdb, __LINE__, "tctdbsetcodecfunc");
|
661
|
+
err = true;
|
662
|
+
}
|
663
|
+
if(!tctdbsetcache(tdb, rcnum, lcnum, ncnum)){
|
664
|
+
eprint(tdb, __LINE__, "tctdbsetcache");
|
665
|
+
err = true;
|
666
|
+
}
|
667
|
+
if(xmsiz >= 0 && !tctdbsetxmsiz(tdb, xmsiz)){
|
668
|
+
eprint(tdb, __LINE__, "tctdbsetxmsiz");
|
669
|
+
err = true;
|
670
|
+
}
|
671
|
+
if(dfunit >= 0 && !tctdbsetdfunit(tdb, dfunit)){
|
672
|
+
eprint(tdb, __LINE__, "tctdbsetdfunit");
|
673
|
+
err = true;
|
674
|
+
}
|
675
|
+
if(!tctdbopen(tdb, path, TDBOREADER | omode)){
|
676
|
+
eprint(tdb, __LINE__, "tctdbopen");
|
677
|
+
err = true;
|
678
|
+
}
|
679
|
+
int rnum = tctdbrnum(tdb) / tnum;
|
680
|
+
TARGREAD targs[tnum];
|
681
|
+
pthread_t threads[tnum];
|
682
|
+
if(tnum == 1){
|
683
|
+
targs[0].tdb = tdb;
|
684
|
+
targs[0].rnum = rnum;
|
685
|
+
targs[0].rnd = rnd;
|
686
|
+
targs[0].id = 0;
|
687
|
+
if(threadread(targs) != NULL) err = true;
|
688
|
+
} else {
|
689
|
+
for(int i = 0; i < tnum; i++){
|
690
|
+
targs[i].tdb = tdb;
|
691
|
+
targs[i].rnum = rnum;
|
692
|
+
targs[i].rnd = rnd;
|
693
|
+
targs[i].id = i;
|
694
|
+
if(pthread_create(threads + i, NULL, threadread, targs + i) != 0){
|
695
|
+
eprint(tdb, __LINE__, "pthread_create");
|
696
|
+
targs[i].id = -1;
|
697
|
+
err = true;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
for(int i = 0; i < tnum; i++){
|
701
|
+
if(targs[i].id == -1) continue;
|
702
|
+
void *rv;
|
703
|
+
if(pthread_join(threads[i], &rv) != 0){
|
704
|
+
eprint(tdb, __LINE__, "pthread_join");
|
705
|
+
err = true;
|
706
|
+
} else if(rv){
|
707
|
+
err = true;
|
708
|
+
}
|
709
|
+
}
|
710
|
+
}
|
711
|
+
iprintf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
|
712
|
+
iprintf("size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
|
713
|
+
sysprint();
|
714
|
+
if(!tctdbclose(tdb)){
|
715
|
+
eprint(tdb, __LINE__, "tctdbclose");
|
716
|
+
err = true;
|
717
|
+
}
|
718
|
+
tctdbdel(tdb);
|
719
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
720
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
721
|
+
return err ? 1 : 0;
|
722
|
+
}
|
723
|
+
|
724
|
+
|
725
|
+
/* perform remove command */
|
726
|
+
static int procremove(const char *path, int tnum, int rcnum, int lcnum, int ncnum,
|
727
|
+
int xmsiz, int dfunit, int omode, bool rnd){
|
728
|
+
iprintf("<Removing Test>\n seed=%u path=%s tnum=%d rcnum=%d lcnum=%d ncnum=%d"
|
729
|
+
" xmsiz=%d dfunit=%d omode=%d rnd=%d\n\n",
|
730
|
+
g_randseed, path, tnum, rcnum, lcnum, ncnum, xmsiz, dfunit, omode, rnd);
|
731
|
+
bool err = false;
|
732
|
+
double stime = tctime();
|
733
|
+
TCTDB *tdb = tctdbnew();
|
734
|
+
if(g_dbgfd >= 0) tctdbsetdbgfd(tdb, g_dbgfd);
|
735
|
+
if(!tctdbsetmutex(tdb)){
|
736
|
+
eprint(tdb, __LINE__, "tctdbsetmutex");
|
737
|
+
err = true;
|
738
|
+
}
|
739
|
+
if(!tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
740
|
+
eprint(tdb, __LINE__, "tctdbsetcodecfunc");
|
741
|
+
err = true;
|
742
|
+
}
|
743
|
+
if(!tctdbsetcache(tdb, rcnum, lcnum, ncnum)){
|
744
|
+
eprint(tdb, __LINE__, "tctdbsetcache");
|
745
|
+
err = true;
|
746
|
+
}
|
747
|
+
if(xmsiz >= 0 && !tctdbsetxmsiz(tdb, xmsiz)){
|
748
|
+
eprint(tdb, __LINE__, "tctdbsetxmsiz");
|
749
|
+
err = true;
|
750
|
+
}
|
751
|
+
if(dfunit >= 0 && !tctdbsetdfunit(tdb, dfunit)){
|
752
|
+
eprint(tdb, __LINE__, "tctdbsetdfunit");
|
753
|
+
err = true;
|
754
|
+
}
|
755
|
+
if(!tctdbopen(tdb, path, TDBOWRITER | omode)){
|
756
|
+
eprint(tdb, __LINE__, "tctdbopen");
|
757
|
+
err = true;
|
758
|
+
}
|
759
|
+
int rnum = tctdbrnum(tdb) / tnum;
|
760
|
+
TARGREMOVE targs[tnum];
|
761
|
+
pthread_t threads[tnum];
|
762
|
+
if(tnum == 1){
|
763
|
+
targs[0].tdb = tdb;
|
764
|
+
targs[0].rnum = rnum;
|
765
|
+
targs[0].rnd = rnd;
|
766
|
+
targs[0].id = 0;
|
767
|
+
if(threadremove(targs) != NULL) err = true;
|
768
|
+
} else {
|
769
|
+
for(int i = 0; i < tnum; i++){
|
770
|
+
targs[i].tdb = tdb;
|
771
|
+
targs[i].rnum = rnum;
|
772
|
+
targs[i].rnd = rnd;
|
773
|
+
targs[i].id = i;
|
774
|
+
if(pthread_create(threads + i, NULL, threadremove, targs + i) != 0){
|
775
|
+
eprint(tdb, __LINE__, "pthread_create");
|
776
|
+
targs[i].id = -1;
|
777
|
+
err = true;
|
778
|
+
}
|
779
|
+
}
|
780
|
+
for(int i = 0; i < tnum; i++){
|
781
|
+
if(targs[i].id == -1) continue;
|
782
|
+
void *rv;
|
783
|
+
if(pthread_join(threads[i], &rv) != 0){
|
784
|
+
eprint(tdb, __LINE__, "pthread_join");
|
785
|
+
err = true;
|
786
|
+
} else if(rv){
|
787
|
+
err = true;
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}
|
791
|
+
iprintf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
|
792
|
+
iprintf("size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
|
793
|
+
sysprint();
|
794
|
+
if(!tctdbclose(tdb)){
|
795
|
+
eprint(tdb, __LINE__, "tctdbclose");
|
796
|
+
err = true;
|
797
|
+
}
|
798
|
+
tctdbdel(tdb);
|
799
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
800
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
801
|
+
return err ? 1 : 0;
|
802
|
+
}
|
803
|
+
|
804
|
+
|
805
|
+
/* perform wicked command */
|
806
|
+
static int procwicked(const char *path, int tnum, int rnum, int opts, int omode){
|
807
|
+
iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d opts=%d omode=%d\n\n",
|
808
|
+
g_randseed, path, tnum, rnum, opts, omode);
|
809
|
+
bool err = false;
|
810
|
+
double stime = tctime();
|
811
|
+
TCTDB *tdb = tctdbnew();
|
812
|
+
if(g_dbgfd >= 0) tctdbsetdbgfd(tdb, g_dbgfd);
|
813
|
+
if(!tctdbsetmutex(tdb)){
|
814
|
+
eprint(tdb, __LINE__, "tctdbsetmutex");
|
815
|
+
err = true;
|
816
|
+
}
|
817
|
+
if(!tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
818
|
+
eprint(tdb, __LINE__, "tctdbsetcodecfunc");
|
819
|
+
err = true;
|
820
|
+
}
|
821
|
+
if(!tctdbtune(tdb, rnum / 50, 2, -1, opts)){
|
822
|
+
eprint(tdb, __LINE__, "tctdbtune");
|
823
|
+
err = true;
|
824
|
+
}
|
825
|
+
if(!tctdbsetcache(tdb, rnum / 10, 128, 256)){
|
826
|
+
eprint(tdb, __LINE__, "tctdbsetcache");
|
827
|
+
err = true;
|
828
|
+
}
|
829
|
+
if(!tctdbsetxmsiz(tdb, rnum * sizeof(int))){
|
830
|
+
eprint(tdb, __LINE__, "tctdbsetxmsiz");
|
831
|
+
err = true;
|
832
|
+
}
|
833
|
+
if(!tctdbsetdfunit(tdb, 8)){
|
834
|
+
eprint(tdb, __LINE__, "tctdbsetdfunit");
|
835
|
+
err = true;
|
836
|
+
}
|
837
|
+
if(!tctdbsetinvcache(tdb, -1, 0.5)){
|
838
|
+
eprint(tdb, __LINE__, "tctdbsetinvcache");
|
839
|
+
err = true;
|
840
|
+
}
|
841
|
+
if(!tctdbopen(tdb, path, TDBOWRITER | TDBOCREAT | TDBOTRUNC | omode)){
|
842
|
+
eprint(tdb, __LINE__, "tctdbopen");
|
843
|
+
err = true;
|
844
|
+
}
|
845
|
+
if(!tctdbsetindex(tdb, "", TDBITDECIMAL)){
|
846
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
847
|
+
err = true;
|
848
|
+
}
|
849
|
+
if(!tctdbsetindex(tdb, "str", TDBITLEXICAL)){
|
850
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
851
|
+
err = true;
|
852
|
+
}
|
853
|
+
if(!tctdbsetindex(tdb, "num", TDBITDECIMAL)){
|
854
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
855
|
+
err = true;
|
856
|
+
}
|
857
|
+
if(!tctdbsetindex(tdb, "type", TDBITDECIMAL)){
|
858
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
859
|
+
err = true;
|
860
|
+
}
|
861
|
+
if(!tctdbsetindex(tdb, "flag", TDBITTOKEN)){
|
862
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
863
|
+
err = true;
|
864
|
+
}
|
865
|
+
if(!tctdbsetindex(tdb, "text", TDBITQGRAM)){
|
866
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
867
|
+
err = true;
|
868
|
+
}
|
869
|
+
if(!tctdbiterinit(tdb)){
|
870
|
+
eprint(tdb, __LINE__, "tctdbiterinit");
|
871
|
+
err = true;
|
872
|
+
}
|
873
|
+
TARGWICKED targs[tnum];
|
874
|
+
pthread_t threads[tnum];
|
875
|
+
if(tnum == 1){
|
876
|
+
targs[0].tdb = tdb;
|
877
|
+
targs[0].rnum = rnum;
|
878
|
+
targs[0].id = 0;
|
879
|
+
if(threadwicked(targs) != NULL) err = true;
|
880
|
+
} else {
|
881
|
+
for(int i = 0; i < tnum; i++){
|
882
|
+
targs[i].tdb = tdb;
|
883
|
+
targs[i].rnum = rnum;
|
884
|
+
targs[i].id = i;
|
885
|
+
if(pthread_create(threads + i, NULL, threadwicked, targs + i) != 0){
|
886
|
+
eprint(tdb, __LINE__, "pthread_create");
|
887
|
+
targs[i].id = -1;
|
888
|
+
err = true;
|
889
|
+
}
|
890
|
+
}
|
891
|
+
for(int i = 0; i < tnum; i++){
|
892
|
+
if(targs[i].id == -1) continue;
|
893
|
+
void *rv;
|
894
|
+
if(pthread_join(threads[i], &rv) != 0){
|
895
|
+
eprint(tdb, __LINE__, "pthread_join");
|
896
|
+
err = true;
|
897
|
+
} else if(rv){
|
898
|
+
err = true;
|
899
|
+
}
|
900
|
+
}
|
901
|
+
}
|
902
|
+
iprintf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
|
903
|
+
iprintf("size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
|
904
|
+
sysprint();
|
905
|
+
if(!tctdbclose(tdb)){
|
906
|
+
eprint(tdb, __LINE__, "tctdbclose");
|
907
|
+
err = true;
|
908
|
+
}
|
909
|
+
tctdbdel(tdb);
|
910
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
911
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
912
|
+
return err ? 1 : 0;
|
913
|
+
}
|
914
|
+
|
915
|
+
|
916
|
+
/* perform typical command */
|
917
|
+
static int proctypical(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
918
|
+
int opts, int rcnum, int lcnum, int ncnum, int xmsiz, int dfunit,
|
919
|
+
int omode, int rratio){
|
920
|
+
iprintf("<Typical Access Test>\n seed=%u path=%s tnum=%d rnum=%d bnum=%d apow=%d"
|
921
|
+
" fpow=%d opts=%d rcnum=%d lcnum=%d ncnum=%d xmsiz=%d dfunit=%d"
|
922
|
+
" omode=%d rratio=%d\n\n",
|
923
|
+
g_randseed, path, tnum, rnum, bnum, apow, fpow, opts, rcnum, lcnum, ncnum,
|
924
|
+
xmsiz, dfunit, omode, rratio);
|
925
|
+
bool err = false;
|
926
|
+
double stime = tctime();
|
927
|
+
TCTDB *tdb = tctdbnew();
|
928
|
+
if(g_dbgfd >= 0) tctdbsetdbgfd(tdb, g_dbgfd);
|
929
|
+
if(!tctdbsetmutex(tdb)){
|
930
|
+
eprint(tdb, __LINE__, "tctdbsetmutex");
|
931
|
+
err = true;
|
932
|
+
}
|
933
|
+
if(!tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
934
|
+
eprint(tdb, __LINE__, "tctdbsetcodecfunc");
|
935
|
+
err = true;
|
936
|
+
}
|
937
|
+
if(!tctdbtune(tdb, bnum, apow, fpow, opts)){
|
938
|
+
eprint(tdb, __LINE__, "tctdbtune");
|
939
|
+
err = true;
|
940
|
+
}
|
941
|
+
if(!tctdbsetcache(tdb, rcnum, lcnum, ncnum)){
|
942
|
+
eprint(tdb, __LINE__, "tctdbsetcache");
|
943
|
+
err = true;
|
944
|
+
}
|
945
|
+
if(xmsiz >= 0 && !tctdbsetxmsiz(tdb, xmsiz)){
|
946
|
+
eprint(tdb, __LINE__, "tctdbsetxmsiz");
|
947
|
+
err = true;
|
948
|
+
}
|
949
|
+
if(dfunit >= 0 && !tctdbsetdfunit(tdb, dfunit)){
|
950
|
+
eprint(tdb, __LINE__, "tctdbsetdfunit");
|
951
|
+
err = true;
|
952
|
+
}
|
953
|
+
if(!tctdbopen(tdb, path, TDBOWRITER | TDBOCREAT | TDBOTRUNC | omode)){
|
954
|
+
eprint(tdb, __LINE__, "tctdbopen");
|
955
|
+
err = true;
|
956
|
+
}
|
957
|
+
if(!tctdbsetindex(tdb, "", TDBITDECIMAL)){
|
958
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
959
|
+
err = true;
|
960
|
+
}
|
961
|
+
if(!tctdbsetindex(tdb, "str", TDBITLEXICAL)){
|
962
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
963
|
+
err = true;
|
964
|
+
}
|
965
|
+
if(!tctdbsetindex(tdb, "num", TDBITDECIMAL)){
|
966
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
967
|
+
err = true;
|
968
|
+
}
|
969
|
+
if(!tctdbsetindex(tdb, "type", TDBITDECIMAL)){
|
970
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
971
|
+
err = true;
|
972
|
+
}
|
973
|
+
if(!tctdbsetindex(tdb, "flag", TDBITTOKEN)){
|
974
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
975
|
+
err = true;
|
976
|
+
}
|
977
|
+
if(!tctdbsetindex(tdb, "text", TDBITQGRAM)){
|
978
|
+
eprint(tdb, __LINE__, "tctdbsetindex");
|
979
|
+
err = true;
|
980
|
+
}
|
981
|
+
TARGTYPICAL targs[tnum];
|
982
|
+
pthread_t threads[tnum];
|
983
|
+
if(tnum == 1){
|
984
|
+
targs[0].tdb = tdb;
|
985
|
+
targs[0].rnum = rnum;
|
986
|
+
targs[0].rratio = rratio;
|
987
|
+
targs[0].id = 0;
|
988
|
+
if(threadtypical(targs) != NULL) err = true;
|
989
|
+
} else {
|
990
|
+
for(int i = 0; i < tnum; i++){
|
991
|
+
targs[i].tdb = tdb;
|
992
|
+
targs[i].rnum = rnum;
|
993
|
+
targs[i].rratio= rratio;
|
994
|
+
targs[i].id = i;
|
995
|
+
if(pthread_create(threads + i, NULL, threadtypical, targs + i) != 0){
|
996
|
+
eprint(tdb, __LINE__, "pthread_create");
|
997
|
+
targs[i].id = -1;
|
998
|
+
err = true;
|
999
|
+
}
|
1000
|
+
}
|
1001
|
+
for(int i = 0; i < tnum; i++){
|
1002
|
+
if(targs[i].id == -1) continue;
|
1003
|
+
void *rv;
|
1004
|
+
if(pthread_join(threads[i], &rv) != 0){
|
1005
|
+
eprint(tdb, __LINE__, "pthread_join");
|
1006
|
+
err = true;
|
1007
|
+
} else if(rv){
|
1008
|
+
err = true;
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
iprintf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
|
1013
|
+
iprintf("size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
|
1014
|
+
sysprint();
|
1015
|
+
if(!tctdbclose(tdb)){
|
1016
|
+
eprint(tdb, __LINE__, "tctdbclose");
|
1017
|
+
err = true;
|
1018
|
+
}
|
1019
|
+
tctdbdel(tdb);
|
1020
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
1021
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
1022
|
+
return err ? 1 : 0;
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
|
1026
|
+
/* thread the write function */
|
1027
|
+
static void *threadwrite(void *targ){
|
1028
|
+
TCTDB *tdb = ((TARGWRITE *)targ)->tdb;
|
1029
|
+
int rnum = ((TARGWRITE *)targ)->rnum;
|
1030
|
+
bool rnd = ((TARGWRITE *)targ)->rnd;
|
1031
|
+
int id = ((TARGWRITE *)targ)->id;
|
1032
|
+
bool err = false;
|
1033
|
+
int base = id * rnum;
|
1034
|
+
for(int i = 1; i <= rnum; i++){
|
1035
|
+
int uid = rnd ? (base + myrand(i) + 1) : tctdbgenuid(tdb);
|
1036
|
+
char pkbuf[RECBUFSIZ];
|
1037
|
+
int pksiz = sprintf(pkbuf, "%d", uid);
|
1038
|
+
TCMAP *cols = tcmapnew2(7);
|
1039
|
+
char vbuf[RECBUFSIZ*5];
|
1040
|
+
int vsiz = sprintf(vbuf, "%d", uid);
|
1041
|
+
tcmapput(cols, "str", 3, vbuf, vsiz);
|
1042
|
+
if(myrand(3) == 0){
|
1043
|
+
vsiz = sprintf(vbuf, "%.2f", (myrand(i * 100) + 1) / 100.0);
|
1044
|
+
} else {
|
1045
|
+
vsiz = sprintf(vbuf, "%d", myrand(i) + 1);
|
1046
|
+
}
|
1047
|
+
tcmapput(cols, "num", 3, vbuf, vsiz);
|
1048
|
+
vsiz = sprintf(vbuf, "%d", myrand(32) + 1);
|
1049
|
+
tcmapput(cols, "type", 4, vbuf, vsiz);
|
1050
|
+
int num = myrand(5);
|
1051
|
+
int pt = 0;
|
1052
|
+
char *wp = vbuf;
|
1053
|
+
for(int j = 0; j < num; j++){
|
1054
|
+
pt += myrand(5) + 1;
|
1055
|
+
if(wp > vbuf) *(wp++) = ',';
|
1056
|
+
wp += sprintf(wp, "%d", pt);
|
1057
|
+
}
|
1058
|
+
*wp = '\0';
|
1059
|
+
if(*vbuf != '\0'){
|
1060
|
+
tcmapput(cols, "flag", 4, vbuf, wp - vbuf);
|
1061
|
+
tcmapput(cols, "text", 4, vbuf, wp - vbuf);
|
1062
|
+
}
|
1063
|
+
if(!tctdbput(tdb, pkbuf, pksiz, cols)){
|
1064
|
+
eprint(tdb, __LINE__, "tctdbput");
|
1065
|
+
err = true;
|
1066
|
+
break;
|
1067
|
+
}
|
1068
|
+
tcmapdel(cols);
|
1069
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1070
|
+
iputchar('.');
|
1071
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
return err ? "error" : NULL;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
|
1078
|
+
/* thread the read function */
|
1079
|
+
static void *threadread(void *targ){
|
1080
|
+
TCTDB *tdb = ((TARGREAD *)targ)->tdb;
|
1081
|
+
int rnum = ((TARGREAD *)targ)->rnum;
|
1082
|
+
bool rnd = ((TARGREAD *)targ)->rnd;
|
1083
|
+
int id = ((TARGREAD *)targ)->id;
|
1084
|
+
bool err = false;
|
1085
|
+
int base = id * rnum;
|
1086
|
+
for(int i = 1; i <= rnum && !err; i++){
|
1087
|
+
char pkbuf[RECBUFSIZ];
|
1088
|
+
int pksiz = sprintf(pkbuf, "%d", base + (rnd ? myrandnd(i) : i));
|
1089
|
+
TCMAP *cols = tctdbget(tdb, pkbuf, pksiz);
|
1090
|
+
if(cols){
|
1091
|
+
tcmapdel(cols);
|
1092
|
+
} else if(!rnd || tctdbecode(tdb) != TCENOREC){
|
1093
|
+
eprint(tdb, __LINE__, "tctdbget");
|
1094
|
+
err = true;
|
1095
|
+
}
|
1096
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1097
|
+
iputchar('.');
|
1098
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
return err ? "error" : NULL;
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
|
1105
|
+
/* thread the remove function */
|
1106
|
+
static void *threadremove(void *targ){
|
1107
|
+
TCTDB *tdb = ((TARGREMOVE *)targ)->tdb;
|
1108
|
+
int rnum = ((TARGREMOVE *)targ)->rnum;
|
1109
|
+
bool rnd = ((TARGREMOVE *)targ)->rnd;
|
1110
|
+
int id = ((TARGREMOVE *)targ)->id;
|
1111
|
+
bool err = false;
|
1112
|
+
int base = id * rnum;
|
1113
|
+
for(int i = 1; i <= rnum; i++){
|
1114
|
+
char pkbuf[RECBUFSIZ];
|
1115
|
+
int pksiz = sprintf(pkbuf, "%d", base + (rnd ? myrand(i + 1) : i));
|
1116
|
+
if(!tctdbout(tdb, pkbuf, pksiz) && (!rnd || tctdbecode(tdb) != TCENOREC)){
|
1117
|
+
eprint(tdb, __LINE__, "tctdbout");
|
1118
|
+
err = true;
|
1119
|
+
break;
|
1120
|
+
}
|
1121
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1122
|
+
iputchar('.');
|
1123
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1124
|
+
}
|
1125
|
+
}
|
1126
|
+
return err ? "error" : NULL;
|
1127
|
+
}
|
1128
|
+
|
1129
|
+
|
1130
|
+
/* thread the wicked function */
|
1131
|
+
static void *threadwicked(void *targ){
|
1132
|
+
TCTDB *tdb = ((TARGWICKED *)targ)->tdb;
|
1133
|
+
int rnum = ((TARGWICKED *)targ)->rnum;
|
1134
|
+
int id = ((TARGWICKED *)targ)->id;
|
1135
|
+
bool err = false;
|
1136
|
+
const char *names[] = { "", "str", "num", "type", "flag", "c1" };
|
1137
|
+
int ops[] = { TDBQCSTREQ, TDBQCSTRINC, TDBQCSTRBW, TDBQCSTREW, TDBQCSTRAND, TDBQCSTROR,
|
1138
|
+
TDBQCSTROREQ, TDBQCSTRRX, TDBQCNUMEQ, TDBQCNUMGT, TDBQCNUMGE, TDBQCNUMLT,
|
1139
|
+
TDBQCNUMLE, TDBQCNUMBT, TDBQCNUMOREQ };
|
1140
|
+
int ftsops[] = { TDBQCFTSPH, TDBQCFTSAND, TDBQCFTSOR, TDBQCFTSEX };
|
1141
|
+
int types[] = { TDBQOSTRASC, TDBQOSTRDESC, TDBQONUMASC, TDBQONUMDESC };
|
1142
|
+
for(int i = 1; i <= rnum && !err; i++){
|
1143
|
+
char pkbuf[RECBUFSIZ];
|
1144
|
+
int pksiz = sprintf(pkbuf, "%d", myrand(rnum * (id + 1)));
|
1145
|
+
TCMAP *cols = tcmapnew2(7);
|
1146
|
+
char vbuf[RECBUFSIZ*5];
|
1147
|
+
int vsiz = sprintf(vbuf, "%d", id);
|
1148
|
+
tcmapput(cols, "str", 3, vbuf, vsiz);
|
1149
|
+
if(myrand(3) == 0){
|
1150
|
+
vsiz = sprintf(vbuf, "%.2f", (myrand(i * 100) + 1) / 100.0);
|
1151
|
+
} else {
|
1152
|
+
vsiz = sprintf(vbuf, "%d", myrand(i) + 1);
|
1153
|
+
}
|
1154
|
+
tcmapput(cols, "num", 3, vbuf, vsiz);
|
1155
|
+
vsiz = sprintf(vbuf, "%d", myrand(32) + 1);
|
1156
|
+
tcmapput(cols, "type", 4, vbuf, vsiz);
|
1157
|
+
int num = myrand(5);
|
1158
|
+
int pt = 0;
|
1159
|
+
char *wp = vbuf;
|
1160
|
+
for(int j = 0; j < num; j++){
|
1161
|
+
pt += myrand(5) + 1;
|
1162
|
+
if(wp > vbuf) *(wp++) = ',';
|
1163
|
+
wp += sprintf(wp, "%d", pt);
|
1164
|
+
}
|
1165
|
+
*wp = '\0';
|
1166
|
+
if(*vbuf != '\0'){
|
1167
|
+
tcmapput(cols, "flag", 4, vbuf, wp - vbuf);
|
1168
|
+
tcmapput(cols, "text", 4, vbuf, wp - vbuf);
|
1169
|
+
}
|
1170
|
+
char nbuf[RECBUFSIZ];
|
1171
|
+
int nsiz = sprintf(nbuf, "c%d", myrand(i) + 1);
|
1172
|
+
vsiz = sprintf(vbuf, "%d", myrand(i) + 1);
|
1173
|
+
tcmapput(cols, nbuf, nsiz, vbuf, vsiz);
|
1174
|
+
char *cbuf;
|
1175
|
+
int csiz;
|
1176
|
+
TCMAP *ncols;
|
1177
|
+
TDBQRY *qry;
|
1178
|
+
switch(myrand(17)){
|
1179
|
+
case 0:
|
1180
|
+
if(id == 0) iputchar('0');
|
1181
|
+
if(!tctdbput(tdb, pkbuf, pksiz, cols)){
|
1182
|
+
eprint(tdb, __LINE__, "tctdbput");
|
1183
|
+
err = true;
|
1184
|
+
}
|
1185
|
+
break;
|
1186
|
+
case 1:
|
1187
|
+
if(id == 0) iputchar('1');
|
1188
|
+
cbuf = tcstrjoin4(cols, &csiz);
|
1189
|
+
if(!tctdbput2(tdb, pkbuf, pksiz, cbuf, csiz)){
|
1190
|
+
eprint(tdb, __LINE__, "tctdbput2");
|
1191
|
+
err = true;
|
1192
|
+
}
|
1193
|
+
tcfree(cbuf);
|
1194
|
+
break;
|
1195
|
+
case 2:
|
1196
|
+
if(id == 0) iputchar('2');
|
1197
|
+
cbuf = tcstrjoin3(cols, '\t');
|
1198
|
+
if(!tctdbput3(tdb, pkbuf, cbuf)){
|
1199
|
+
eprint(tdb, __LINE__, "tctdbput3");
|
1200
|
+
err = true;
|
1201
|
+
}
|
1202
|
+
tcfree(cbuf);
|
1203
|
+
break;
|
1204
|
+
case 3:
|
1205
|
+
if(id == 0) iputchar('3');
|
1206
|
+
if(!tctdbputkeep(tdb, pkbuf, pksiz, cols) && tctdbecode(tdb) != TCEKEEP){
|
1207
|
+
eprint(tdb, __LINE__, "tctdbputkeep");
|
1208
|
+
err = true;
|
1209
|
+
}
|
1210
|
+
break;
|
1211
|
+
case 4:
|
1212
|
+
if(id == 0) iputchar('4');
|
1213
|
+
cbuf = tcstrjoin4(cols, &csiz);
|
1214
|
+
if(!tctdbputkeep2(tdb, pkbuf, pksiz, cbuf, csiz) && tctdbecode(tdb) != TCEKEEP){
|
1215
|
+
eprint(tdb, __LINE__, "tctdbputkeep2");
|
1216
|
+
err = true;
|
1217
|
+
}
|
1218
|
+
tcfree(cbuf);
|
1219
|
+
break;
|
1220
|
+
case 5:
|
1221
|
+
if(id == 0) iputchar('5');
|
1222
|
+
cbuf = tcstrjoin3(cols, '\t');
|
1223
|
+
if(!tctdbputkeep3(tdb, pkbuf, cbuf) && tctdbecode(tdb) != TCEKEEP){
|
1224
|
+
eprint(tdb, __LINE__, "tctdbputkeep3");
|
1225
|
+
err = true;
|
1226
|
+
}
|
1227
|
+
tcfree(cbuf);
|
1228
|
+
break;
|
1229
|
+
case 6:
|
1230
|
+
if(id == 0) iputchar('6');
|
1231
|
+
if(!tctdbputcat(tdb, pkbuf, pksiz, cols)){
|
1232
|
+
eprint(tdb, __LINE__, "tctdbputcat");
|
1233
|
+
err = true;
|
1234
|
+
}
|
1235
|
+
break;
|
1236
|
+
case 7:
|
1237
|
+
if(id == 0) iputchar('7');
|
1238
|
+
cbuf = tcstrjoin4(cols, &csiz);
|
1239
|
+
if(!tctdbputcat2(tdb, pkbuf, pksiz, cbuf, csiz)){
|
1240
|
+
eprint(tdb, __LINE__, "tctdbputcat2");
|
1241
|
+
err = true;
|
1242
|
+
}
|
1243
|
+
tcfree(cbuf);
|
1244
|
+
break;
|
1245
|
+
case 8:
|
1246
|
+
if(id == 0) iputchar('8');
|
1247
|
+
cbuf = tcstrjoin3(cols, '\t');
|
1248
|
+
if(!tctdbputcat3(tdb, pkbuf, cbuf)){
|
1249
|
+
eprint(tdb, __LINE__, "tctdbputcat3");
|
1250
|
+
err = true;
|
1251
|
+
}
|
1252
|
+
tcfree(cbuf);
|
1253
|
+
break;
|
1254
|
+
case 9:
|
1255
|
+
if(id == 0) iputchar('9');
|
1256
|
+
if(myrand(2) == 0){
|
1257
|
+
if(!tctdbout(tdb, pkbuf, pksiz) && tctdbecode(tdb) != TCENOREC){
|
1258
|
+
eprint(tdb, __LINE__, "tctdbout");
|
1259
|
+
err = true;
|
1260
|
+
}
|
1261
|
+
}
|
1262
|
+
break;
|
1263
|
+
case 10:
|
1264
|
+
if(id == 0) iputchar('A');
|
1265
|
+
if(myrand(2) == 0){
|
1266
|
+
if(!tctdbout2(tdb, pkbuf) && tctdbecode(tdb) != TCENOREC){
|
1267
|
+
eprint(tdb, __LINE__, "tctdbout2");
|
1268
|
+
err = true;
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
break;
|
1272
|
+
case 11:
|
1273
|
+
if(id == 0) iputchar('B');
|
1274
|
+
ncols = tctdbget(tdb, pkbuf, pksiz);
|
1275
|
+
if(ncols){
|
1276
|
+
tcmapdel(ncols);
|
1277
|
+
} else if(tctdbecode(tdb) != TCENOREC){
|
1278
|
+
eprint(tdb, __LINE__, "tctdbget");
|
1279
|
+
err = true;
|
1280
|
+
}
|
1281
|
+
break;
|
1282
|
+
case 12:
|
1283
|
+
if(id == 0) iputchar('C');
|
1284
|
+
cbuf = tctdbget2(tdb, pkbuf, pksiz, &csiz);
|
1285
|
+
if(cbuf){
|
1286
|
+
tcfree(cbuf);
|
1287
|
+
} else if(tctdbecode(tdb) != TCENOREC){
|
1288
|
+
eprint(tdb, __LINE__, "tctdbget2");
|
1289
|
+
err = true;
|
1290
|
+
}
|
1291
|
+
break;
|
1292
|
+
case 13:
|
1293
|
+
if(id == 0) iputchar('D');
|
1294
|
+
cbuf = tctdbget3(tdb, pkbuf);
|
1295
|
+
if(cbuf){
|
1296
|
+
tcfree(cbuf);
|
1297
|
+
} else if(tctdbecode(tdb) != TCENOREC){
|
1298
|
+
eprint(tdb, __LINE__, "tctdbget3");
|
1299
|
+
err = true;
|
1300
|
+
}
|
1301
|
+
break;
|
1302
|
+
case 14:
|
1303
|
+
if(id == 0) iputchar('E');
|
1304
|
+
if(myrand(rnum / 50) == 0){
|
1305
|
+
if(!tctdbiterinit(tdb)){
|
1306
|
+
eprint(tdb, __LINE__, "tctdbiterinit");
|
1307
|
+
err = true;
|
1308
|
+
}
|
1309
|
+
}
|
1310
|
+
for(int j = myrand(rnum) / 1000 + 1; j >= 0; j--){
|
1311
|
+
int iksiz;
|
1312
|
+
char *ikbuf = tctdbiternext(tdb, &iksiz);
|
1313
|
+
if(ikbuf){
|
1314
|
+
tcfree(ikbuf);
|
1315
|
+
} else {
|
1316
|
+
int ecode = tctdbecode(tdb);
|
1317
|
+
if(ecode != TCEINVALID && ecode != TCENOREC){
|
1318
|
+
eprint(tdb, __LINE__, "tctdbiternext");
|
1319
|
+
err = true;
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
break;
|
1324
|
+
case 15:
|
1325
|
+
if(id == 0) iputchar('F');
|
1326
|
+
qry = tctdbqrynew(tdb);
|
1327
|
+
if(myrand(10) != 0){
|
1328
|
+
char expr[RECBUFSIZ];
|
1329
|
+
sprintf(expr, "%d", myrand(i) + 1);
|
1330
|
+
switch(myrand(6)){
|
1331
|
+
default:
|
1332
|
+
tctdbqryaddcond(qry, "str", TDBQCSTREQ, expr);
|
1333
|
+
break;
|
1334
|
+
case 1:
|
1335
|
+
tctdbqryaddcond(qry, "str", TDBQCSTRBW, expr);
|
1336
|
+
break;
|
1337
|
+
case 2:
|
1338
|
+
tctdbqryaddcond(qry, "str", TDBQCSTROREQ, expr);
|
1339
|
+
break;
|
1340
|
+
case 3:
|
1341
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMEQ, expr);
|
1342
|
+
break;
|
1343
|
+
case 4:
|
1344
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMGT, expr);
|
1345
|
+
break;
|
1346
|
+
case 5:
|
1347
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMLT, expr);
|
1348
|
+
break;
|
1349
|
+
}
|
1350
|
+
switch(myrand(5)){
|
1351
|
+
case 0:
|
1352
|
+
tctdbqrysetorder(qry, "str", TDBQOSTRASC);
|
1353
|
+
break;
|
1354
|
+
case 1:
|
1355
|
+
tctdbqrysetorder(qry, "str", TDBQOSTRDESC);
|
1356
|
+
break;
|
1357
|
+
case 2:
|
1358
|
+
tctdbqrysetorder(qry, "num", TDBQONUMASC);
|
1359
|
+
break;
|
1360
|
+
case 3:
|
1361
|
+
tctdbqrysetorder(qry, "num", TDBQONUMDESC);
|
1362
|
+
break;
|
1363
|
+
}
|
1364
|
+
tctdbqrysetlimit(qry, 10, myrand(10));
|
1365
|
+
} else {
|
1366
|
+
int cnum = myrand(4);
|
1367
|
+
if(cnum < 1 && myrand(5) != 0) cnum = 1;
|
1368
|
+
for(int j = 0; j < cnum; j++){
|
1369
|
+
const char *name = names[myrand(sizeof(names) / sizeof(*names))];
|
1370
|
+
int op = ops[myrand(sizeof(ops) / sizeof(*ops))];
|
1371
|
+
if(myrand(10) == 0) op = ftsops[myrand(sizeof(ftsops) / sizeof(*ftsops))];
|
1372
|
+
if(myrand(20) == 0) op |= TDBQCNEGATE;
|
1373
|
+
if(myrand(20) == 0) op |= TDBQCNOIDX;
|
1374
|
+
char expr[RECBUFSIZ*3];
|
1375
|
+
char *wp = expr;
|
1376
|
+
if(myrand(3) == 0){
|
1377
|
+
wp += sprintf(expr, "%f", myrand(i * 100) / 100.0);
|
1378
|
+
} else {
|
1379
|
+
wp += sprintf(expr, "%d", myrand(i));
|
1380
|
+
}
|
1381
|
+
if(myrand(10) == 0) wp += sprintf(wp, ",%d", myrand(i));
|
1382
|
+
if(myrand(10) == 0) wp += sprintf(wp, ",%d", myrand(i));
|
1383
|
+
tctdbqryaddcond(qry, name, op, expr);
|
1384
|
+
}
|
1385
|
+
if(myrand(3) != 0){
|
1386
|
+
const char *name = names[myrand(sizeof(names) / sizeof(*names))];
|
1387
|
+
int type = types[myrand(sizeof(types) / sizeof(*types))];
|
1388
|
+
tctdbqrysetorder(qry, name, type);
|
1389
|
+
}
|
1390
|
+
if(myrand(3) != 0) tctdbqrysetlimit(qry, myrand(i), myrand(10));
|
1391
|
+
}
|
1392
|
+
if(myrand(10) == 0){
|
1393
|
+
TCLIST *res = tctdbqrysearch(qry);
|
1394
|
+
tclistdel(res);
|
1395
|
+
}
|
1396
|
+
tctdbqrydel(qry);
|
1397
|
+
break;
|
1398
|
+
default:
|
1399
|
+
if(id == 0) iputchar('@');
|
1400
|
+
if(tctdbtranbegin(tdb)){
|
1401
|
+
if(myrand(2) == 0){
|
1402
|
+
if(!tctdbput(tdb, pkbuf, pksiz, cols)){
|
1403
|
+
eprint(tdb, __LINE__, "tctdbput");
|
1404
|
+
err = true;
|
1405
|
+
}
|
1406
|
+
} else {
|
1407
|
+
if(!tctdbout(tdb, pkbuf, pksiz) && tctdbecode(tdb) != TCENOREC){
|
1408
|
+
eprint(tdb, __LINE__, "tctdbout");
|
1409
|
+
err = true;
|
1410
|
+
}
|
1411
|
+
}
|
1412
|
+
if(myrand(2) == 0){
|
1413
|
+
if(!tctdbtranabort(tdb)){
|
1414
|
+
eprint(tdb, __LINE__, "tctdbtranabort");
|
1415
|
+
err = true;
|
1416
|
+
}
|
1417
|
+
} else {
|
1418
|
+
if(!tctdbtrancommit(tdb)){
|
1419
|
+
eprint(tdb, __LINE__, "tctdbtrancommit");
|
1420
|
+
err = true;
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
} else {
|
1424
|
+
eprint(tdb, __LINE__, "tctdbtranbegin");
|
1425
|
+
err = true;
|
1426
|
+
}
|
1427
|
+
if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
|
1428
|
+
break;
|
1429
|
+
}
|
1430
|
+
tcmapdel(cols);
|
1431
|
+
if(id == 0){
|
1432
|
+
if(i % 50 == 0) iprintf(" (%08d)\n", i);
|
1433
|
+
if(id == 0 && i == rnum / 4){
|
1434
|
+
if(!tctdboptimize(tdb, rnum / 50, -1, -1, -1) && tctdbecode(tdb) != TCEINVALID){
|
1435
|
+
eprint(tdb, __LINE__, "tctdboptimize");
|
1436
|
+
err = true;
|
1437
|
+
}
|
1438
|
+
if(!tctdbiterinit(tdb)){
|
1439
|
+
eprint(tdb, __LINE__, "tctdbiterinit");
|
1440
|
+
err = true;
|
1441
|
+
}
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
return err ? "error" : NULL;
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
|
1449
|
+
/* thread the typical function */
|
1450
|
+
static void *threadtypical(void *targ){
|
1451
|
+
TCTDB *tdb = ((TARGTYPICAL *)targ)->tdb;
|
1452
|
+
int rnum = ((TARGTYPICAL *)targ)->rnum;
|
1453
|
+
int rratio = ((TARGTYPICAL *)targ)->rratio;
|
1454
|
+
int id = ((TARGTYPICAL *)targ)->id;
|
1455
|
+
bool err = false;
|
1456
|
+
int base = id * rnum;
|
1457
|
+
int mrange = tclmax(50 + rratio, 100);
|
1458
|
+
for(int i = 1; !err && i <= rnum; i++){
|
1459
|
+
char pkbuf[RECBUFSIZ];
|
1460
|
+
int pksiz = sprintf(pkbuf, "%08d", base + myrandnd(i));
|
1461
|
+
int rnd = myrand(mrange);
|
1462
|
+
if(rnd < 20){
|
1463
|
+
TCMAP *cols = tcmapnew2(7);
|
1464
|
+
char vbuf[RECBUFSIZ*5];
|
1465
|
+
int vsiz = sprintf(vbuf, "%d", id);
|
1466
|
+
tcmapput(cols, "str", 3, vbuf, vsiz);
|
1467
|
+
if(myrand(3) == 0){
|
1468
|
+
vsiz = sprintf(vbuf, "%.2f", (myrand(i * 100) + 1) / 100.0);
|
1469
|
+
} else {
|
1470
|
+
vsiz = sprintf(vbuf, "%d", myrand(i) + 1);
|
1471
|
+
}
|
1472
|
+
tcmapput(cols, "num", 3, vbuf, vsiz);
|
1473
|
+
vsiz = sprintf(vbuf, "%d", myrand(32) + 1);
|
1474
|
+
tcmapput(cols, "type", 4, vbuf, vsiz);
|
1475
|
+
int num = myrand(5);
|
1476
|
+
int pt = 0;
|
1477
|
+
char *wp = vbuf;
|
1478
|
+
for(int j = 0; j < num; j++){
|
1479
|
+
pt += myrand(5) + 1;
|
1480
|
+
if(wp > vbuf) *(wp++) = ',';
|
1481
|
+
wp += sprintf(wp, "%d", pt);
|
1482
|
+
}
|
1483
|
+
*wp = '\0';
|
1484
|
+
if(*vbuf != '\0'){
|
1485
|
+
tcmapput(cols, "flag", 4, vbuf, wp - vbuf);
|
1486
|
+
tcmapput(cols, "text", 4, vbuf, wp - vbuf);
|
1487
|
+
}
|
1488
|
+
char nbuf[RECBUFSIZ];
|
1489
|
+
int nsiz = sprintf(nbuf, "c%d", myrand(i) + 1);
|
1490
|
+
vsiz = sprintf(vbuf, "%d", myrand(i) + 1);
|
1491
|
+
tcmapput(cols, nbuf, nsiz, vbuf, vsiz);
|
1492
|
+
if(myrand(2) == 0){
|
1493
|
+
if(!tctdbput(tdb, pkbuf, pksiz, cols)){
|
1494
|
+
eprint(tdb, __LINE__, "tctdbput");
|
1495
|
+
err = true;
|
1496
|
+
}
|
1497
|
+
} else {
|
1498
|
+
if(!tctdbput(tdb, pkbuf, pksiz, cols) && tctdbecode(tdb) && tctdbecode(tdb) != TCEKEEP){
|
1499
|
+
eprint(tdb, __LINE__, "tctdbput");
|
1500
|
+
err = true;
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
tcmapdel(cols);
|
1504
|
+
} else if(rnd < 30){
|
1505
|
+
if(!tctdbout(tdb, pkbuf, pksiz) && tctdbecode(tdb) && tctdbecode(tdb) != TCENOREC){
|
1506
|
+
eprint(tdb, __LINE__, "tctdbout");
|
1507
|
+
err = true;
|
1508
|
+
}
|
1509
|
+
} else if(rnd < 31){
|
1510
|
+
if(myrand(10) == 0 && !tctdbiterinit(tdb) && tctdbecode(tdb) != TCENOREC){
|
1511
|
+
eprint(tdb, __LINE__, "tctdbiterinit");
|
1512
|
+
err = true;
|
1513
|
+
}
|
1514
|
+
for(int j = 0; !err && j < 10; j++){
|
1515
|
+
int ksiz;
|
1516
|
+
char *kbuf = tctdbiternext(tdb, &ksiz);
|
1517
|
+
if(kbuf){
|
1518
|
+
tcfree(kbuf);
|
1519
|
+
} else if(tctdbecode(tdb) != TCEINVALID && tctdbecode(tdb) != TCENOREC){
|
1520
|
+
eprint(tdb, __LINE__, "tctdbiternext");
|
1521
|
+
err = true;
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
} else {
|
1525
|
+
TDBQRY *qry = tctdbqrynew(tdb);
|
1526
|
+
char expr[RECBUFSIZ];
|
1527
|
+
sprintf(expr, "%d", myrand(i) + 1);
|
1528
|
+
switch(myrand(6) * 1){
|
1529
|
+
default:
|
1530
|
+
tctdbqryaddcond(qry, "str", TDBQCSTREQ, expr);
|
1531
|
+
break;
|
1532
|
+
case 1:
|
1533
|
+
tctdbqryaddcond(qry, "str", TDBQCSTRBW, expr);
|
1534
|
+
break;
|
1535
|
+
case 2:
|
1536
|
+
tctdbqryaddcond(qry, "str", TDBQCSTROREQ, expr);
|
1537
|
+
break;
|
1538
|
+
case 3:
|
1539
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMEQ, expr);
|
1540
|
+
break;
|
1541
|
+
case 4:
|
1542
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMGT, expr);
|
1543
|
+
break;
|
1544
|
+
case 5:
|
1545
|
+
tctdbqryaddcond(qry, "num", TDBQCNUMLT, expr);
|
1546
|
+
break;
|
1547
|
+
}
|
1548
|
+
tctdbqrysetlimit(qry, 10, myrand(5) * 10);
|
1549
|
+
TCLIST *res = tctdbqrysearch(qry);
|
1550
|
+
tclistdel(res);
|
1551
|
+
tctdbqrydel(qry);
|
1552
|
+
}
|
1553
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1554
|
+
iputchar('.');
|
1555
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1556
|
+
}
|
1557
|
+
}
|
1558
|
+
return err ? "error" : NULL;
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
|
1562
|
+
|
1563
|
+
// END OF FILE
|