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,1757 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* The test cases of the hash 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 <tchdb.h>
|
19
|
+
#include "myconf.h"
|
20
|
+
|
21
|
+
#define RECBUFSIZ 48 // buffer for records
|
22
|
+
|
23
|
+
typedef struct { // type of structure for write thread
|
24
|
+
TCHDB *hdb;
|
25
|
+
int rnum;
|
26
|
+
bool as;
|
27
|
+
bool rnd;
|
28
|
+
int id;
|
29
|
+
} TARGWRITE;
|
30
|
+
|
31
|
+
typedef struct { // type of structure for read thread
|
32
|
+
TCHDB *hdb;
|
33
|
+
int rnum;
|
34
|
+
bool wb;
|
35
|
+
bool rnd;
|
36
|
+
int id;
|
37
|
+
} TARGREAD;
|
38
|
+
|
39
|
+
typedef struct { // type of structure for remove thread
|
40
|
+
TCHDB *hdb;
|
41
|
+
int rnum;
|
42
|
+
bool rnd;
|
43
|
+
int id;
|
44
|
+
} TARGREMOVE;
|
45
|
+
|
46
|
+
typedef struct { // type of structure for wicked thread
|
47
|
+
TCHDB *hdb;
|
48
|
+
int rnum;
|
49
|
+
bool nc;
|
50
|
+
int id;
|
51
|
+
TCMAP *map;
|
52
|
+
} TARGWICKED;
|
53
|
+
|
54
|
+
typedef struct { // type of structure for typical thread
|
55
|
+
TCHDB *hdb;
|
56
|
+
int rnum;
|
57
|
+
bool nc;
|
58
|
+
int rratio;
|
59
|
+
int id;
|
60
|
+
} TARGTYPICAL;
|
61
|
+
|
62
|
+
typedef struct { // type of structure for race thread
|
63
|
+
TCHDB *hdb;
|
64
|
+
int rnum;
|
65
|
+
int id;
|
66
|
+
} TARGRACE;
|
67
|
+
|
68
|
+
|
69
|
+
/* global variables */
|
70
|
+
const char *g_progname; // program name
|
71
|
+
unsigned int g_randseed; // random seed
|
72
|
+
int g_dbgfd; // debugging output
|
73
|
+
|
74
|
+
|
75
|
+
/* function prototypes */
|
76
|
+
int main(int argc, char **argv);
|
77
|
+
static void usage(void);
|
78
|
+
static void iprintf(const char *format, ...);
|
79
|
+
static void iputchar(int c);
|
80
|
+
static void eprint(TCHDB *hdb, int line, const char *func);
|
81
|
+
static void mprint(TCHDB *hdb);
|
82
|
+
static void sysprint(void);
|
83
|
+
static int myrand(int range);
|
84
|
+
static int myrandnd(int range);
|
85
|
+
static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op);
|
86
|
+
static int runwrite(int argc, char **argv);
|
87
|
+
static int runread(int argc, char **argv);
|
88
|
+
static int runremove(int argc, char **argv);
|
89
|
+
static int runwicked(int argc, char **argv);
|
90
|
+
static int runtypical(int argc, char **argv);
|
91
|
+
static int runrace(int argc, char **argv);
|
92
|
+
static int procwrite(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
93
|
+
int opts, int rcnum, int xmsiz, int dfunit, int omode, bool as, bool rnd);
|
94
|
+
static int procread(const char *path, int tnum, int rcnum, int xmsiz, int dfunit, int omode,
|
95
|
+
bool wb, bool rnd);
|
96
|
+
static int procremove(const char *path, int tnum, int rcnum, int xmsiz, int dfunit, int omode,
|
97
|
+
bool rnd);
|
98
|
+
static int procwicked(const char *path, int tnum, int rnum, int opts, int omode, bool nc);
|
99
|
+
static int proctypical(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
100
|
+
int opts, int rcnum, int xmsiz, int dfunit, int omode,
|
101
|
+
bool nc, int rratio);
|
102
|
+
static int procrace(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
103
|
+
int opts, int xmsiz, int dfunit, int omode);
|
104
|
+
static void *threadwrite(void *targ);
|
105
|
+
static void *threadread(void *targ);
|
106
|
+
static void *threadremove(void *targ);
|
107
|
+
static void *threadwicked(void *targ);
|
108
|
+
static void *threadtypical(void *targ);
|
109
|
+
static void *threadrace(void *targ);
|
110
|
+
|
111
|
+
|
112
|
+
/* main routine */
|
113
|
+
int main(int argc, char **argv){
|
114
|
+
g_progname = argv[0];
|
115
|
+
const char *ebuf = getenv("TCRNDSEED");
|
116
|
+
g_randseed = ebuf ? tcatoix(ebuf) : tctime() * 1000;
|
117
|
+
srand(g_randseed);
|
118
|
+
ebuf = getenv("TCDBGFD");
|
119
|
+
g_dbgfd = ebuf ? tcatoix(ebuf) : UINT16_MAX;
|
120
|
+
if(argc < 2) usage();
|
121
|
+
int rv = 0;
|
122
|
+
if(!strcmp(argv[1], "write")){
|
123
|
+
rv = runwrite(argc, argv);
|
124
|
+
} else if(!strcmp(argv[1], "read")){
|
125
|
+
rv = runread(argc, argv);
|
126
|
+
} else if(!strcmp(argv[1], "remove")){
|
127
|
+
rv = runremove(argc, argv);
|
128
|
+
} else if(!strcmp(argv[1], "wicked")){
|
129
|
+
rv = runwicked(argc, argv);
|
130
|
+
} else if(!strcmp(argv[1], "typical")){
|
131
|
+
rv = runtypical(argc, argv);
|
132
|
+
} else if(!strcmp(argv[1], "race")){
|
133
|
+
rv = runrace(argc, argv);
|
134
|
+
} else {
|
135
|
+
usage();
|
136
|
+
}
|
137
|
+
if(rv != 0){
|
138
|
+
printf("FAILED: TCRNDSEED=%u PID=%d", g_randseed, (int)getpid());
|
139
|
+
for(int i = 0; i < argc; i++){
|
140
|
+
printf(" %s", argv[i]);
|
141
|
+
}
|
142
|
+
printf("\n\n");
|
143
|
+
}
|
144
|
+
return rv;
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
/* print the usage and exit */
|
149
|
+
static void usage(void){
|
150
|
+
fprintf(stderr, "%s: test cases of the hash database API of Tokyo Cabinet\n", g_progname);
|
151
|
+
fprintf(stderr, "\n");
|
152
|
+
fprintf(stderr, "usage:\n");
|
153
|
+
fprintf(stderr, " %s write [-tl] [-td|-tb|-tt|-tx] [-rc num] [-xm num] [-df num]"
|
154
|
+
" [-nl|-nb] [-as] [-rnd] path tnum rnum [bnum [apow [fpow]]]\n", g_progname);
|
155
|
+
fprintf(stderr, " %s read [-rc num] [-xm num] [-df num] [-nl|-nb] [-wb] [-rnd] path tnum\n",
|
156
|
+
g_progname);
|
157
|
+
fprintf(stderr, " %s remove [-rc num] [-xm num] [-df num] [-nl|-nb] [-rnd] path tnum\n",
|
158
|
+
g_progname);
|
159
|
+
fprintf(stderr, " %s wicked [-tl] [-td|-tb|-tt|-tx] [-nl|-nb] [-nc]"
|
160
|
+
" path tnum rnum\n", g_progname);
|
161
|
+
fprintf(stderr, " %s typical [-tl] [-td|-tb|-tt|-tx] [-rc num] [-xm num] [-df num]"
|
162
|
+
" [-nl|-nb] [-nc] [-rr num] path tnum rnum [bnum [apow [fpow]]]\n", g_progname);
|
163
|
+
fprintf(stderr, " %s race [-tl] [-td|-tb|-tt|-tx] [-xm num] [-df num] [-nl|-nb]"
|
164
|
+
" path tnum rnum [bnum [apow [fpow]]]\n", g_progname);
|
165
|
+
fprintf(stderr, "\n");
|
166
|
+
exit(1);
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
/* print formatted information string and flush the buffer */
|
171
|
+
static void iprintf(const char *format, ...){
|
172
|
+
va_list ap;
|
173
|
+
va_start(ap, format);
|
174
|
+
vprintf(format, ap);
|
175
|
+
fflush(stdout);
|
176
|
+
va_end(ap);
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
/* print a character and flush the buffer */
|
181
|
+
static void iputchar(int c){
|
182
|
+
putchar(c);
|
183
|
+
fflush(stdout);
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
/* print error message of hash database */
|
188
|
+
static void eprint(TCHDB *hdb, int line, const char *func){
|
189
|
+
const char *path = tchdbpath(hdb);
|
190
|
+
int ecode = tchdbecode(hdb);
|
191
|
+
fprintf(stderr, "%s: %s: %d: %s: error: %d: %s\n",
|
192
|
+
g_progname, path ? path : "-", line, func, ecode, tchdberrmsg(ecode));
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
/* print members of hash database */
|
197
|
+
static void mprint(TCHDB *hdb){
|
198
|
+
if(hdb->cnt_writerec < 0) return;
|
199
|
+
iprintf("bucket number: %lld\n", (long long)tchdbbnum(hdb));
|
200
|
+
iprintf("used bucket number: %lld\n", (long long)tchdbbnumused(hdb));
|
201
|
+
iprintf("cnt_writerec: %lld\n", (long long)hdb->cnt_writerec);
|
202
|
+
iprintf("cnt_reuserec: %lld\n", (long long)hdb->cnt_reuserec);
|
203
|
+
iprintf("cnt_moverec: %lld\n", (long long)hdb->cnt_moverec);
|
204
|
+
iprintf("cnt_readrec: %lld\n", (long long)hdb->cnt_readrec);
|
205
|
+
iprintf("cnt_searchfbp: %lld\n", (long long)hdb->cnt_searchfbp);
|
206
|
+
iprintf("cnt_insertfbp: %lld\n", (long long)hdb->cnt_insertfbp);
|
207
|
+
iprintf("cnt_splicefbp: %lld\n", (long long)hdb->cnt_splicefbp);
|
208
|
+
iprintf("cnt_dividefbp: %lld\n", (long long)hdb->cnt_dividefbp);
|
209
|
+
iprintf("cnt_mergefbp: %lld\n", (long long)hdb->cnt_mergefbp);
|
210
|
+
iprintf("cnt_reducefbp: %lld\n", (long long)hdb->cnt_reducefbp);
|
211
|
+
iprintf("cnt_appenddrp: %lld\n", (long long)hdb->cnt_appenddrp);
|
212
|
+
iprintf("cnt_deferdrp: %lld\n", (long long)hdb->cnt_deferdrp);
|
213
|
+
iprintf("cnt_flushdrp: %lld\n", (long long)hdb->cnt_flushdrp);
|
214
|
+
iprintf("cnt_adjrecc: %lld\n", (long long)hdb->cnt_adjrecc);
|
215
|
+
iprintf("cnt_defrag: %lld\n", (long long)hdb->cnt_defrag);
|
216
|
+
iprintf("cnt_shiftrec: %lld\n", (long long)hdb->cnt_shiftrec);
|
217
|
+
iprintf("cnt_trunc: %lld\n", (long long)hdb->cnt_trunc);
|
218
|
+
}
|
219
|
+
|
220
|
+
|
221
|
+
/* print system information */
|
222
|
+
static void sysprint(void){
|
223
|
+
TCMAP *info = tcsysinfo();
|
224
|
+
if(info){
|
225
|
+
tcmapiterinit(info);
|
226
|
+
const char *kbuf;
|
227
|
+
while((kbuf = tcmapiternext2(info)) != NULL){
|
228
|
+
iprintf("sys_%s: %s\n", kbuf, tcmapiterval2(kbuf));
|
229
|
+
}
|
230
|
+
tcmapdel(info);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
/* get a random number */
|
236
|
+
static int myrand(int range){
|
237
|
+
if(range < 2) return 0;
|
238
|
+
int high = (unsigned int)rand() >> 4;
|
239
|
+
int low = range * (rand() / (RAND_MAX + 1.0));
|
240
|
+
low &= (unsigned int)INT_MAX >> 4;
|
241
|
+
return (high + low) % range;
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
/* get a random number based on normal distribution */
|
246
|
+
static int myrandnd(int range){
|
247
|
+
int num = (int)tcdrandnd(range >> 1, range / 10);
|
248
|
+
return (num < 0 || num >= range) ? 0 : num;
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
/* iterator function */
|
253
|
+
static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op){
|
254
|
+
unsigned int sum = 0;
|
255
|
+
while(--ksiz >= 0){
|
256
|
+
sum += ((char *)kbuf)[ksiz];
|
257
|
+
}
|
258
|
+
while(--vsiz >= 0){
|
259
|
+
sum += ((char *)vbuf)[vsiz];
|
260
|
+
}
|
261
|
+
return myrand(100 + (sum & 0xff)) > 0;
|
262
|
+
}
|
263
|
+
|
264
|
+
|
265
|
+
/* parse arguments of write command */
|
266
|
+
static int runwrite(int argc, char **argv){
|
267
|
+
char *path = NULL;
|
268
|
+
char *tstr = NULL;
|
269
|
+
char *rstr = NULL;
|
270
|
+
char *bstr = NULL;
|
271
|
+
char *astr = NULL;
|
272
|
+
char *fstr = NULL;
|
273
|
+
int opts = 0;
|
274
|
+
int rcnum = 0;
|
275
|
+
int xmsiz = -1;
|
276
|
+
int dfunit = 0;
|
277
|
+
int omode = 0;
|
278
|
+
bool as = false;
|
279
|
+
bool rnd = false;
|
280
|
+
for(int i = 2; i < argc; i++){
|
281
|
+
if(!path && argv[i][0] == '-'){
|
282
|
+
if(!strcmp(argv[i], "-tl")){
|
283
|
+
opts |= HDBTLARGE;
|
284
|
+
} else if(!strcmp(argv[i], "-td")){
|
285
|
+
opts |= HDBTDEFLATE;
|
286
|
+
} else if(!strcmp(argv[i], "-tb")){
|
287
|
+
opts |= HDBTBZIP;
|
288
|
+
} else if(!strcmp(argv[i], "-tt")){
|
289
|
+
opts |= HDBTTCBS;
|
290
|
+
} else if(!strcmp(argv[i], "-tx")){
|
291
|
+
opts |= HDBTEXCODEC;
|
292
|
+
} else if(!strcmp(argv[i], "-rc")){
|
293
|
+
if(++i >= argc) usage();
|
294
|
+
rcnum = tcatoix(argv[i]);
|
295
|
+
} else if(!strcmp(argv[i], "-xm")){
|
296
|
+
if(++i >= argc) usage();
|
297
|
+
xmsiz = tcatoix(argv[i]);
|
298
|
+
} else if(!strcmp(argv[i], "-df")){
|
299
|
+
if(++i >= argc) usage();
|
300
|
+
dfunit = tcatoix(argv[i]);
|
301
|
+
} else if(!strcmp(argv[i], "-nl")){
|
302
|
+
omode |= HDBONOLCK;
|
303
|
+
} else if(!strcmp(argv[i], "-nb")){
|
304
|
+
omode |= HDBOLCKNB;
|
305
|
+
} else if(!strcmp(argv[i], "-as")){
|
306
|
+
as = true;
|
307
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
308
|
+
rnd = true;
|
309
|
+
} else {
|
310
|
+
usage();
|
311
|
+
}
|
312
|
+
} else if(!path){
|
313
|
+
path = argv[i];
|
314
|
+
} else if(!tstr){
|
315
|
+
tstr = argv[i];
|
316
|
+
} else if(!rstr){
|
317
|
+
rstr = argv[i];
|
318
|
+
} else if(!bstr){
|
319
|
+
bstr = argv[i];
|
320
|
+
} else if(!astr){
|
321
|
+
astr = argv[i];
|
322
|
+
} else if(!fstr){
|
323
|
+
fstr = argv[i];
|
324
|
+
} else {
|
325
|
+
usage();
|
326
|
+
}
|
327
|
+
}
|
328
|
+
if(!path || !tstr || !rstr) usage();
|
329
|
+
int tnum = tcatoix(tstr);
|
330
|
+
int rnum = tcatoix(rstr);
|
331
|
+
if(tnum < 1 || rnum < 1) usage();
|
332
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
333
|
+
int apow = astr ? tcatoix(astr) : -1;
|
334
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
335
|
+
int rv = procwrite(path, tnum, rnum, bnum, apow, fpow, opts, rcnum, xmsiz, dfunit, omode,
|
336
|
+
as, rnd);
|
337
|
+
return rv;
|
338
|
+
}
|
339
|
+
|
340
|
+
|
341
|
+
/* parse arguments of read command */
|
342
|
+
static int runread(int argc, char **argv){
|
343
|
+
char *path = NULL;
|
344
|
+
char *tstr = NULL;
|
345
|
+
int rcnum = 0;
|
346
|
+
int xmsiz = -1;
|
347
|
+
int dfunit = 0;
|
348
|
+
int omode = 0;
|
349
|
+
bool wb = false;
|
350
|
+
bool rnd = false;
|
351
|
+
for(int i = 2; i < argc; i++){
|
352
|
+
if(!path && argv[i][0] == '-'){
|
353
|
+
if(!strcmp(argv[i], "-rc")){
|
354
|
+
if(++i >= argc) usage();
|
355
|
+
rcnum = tcatoix(argv[i]);
|
356
|
+
} else if(!strcmp(argv[i], "-xm")){
|
357
|
+
if(++i >= argc) usage();
|
358
|
+
xmsiz = tcatoix(argv[i]);
|
359
|
+
} else if(!strcmp(argv[i], "-df")){
|
360
|
+
if(++i >= argc) usage();
|
361
|
+
dfunit = tcatoix(argv[i]);
|
362
|
+
} else if(!strcmp(argv[i], "-nl")){
|
363
|
+
omode |= HDBONOLCK;
|
364
|
+
} else if(!strcmp(argv[i], "-nb")){
|
365
|
+
omode |= HDBOLCKNB;
|
366
|
+
} else if(!strcmp(argv[i], "-wb")){
|
367
|
+
wb = true;
|
368
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
369
|
+
rnd = true;
|
370
|
+
} else {
|
371
|
+
usage();
|
372
|
+
}
|
373
|
+
} else if(!path){
|
374
|
+
path = argv[i];
|
375
|
+
} else if(!tstr){
|
376
|
+
tstr = argv[i];
|
377
|
+
} else {
|
378
|
+
usage();
|
379
|
+
}
|
380
|
+
}
|
381
|
+
if(!path || !tstr) usage();
|
382
|
+
int tnum = tcatoix(tstr);
|
383
|
+
if(tnum < 1) usage();
|
384
|
+
int rv = procread(path, tnum, rcnum, xmsiz, dfunit, omode, wb, rnd);
|
385
|
+
return rv;
|
386
|
+
}
|
387
|
+
|
388
|
+
|
389
|
+
/* parse arguments of remove command */
|
390
|
+
static int runremove(int argc, char **argv){
|
391
|
+
char *path = NULL;
|
392
|
+
char *tstr = NULL;
|
393
|
+
int rcnum = 0;
|
394
|
+
int xmsiz = -1;
|
395
|
+
int dfunit = 0;
|
396
|
+
int omode = 0;
|
397
|
+
bool rnd = false;
|
398
|
+
for(int i = 2; i < argc; i++){
|
399
|
+
if(!path && argv[i][0] == '-'){
|
400
|
+
if(!strcmp(argv[i], "-rc")){
|
401
|
+
if(++i >= argc) usage();
|
402
|
+
rcnum = tcatoix(argv[i]);
|
403
|
+
} else if(!strcmp(argv[i], "-xm")){
|
404
|
+
if(++i >= argc) usage();
|
405
|
+
xmsiz = tcatoix(argv[i]);
|
406
|
+
} else if(!strcmp(argv[i], "-df")){
|
407
|
+
if(++i >= argc) usage();
|
408
|
+
dfunit = tcatoix(argv[i]);
|
409
|
+
} else if(!strcmp(argv[i], "-nl")){
|
410
|
+
omode |= HDBONOLCK;
|
411
|
+
} else if(!strcmp(argv[i], "-nb")){
|
412
|
+
omode |= HDBOLCKNB;
|
413
|
+
} else if(!strcmp(argv[i], "-rnd")){
|
414
|
+
rnd = true;
|
415
|
+
} else {
|
416
|
+
usage();
|
417
|
+
}
|
418
|
+
} else if(!path){
|
419
|
+
path = argv[i];
|
420
|
+
} else if(!tstr){
|
421
|
+
tstr = argv[i];
|
422
|
+
} else {
|
423
|
+
usage();
|
424
|
+
}
|
425
|
+
}
|
426
|
+
if(!path || !tstr) usage();
|
427
|
+
int tnum = tcatoix(tstr);
|
428
|
+
if(tnum < 1) usage();
|
429
|
+
int rv = procremove(path, tnum, rcnum, xmsiz, dfunit, omode, rnd);
|
430
|
+
return rv;
|
431
|
+
}
|
432
|
+
|
433
|
+
|
434
|
+
/* parse arguments of wicked command */
|
435
|
+
static int runwicked(int argc, char **argv){
|
436
|
+
char *path = NULL;
|
437
|
+
char *tstr = NULL;
|
438
|
+
char *rstr = NULL;
|
439
|
+
int opts = 0;
|
440
|
+
int omode = 0;
|
441
|
+
bool nc = false;
|
442
|
+
for(int i = 2; i < argc; i++){
|
443
|
+
if(!path && argv[i][0] == '-'){
|
444
|
+
if(!strcmp(argv[i], "-tl")){
|
445
|
+
opts |= HDBTLARGE;
|
446
|
+
} else if(!strcmp(argv[i], "-td")){
|
447
|
+
opts |= HDBTDEFLATE;
|
448
|
+
} else if(!strcmp(argv[i], "-tb")){
|
449
|
+
opts |= HDBTBZIP;
|
450
|
+
} else if(!strcmp(argv[i], "-tt")){
|
451
|
+
opts |= HDBTTCBS;
|
452
|
+
} else if(!strcmp(argv[i], "-tx")){
|
453
|
+
opts |= HDBTEXCODEC;
|
454
|
+
} else if(!strcmp(argv[i], "-nl")){
|
455
|
+
omode |= HDBONOLCK;
|
456
|
+
} else if(!strcmp(argv[i], "-nb")){
|
457
|
+
omode |= HDBOLCKNB;
|
458
|
+
} else if(!strcmp(argv[i], "-nc")){
|
459
|
+
nc = true;
|
460
|
+
} else {
|
461
|
+
usage();
|
462
|
+
}
|
463
|
+
} else if(!path){
|
464
|
+
path = argv[i];
|
465
|
+
} else if(!tstr){
|
466
|
+
tstr = argv[i];
|
467
|
+
} else if(!rstr){
|
468
|
+
rstr = argv[i];
|
469
|
+
} else {
|
470
|
+
usage();
|
471
|
+
}
|
472
|
+
}
|
473
|
+
if(!path || !tstr || !rstr) usage();
|
474
|
+
int tnum = tcatoix(tstr);
|
475
|
+
int rnum = tcatoix(rstr);
|
476
|
+
if(tnum < 1 || rnum < 1) usage();
|
477
|
+
int rv = procwicked(path, tnum, rnum, opts, omode, nc);
|
478
|
+
return rv;
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
/* parse arguments of typical command */
|
483
|
+
static int runtypical(int argc, char **argv){
|
484
|
+
char *path = NULL;
|
485
|
+
char *tstr = NULL;
|
486
|
+
char *rstr = NULL;
|
487
|
+
char *bstr = NULL;
|
488
|
+
char *astr = NULL;
|
489
|
+
char *fstr = NULL;
|
490
|
+
int opts = 0;
|
491
|
+
int rcnum = 0;
|
492
|
+
int xmsiz = -1;
|
493
|
+
int dfunit = 0;
|
494
|
+
int omode = 0;
|
495
|
+
int rratio = -1;
|
496
|
+
bool nc = false;
|
497
|
+
for(int i = 2; i < argc; i++){
|
498
|
+
if(!path && argv[i][0] == '-'){
|
499
|
+
if(!strcmp(argv[i], "-tl")){
|
500
|
+
opts |= HDBTLARGE;
|
501
|
+
} else if(!strcmp(argv[i], "-td")){
|
502
|
+
opts |= HDBTDEFLATE;
|
503
|
+
} else if(!strcmp(argv[i], "-tb")){
|
504
|
+
opts |= HDBTBZIP;
|
505
|
+
} else if(!strcmp(argv[i], "-tt")){
|
506
|
+
opts |= HDBTTCBS;
|
507
|
+
} else if(!strcmp(argv[i], "-tx")){
|
508
|
+
opts |= HDBTEXCODEC;
|
509
|
+
} else if(!strcmp(argv[i], "-rc")){
|
510
|
+
if(++i >= argc) usage();
|
511
|
+
rcnum = tcatoix(argv[i]);
|
512
|
+
} else if(!strcmp(argv[i], "-xm")){
|
513
|
+
if(++i >= argc) usage();
|
514
|
+
xmsiz = tcatoix(argv[i]);
|
515
|
+
} else if(!strcmp(argv[i], "-df")){
|
516
|
+
if(++i >= argc) usage();
|
517
|
+
dfunit = tcatoix(argv[i]);
|
518
|
+
} else if(!strcmp(argv[i], "-nl")){
|
519
|
+
omode |= HDBONOLCK;
|
520
|
+
} else if(!strcmp(argv[i], "-nb")){
|
521
|
+
omode |= HDBOLCKNB;
|
522
|
+
} else if(!strcmp(argv[i], "-nc")){
|
523
|
+
nc = true;
|
524
|
+
} else if(!strcmp(argv[i], "-rr")){
|
525
|
+
if(++i >= argc) usage();
|
526
|
+
rratio = tcatoix(argv[i]);
|
527
|
+
} else {
|
528
|
+
usage();
|
529
|
+
}
|
530
|
+
} else if(!path){
|
531
|
+
path = argv[i];
|
532
|
+
} else if(!tstr){
|
533
|
+
tstr = argv[i];
|
534
|
+
} else if(!rstr){
|
535
|
+
rstr = argv[i];
|
536
|
+
} else if(!bstr){
|
537
|
+
bstr = argv[i];
|
538
|
+
} else if(!astr){
|
539
|
+
astr = argv[i];
|
540
|
+
} else if(!fstr){
|
541
|
+
fstr = argv[i];
|
542
|
+
} else {
|
543
|
+
usage();
|
544
|
+
}
|
545
|
+
}
|
546
|
+
if(!path || !tstr || !rstr) usage();
|
547
|
+
int tnum = tcatoix(tstr);
|
548
|
+
int rnum = tcatoix(rstr);
|
549
|
+
if(tnum < 1 || rnum < 1) usage();
|
550
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
551
|
+
int apow = astr ? tcatoix(astr) : -1;
|
552
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
553
|
+
int rv = proctypical(path, tnum, rnum, bnum, apow, fpow, opts, rcnum, xmsiz, dfunit, omode,
|
554
|
+
nc, rratio);
|
555
|
+
return rv;
|
556
|
+
}
|
557
|
+
|
558
|
+
|
559
|
+
/* parse arguments of race command */
|
560
|
+
static int runrace(int argc, char **argv){
|
561
|
+
char *path = NULL;
|
562
|
+
char *tstr = NULL;
|
563
|
+
char *rstr = NULL;
|
564
|
+
char *bstr = NULL;
|
565
|
+
char *astr = NULL;
|
566
|
+
char *fstr = NULL;
|
567
|
+
int opts = 0;
|
568
|
+
int xmsiz = -1;
|
569
|
+
int dfunit = 0;
|
570
|
+
int omode = 0;
|
571
|
+
for(int i = 2; i < argc; i++){
|
572
|
+
if(!path && argv[i][0] == '-'){
|
573
|
+
if(!strcmp(argv[i], "-tl")){
|
574
|
+
opts |= HDBTLARGE;
|
575
|
+
} else if(!strcmp(argv[i], "-td")){
|
576
|
+
opts |= HDBTDEFLATE;
|
577
|
+
} else if(!strcmp(argv[i], "-tb")){
|
578
|
+
opts |= HDBTBZIP;
|
579
|
+
} else if(!strcmp(argv[i], "-tt")){
|
580
|
+
opts |= HDBTTCBS;
|
581
|
+
} else if(!strcmp(argv[i], "-tx")){
|
582
|
+
opts |= HDBTEXCODEC;
|
583
|
+
} else if(!strcmp(argv[i], "-xm")){
|
584
|
+
if(++i >= argc) usage();
|
585
|
+
xmsiz = tcatoix(argv[i]);
|
586
|
+
} else if(!strcmp(argv[i], "-df")){
|
587
|
+
if(++i >= argc) usage();
|
588
|
+
dfunit = tcatoix(argv[i]);
|
589
|
+
} else if(!strcmp(argv[i], "-nl")){
|
590
|
+
omode |= HDBONOLCK;
|
591
|
+
} else if(!strcmp(argv[i], "-nb")){
|
592
|
+
omode |= HDBOLCKNB;
|
593
|
+
} else {
|
594
|
+
usage();
|
595
|
+
}
|
596
|
+
} else if(!path){
|
597
|
+
path = argv[i];
|
598
|
+
} else if(!tstr){
|
599
|
+
tstr = argv[i];
|
600
|
+
} else if(!rstr){
|
601
|
+
rstr = argv[i];
|
602
|
+
} else if(!bstr){
|
603
|
+
bstr = argv[i];
|
604
|
+
} else if(!astr){
|
605
|
+
astr = argv[i];
|
606
|
+
} else if(!fstr){
|
607
|
+
fstr = argv[i];
|
608
|
+
} else {
|
609
|
+
usage();
|
610
|
+
}
|
611
|
+
}
|
612
|
+
if(!path || !tstr || !rstr) usage();
|
613
|
+
int tnum = tcatoix(tstr);
|
614
|
+
int rnum = tcatoix(rstr);
|
615
|
+
if(tnum < 1 || rnum < 1) usage();
|
616
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
617
|
+
int apow = astr ? tcatoix(astr) : -1;
|
618
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
619
|
+
int rv = procrace(path, tnum, rnum, bnum, apow, fpow, opts, xmsiz, dfunit, omode);
|
620
|
+
return rv;
|
621
|
+
}
|
622
|
+
|
623
|
+
|
624
|
+
/* perform write command */
|
625
|
+
static int procwrite(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
626
|
+
int opts, int rcnum, int xmsiz, int dfunit, int omode, bool as, bool rnd){
|
627
|
+
iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d bnum=%d apow=%d fpow=%d"
|
628
|
+
" opts=%d rcnum=%d xmsiz=%d dfunit=%d omode=%d as=%d rnd=%d\n\n",
|
629
|
+
g_randseed, path, tnum, rnum, bnum, apow, fpow, opts, rcnum, xmsiz, dfunit, omode,
|
630
|
+
as, rnd);
|
631
|
+
bool err = false;
|
632
|
+
double stime = tctime();
|
633
|
+
TCHDB *hdb = tchdbnew();
|
634
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
635
|
+
if(!tchdbsetmutex(hdb)){
|
636
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
637
|
+
err = true;
|
638
|
+
}
|
639
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
640
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
641
|
+
err = true;
|
642
|
+
}
|
643
|
+
if(!tchdbtune(hdb, bnum, apow, fpow, opts)){
|
644
|
+
eprint(hdb, __LINE__, "tchdbtune");
|
645
|
+
err = true;
|
646
|
+
}
|
647
|
+
if(!tchdbsetcache(hdb, rcnum)){
|
648
|
+
eprint(hdb, __LINE__, "tchdbsetcache");
|
649
|
+
err = true;
|
650
|
+
}
|
651
|
+
if(xmsiz >= 0 && !tchdbsetxmsiz(hdb, xmsiz)){
|
652
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
653
|
+
err = true;
|
654
|
+
}
|
655
|
+
if(dfunit >= 0 && !tchdbsetdfunit(hdb, dfunit)){
|
656
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
657
|
+
err = true;
|
658
|
+
}
|
659
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC | omode)){
|
660
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
661
|
+
err = true;
|
662
|
+
}
|
663
|
+
TARGWRITE targs[tnum];
|
664
|
+
pthread_t threads[tnum];
|
665
|
+
if(tnum == 1){
|
666
|
+
targs[0].hdb = hdb;
|
667
|
+
targs[0].rnum = rnum;
|
668
|
+
targs[0].as = as;
|
669
|
+
targs[0].rnd = rnd;
|
670
|
+
targs[0].id = 0;
|
671
|
+
if(threadwrite(targs) != NULL) err = true;
|
672
|
+
} else {
|
673
|
+
for(int i = 0; i < tnum; i++){
|
674
|
+
targs[i].hdb = hdb;
|
675
|
+
targs[i].rnum = rnum;
|
676
|
+
targs[i].as = as;
|
677
|
+
targs[i].rnd = rnd;
|
678
|
+
targs[i].id = i;
|
679
|
+
if(pthread_create(threads + i, NULL, threadwrite, targs + i) != 0){
|
680
|
+
eprint(hdb, __LINE__, "pthread_create");
|
681
|
+
targs[i].id = -1;
|
682
|
+
err = true;
|
683
|
+
}
|
684
|
+
}
|
685
|
+
for(int i = 0; i < tnum; i++){
|
686
|
+
if(targs[i].id == -1) continue;
|
687
|
+
void *rv;
|
688
|
+
if(pthread_join(threads[i], &rv) != 0){
|
689
|
+
eprint(hdb, __LINE__, "pthread_join");
|
690
|
+
err = true;
|
691
|
+
} else if(rv){
|
692
|
+
err = true;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
}
|
696
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
697
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
698
|
+
mprint(hdb);
|
699
|
+
sysprint();
|
700
|
+
if(!tchdbclose(hdb)){
|
701
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
702
|
+
err = true;
|
703
|
+
}
|
704
|
+
tchdbdel(hdb);
|
705
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
706
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
707
|
+
return err ? 1 : 0;
|
708
|
+
}
|
709
|
+
|
710
|
+
|
711
|
+
/* perform read command */
|
712
|
+
static int procread(const char *path, int tnum, int rcnum, int xmsiz, int dfunit, int omode,
|
713
|
+
bool wb, bool rnd){
|
714
|
+
iprintf("<Reading Test>\n seed=%u path=%s tnum=%d rcnum=%d xmsiz=%d dfunit=%d omode=%d"
|
715
|
+
" wb=%d rnd=%d\n\n", g_randseed, path, tnum, rcnum, xmsiz, dfunit, omode, wb, rnd);
|
716
|
+
bool err = false;
|
717
|
+
double stime = tctime();
|
718
|
+
TCHDB *hdb = tchdbnew();
|
719
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
720
|
+
if(!tchdbsetmutex(hdb)){
|
721
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
722
|
+
err = true;
|
723
|
+
}
|
724
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
725
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
726
|
+
err = true;
|
727
|
+
}
|
728
|
+
if(!tchdbsetcache(hdb, rcnum)){
|
729
|
+
eprint(hdb, __LINE__, "tchdbsetcache");
|
730
|
+
err = true;
|
731
|
+
}
|
732
|
+
if(xmsiz >= 0 && !tchdbsetxmsiz(hdb, xmsiz)){
|
733
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
734
|
+
err = true;
|
735
|
+
}
|
736
|
+
if(dfunit >= 0 && !tchdbsetdfunit(hdb, dfunit)){
|
737
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
738
|
+
err = true;
|
739
|
+
}
|
740
|
+
if(!tchdbopen(hdb, path, HDBOREADER | omode)){
|
741
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
742
|
+
err = true;
|
743
|
+
}
|
744
|
+
int rnum = tchdbrnum(hdb) / tnum;
|
745
|
+
TARGREAD targs[tnum];
|
746
|
+
pthread_t threads[tnum];
|
747
|
+
if(tnum == 1){
|
748
|
+
targs[0].hdb = hdb;
|
749
|
+
targs[0].rnum = rnum;
|
750
|
+
targs[0].wb = wb;
|
751
|
+
targs[0].rnd = rnd;
|
752
|
+
targs[0].id = 0;
|
753
|
+
if(threadread(targs) != NULL) err = true;
|
754
|
+
} else {
|
755
|
+
for(int i = 0; i < tnum; i++){
|
756
|
+
targs[i].hdb = hdb;
|
757
|
+
targs[i].rnum = rnum;
|
758
|
+
targs[i].wb = wb;
|
759
|
+
targs[i].rnd = rnd;
|
760
|
+
targs[i].id = i;
|
761
|
+
if(pthread_create(threads + i, NULL, threadread, targs + i) != 0){
|
762
|
+
eprint(hdb, __LINE__, "pthread_create");
|
763
|
+
targs[i].id = -1;
|
764
|
+
err = true;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
for(int i = 0; i < tnum; i++){
|
768
|
+
if(targs[i].id == -1) continue;
|
769
|
+
void *rv;
|
770
|
+
if(pthread_join(threads[i], &rv) != 0){
|
771
|
+
eprint(hdb, __LINE__, "pthread_join");
|
772
|
+
err = true;
|
773
|
+
} else if(rv){
|
774
|
+
err = true;
|
775
|
+
}
|
776
|
+
}
|
777
|
+
}
|
778
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
779
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
780
|
+
mprint(hdb);
|
781
|
+
sysprint();
|
782
|
+
if(!tchdbclose(hdb)){
|
783
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
784
|
+
err = true;
|
785
|
+
}
|
786
|
+
tchdbdel(hdb);
|
787
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
788
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
789
|
+
return err ? 1 : 0;
|
790
|
+
}
|
791
|
+
|
792
|
+
|
793
|
+
/* perform remove command */
|
794
|
+
static int procremove(const char *path, int tnum, int rcnum, int xmsiz, int dfunit, int omode,
|
795
|
+
bool rnd){
|
796
|
+
iprintf("<Removing Test>\n seed=%u path=%s tnum=%d rcnum=%d xmsiz=%d dfunit=%d omode=%d"
|
797
|
+
" rnd=%d\n\n", g_randseed, path, tnum, rcnum, xmsiz, dfunit, omode, rnd);
|
798
|
+
bool err = false;
|
799
|
+
double stime = tctime();
|
800
|
+
TCHDB *hdb = tchdbnew();
|
801
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
802
|
+
if(!tchdbsetmutex(hdb)){
|
803
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
804
|
+
err = true;
|
805
|
+
}
|
806
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
807
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
808
|
+
err = true;
|
809
|
+
}
|
810
|
+
if(!tchdbsetcache(hdb, rcnum)){
|
811
|
+
eprint(hdb, __LINE__, "tchdbsetcache");
|
812
|
+
err = true;
|
813
|
+
}
|
814
|
+
if(xmsiz >= 0 && !tchdbsetxmsiz(hdb, xmsiz)){
|
815
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
816
|
+
err = true;
|
817
|
+
}
|
818
|
+
if(dfunit >= 0 && !tchdbsetdfunit(hdb, dfunit)){
|
819
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
820
|
+
err = true;
|
821
|
+
}
|
822
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | omode)){
|
823
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
824
|
+
err = true;
|
825
|
+
}
|
826
|
+
int rnum = tchdbrnum(hdb) / tnum;
|
827
|
+
TARGREMOVE targs[tnum];
|
828
|
+
pthread_t threads[tnum];
|
829
|
+
if(tnum == 1){
|
830
|
+
targs[0].hdb = hdb;
|
831
|
+
targs[0].rnum = rnum;
|
832
|
+
targs[0].rnd = rnd;
|
833
|
+
targs[0].id = 0;
|
834
|
+
if(threadremove(targs) != NULL) err = true;
|
835
|
+
} else {
|
836
|
+
for(int i = 0; i < tnum; i++){
|
837
|
+
targs[i].hdb = hdb;
|
838
|
+
targs[i].rnum = rnum;
|
839
|
+
targs[i].rnd = rnd;
|
840
|
+
targs[i].id = i;
|
841
|
+
if(pthread_create(threads + i, NULL, threadremove, targs + i) != 0){
|
842
|
+
eprint(hdb, __LINE__, "pthread_create");
|
843
|
+
targs[i].id = -1;
|
844
|
+
err = true;
|
845
|
+
}
|
846
|
+
}
|
847
|
+
for(int i = 0; i < tnum; i++){
|
848
|
+
if(targs[i].id == -1) continue;
|
849
|
+
void *rv;
|
850
|
+
if(pthread_join(threads[i], &rv) != 0){
|
851
|
+
eprint(hdb, __LINE__, "pthread_join");
|
852
|
+
err = true;
|
853
|
+
} else if(rv){
|
854
|
+
err = true;
|
855
|
+
}
|
856
|
+
}
|
857
|
+
}
|
858
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
859
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
860
|
+
mprint(hdb);
|
861
|
+
sysprint();
|
862
|
+
if(!tchdbclose(hdb)){
|
863
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
864
|
+
err = true;
|
865
|
+
}
|
866
|
+
tchdbdel(hdb);
|
867
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
868
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
869
|
+
return err ? 1 : 0;
|
870
|
+
}
|
871
|
+
|
872
|
+
|
873
|
+
/* perform wicked command */
|
874
|
+
static int procwicked(const char *path, int tnum, int rnum, int opts, int omode, bool nc){
|
875
|
+
iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d opts=%d omode=%d nc=%d\n\n",
|
876
|
+
g_randseed, path, tnum, rnum, opts, omode, nc);
|
877
|
+
bool err = false;
|
878
|
+
double stime = tctime();
|
879
|
+
TCHDB *hdb = tchdbnew();
|
880
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
881
|
+
if(!tchdbsetmutex(hdb)){
|
882
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
883
|
+
err = true;
|
884
|
+
}
|
885
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
886
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
887
|
+
err = true;
|
888
|
+
}
|
889
|
+
if(!tchdbtune(hdb, rnum / 50, 2, -1, opts)){
|
890
|
+
eprint(hdb, __LINE__, "tchdbtune");
|
891
|
+
err = true;
|
892
|
+
}
|
893
|
+
if(!tchdbsetcache(hdb, rnum / 2)){
|
894
|
+
eprint(hdb, __LINE__, "tchdbsetcache");
|
895
|
+
err = true;
|
896
|
+
}
|
897
|
+
if(!tchdbsetxmsiz(hdb, rnum * sizeof(int))){
|
898
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
899
|
+
err = true;
|
900
|
+
}
|
901
|
+
if(!tchdbsetdfunit(hdb, 8)){
|
902
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
903
|
+
err = true;
|
904
|
+
}
|
905
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC | omode)){
|
906
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
907
|
+
err = true;
|
908
|
+
}
|
909
|
+
if(!tchdbiterinit(hdb)){
|
910
|
+
eprint(hdb, __LINE__, "tchdbiterinit");
|
911
|
+
err = true;
|
912
|
+
}
|
913
|
+
TARGWICKED targs[tnum];
|
914
|
+
pthread_t threads[tnum];
|
915
|
+
TCMAP *map = tcmapnew();
|
916
|
+
if(tnum == 1){
|
917
|
+
targs[0].hdb = hdb;
|
918
|
+
targs[0].rnum = rnum;
|
919
|
+
targs[0].nc = nc;
|
920
|
+
targs[0].id = 0;
|
921
|
+
targs[0].map = map;
|
922
|
+
if(threadwicked(targs) != NULL) err = true;
|
923
|
+
} else {
|
924
|
+
for(int i = 0; i < tnum; i++){
|
925
|
+
targs[i].hdb = hdb;
|
926
|
+
targs[i].rnum = rnum;
|
927
|
+
targs[i].nc = nc;
|
928
|
+
targs[i].id = i;
|
929
|
+
targs[i].map = map;
|
930
|
+
if(pthread_create(threads + i, NULL, threadwicked, targs + i) != 0){
|
931
|
+
eprint(hdb, __LINE__, "pthread_create");
|
932
|
+
targs[i].id = -1;
|
933
|
+
err = true;
|
934
|
+
}
|
935
|
+
}
|
936
|
+
for(int i = 0; i < tnum; i++){
|
937
|
+
if(targs[i].id == -1) continue;
|
938
|
+
void *rv;
|
939
|
+
if(pthread_join(threads[i], &rv) != 0){
|
940
|
+
eprint(hdb, __LINE__, "pthread_join");
|
941
|
+
err = true;
|
942
|
+
} else if(rv){
|
943
|
+
err = true;
|
944
|
+
}
|
945
|
+
}
|
946
|
+
}
|
947
|
+
if(!nc){
|
948
|
+
if(!tchdbsync(hdb)){
|
949
|
+
eprint(hdb, __LINE__, "tchdbsync");
|
950
|
+
err = true;
|
951
|
+
}
|
952
|
+
if(tchdbrnum(hdb) != tcmaprnum(map)){
|
953
|
+
eprint(hdb, __LINE__, "(validation)");
|
954
|
+
err = true;
|
955
|
+
}
|
956
|
+
int end = rnum * tnum;
|
957
|
+
for(int i = 1; i <= end && !err; i++){
|
958
|
+
char kbuf[RECBUFSIZ];
|
959
|
+
int ksiz = sprintf(kbuf, "%d", i - 1);
|
960
|
+
int vsiz;
|
961
|
+
const char *vbuf = tcmapget(map, kbuf, ksiz, &vsiz);
|
962
|
+
int rsiz;
|
963
|
+
char *rbuf = tchdbget(hdb, kbuf, ksiz, &rsiz);
|
964
|
+
if(vbuf){
|
965
|
+
iputchar('.');
|
966
|
+
if(!rbuf){
|
967
|
+
eprint(hdb, __LINE__, "tchdbget");
|
968
|
+
err = true;
|
969
|
+
} else if(rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
|
970
|
+
eprint(hdb, __LINE__, "(validation)");
|
971
|
+
err = true;
|
972
|
+
}
|
973
|
+
} else {
|
974
|
+
iputchar('*');
|
975
|
+
if(rbuf || tchdbecode(hdb) != TCENOREC){
|
976
|
+
eprint(hdb, __LINE__, "(validation)");
|
977
|
+
err = true;
|
978
|
+
}
|
979
|
+
}
|
980
|
+
tcfree(rbuf);
|
981
|
+
if(i % 50 == 0) iprintf(" (%08d)\n", i);
|
982
|
+
}
|
983
|
+
if(rnum % 50 > 0) iprintf(" (%08d)\n", rnum);
|
984
|
+
}
|
985
|
+
tcmapdel(map);
|
986
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
987
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
988
|
+
mprint(hdb);
|
989
|
+
sysprint();
|
990
|
+
if(!tchdbclose(hdb)){
|
991
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
992
|
+
err = true;
|
993
|
+
}
|
994
|
+
tchdbdel(hdb);
|
995
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
996
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
997
|
+
return err ? 1 : 0;
|
998
|
+
}
|
999
|
+
|
1000
|
+
|
1001
|
+
/* perform typical command */
|
1002
|
+
static int proctypical(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
1003
|
+
int opts, int rcnum, int xmsiz, int dfunit, int omode,
|
1004
|
+
bool nc, int rratio){
|
1005
|
+
iprintf("<Typical Access Test>\n seed=%u path=%s tnum=%d rnum=%d bnum=%d apow=%d"
|
1006
|
+
" fpow=%d opts=%d rcnum=%d xmsiz=%d dfunit=%d omode=%d nc=%d rratio=%d\n\n",
|
1007
|
+
g_randseed, path, tnum, rnum, bnum, apow, fpow, opts, rcnum, xmsiz, dfunit, omode,
|
1008
|
+
nc, rratio);
|
1009
|
+
bool err = false;
|
1010
|
+
double stime = tctime();
|
1011
|
+
TCHDB *hdb = tchdbnew();
|
1012
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
1013
|
+
if(!tchdbsetmutex(hdb)){
|
1014
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
1015
|
+
err = true;
|
1016
|
+
}
|
1017
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
1018
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
1019
|
+
err = true;
|
1020
|
+
}
|
1021
|
+
if(!tchdbtune(hdb, bnum, apow, fpow, opts)){
|
1022
|
+
eprint(hdb, __LINE__, "tchdbtune");
|
1023
|
+
err = true;
|
1024
|
+
}
|
1025
|
+
if(!tchdbsetcache(hdb, rcnum)){
|
1026
|
+
eprint(hdb, __LINE__, "tchdbsetcache");
|
1027
|
+
err = true;
|
1028
|
+
}
|
1029
|
+
if(xmsiz >= 0 && !tchdbsetxmsiz(hdb, xmsiz)){
|
1030
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
1031
|
+
err = true;
|
1032
|
+
}
|
1033
|
+
if(dfunit >= 0 && !tchdbsetdfunit(hdb, dfunit)){
|
1034
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
1035
|
+
err = true;
|
1036
|
+
}
|
1037
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC | omode)){
|
1038
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
1039
|
+
err = true;
|
1040
|
+
}
|
1041
|
+
TARGTYPICAL targs[tnum];
|
1042
|
+
pthread_t threads[tnum];
|
1043
|
+
if(tnum == 1){
|
1044
|
+
targs[0].hdb = hdb;
|
1045
|
+
targs[0].rnum = rnum;
|
1046
|
+
targs[0].nc = nc;
|
1047
|
+
targs[0].rratio = rratio;
|
1048
|
+
targs[0].id = 0;
|
1049
|
+
if(threadtypical(targs) != NULL) err = true;
|
1050
|
+
} else {
|
1051
|
+
for(int i = 0; i < tnum; i++){
|
1052
|
+
targs[i].hdb = hdb;
|
1053
|
+
targs[i].rnum = rnum;
|
1054
|
+
targs[i].nc = nc;
|
1055
|
+
targs[i].rratio= rratio;
|
1056
|
+
targs[i].id = i;
|
1057
|
+
if(pthread_create(threads + i, NULL, threadtypical, targs + i) != 0){
|
1058
|
+
eprint(hdb, __LINE__, "pthread_create");
|
1059
|
+
targs[i].id = -1;
|
1060
|
+
err = true;
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
for(int i = 0; i < tnum; i++){
|
1064
|
+
if(targs[i].id == -1) continue;
|
1065
|
+
void *rv;
|
1066
|
+
if(pthread_join(threads[i], &rv) != 0){
|
1067
|
+
eprint(hdb, __LINE__, "pthread_join");
|
1068
|
+
err = true;
|
1069
|
+
} else if(rv){
|
1070
|
+
err = true;
|
1071
|
+
}
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
1075
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
1076
|
+
mprint(hdb);
|
1077
|
+
sysprint();
|
1078
|
+
if(!tchdbclose(hdb)){
|
1079
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
1080
|
+
err = true;
|
1081
|
+
}
|
1082
|
+
tchdbdel(hdb);
|
1083
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
1084
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
1085
|
+
return err ? 1 : 0;
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
|
1089
|
+
/* perform race command */
|
1090
|
+
static int procrace(const char *path, int tnum, int rnum, int bnum, int apow, int fpow,
|
1091
|
+
int opts, int xmsiz, int dfunit, int omode){
|
1092
|
+
iprintf("<Race Condition Test>\n seed=%u path=%s tnum=%d rnum=%d bnum=%d apow=%d"
|
1093
|
+
" fpow=%d opts=%d xmsiz=%d dfunit=%d omode=%d\n\n",
|
1094
|
+
g_randseed, path, tnum, rnum, bnum, apow, fpow, opts, xmsiz, dfunit, omode);
|
1095
|
+
bool err = false;
|
1096
|
+
double stime = tctime();
|
1097
|
+
TCHDB *hdb = tchdbnew();
|
1098
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
1099
|
+
if(!tchdbsetmutex(hdb)){
|
1100
|
+
eprint(hdb, __LINE__, "tchdbsetmutex");
|
1101
|
+
err = true;
|
1102
|
+
}
|
1103
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)){
|
1104
|
+
eprint(hdb, __LINE__, "tchdbsetcodecfunc");
|
1105
|
+
err = true;
|
1106
|
+
}
|
1107
|
+
if(!tchdbtune(hdb, bnum, apow, fpow, opts)){
|
1108
|
+
eprint(hdb, __LINE__, "tchdbtune");
|
1109
|
+
err = true;
|
1110
|
+
}
|
1111
|
+
if(xmsiz >= 0 && !tchdbsetxmsiz(hdb, xmsiz)){
|
1112
|
+
eprint(hdb, __LINE__, "tchdbsetxmsiz");
|
1113
|
+
err = true;
|
1114
|
+
}
|
1115
|
+
if(dfunit >= 0 && !tchdbsetdfunit(hdb, dfunit)){
|
1116
|
+
eprint(hdb, __LINE__, "tchdbsetdfunit");
|
1117
|
+
err = true;
|
1118
|
+
}
|
1119
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC | omode)){
|
1120
|
+
eprint(hdb, __LINE__, "tchdbopen");
|
1121
|
+
err = true;
|
1122
|
+
}
|
1123
|
+
TARGRACE targs[tnum];
|
1124
|
+
pthread_t threads[tnum];
|
1125
|
+
if(tnum == 1){
|
1126
|
+
targs[0].hdb = hdb;
|
1127
|
+
targs[0].rnum = rnum;
|
1128
|
+
targs[0].id = 0;
|
1129
|
+
if(threadrace(targs) != NULL) err = true;
|
1130
|
+
} else {
|
1131
|
+
for(int i = 0; i < tnum; i++){
|
1132
|
+
targs[i].hdb = hdb;
|
1133
|
+
targs[i].rnum = rnum;
|
1134
|
+
targs[i].id = i;
|
1135
|
+
if(pthread_create(threads + i, NULL, threadrace, targs + i) != 0){
|
1136
|
+
eprint(hdb, __LINE__, "pthread_create");
|
1137
|
+
targs[i].id = -1;
|
1138
|
+
err = true;
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
for(int i = 0; i < tnum; i++){
|
1142
|
+
if(targs[i].id == -1) continue;
|
1143
|
+
void *rv;
|
1144
|
+
if(pthread_join(threads[i], &rv) != 0){
|
1145
|
+
eprint(hdb, __LINE__, "pthread_join");
|
1146
|
+
err = true;
|
1147
|
+
} else if(rv){
|
1148
|
+
err = true;
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
}
|
1152
|
+
iprintf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
1153
|
+
iprintf("size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
1154
|
+
mprint(hdb);
|
1155
|
+
sysprint();
|
1156
|
+
if(!tchdbclose(hdb)){
|
1157
|
+
eprint(hdb, __LINE__, "tchdbclose");
|
1158
|
+
err = true;
|
1159
|
+
}
|
1160
|
+
tchdbdel(hdb);
|
1161
|
+
iprintf("time: %.3f\n", tctime() - stime);
|
1162
|
+
iprintf("%s\n\n", err ? "error" : "ok");
|
1163
|
+
return err ? 1 : 0;
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
|
1167
|
+
/* thread the write function */
|
1168
|
+
static void *threadwrite(void *targ){
|
1169
|
+
TCHDB *hdb = ((TARGWRITE *)targ)->hdb;
|
1170
|
+
int rnum = ((TARGWRITE *)targ)->rnum;
|
1171
|
+
bool as = ((TARGWRITE *)targ)->as;
|
1172
|
+
bool rnd = ((TARGWRITE *)targ)->rnd;
|
1173
|
+
int id = ((TARGWRITE *)targ)->id;
|
1174
|
+
bool err = false;
|
1175
|
+
int base = id * rnum;
|
1176
|
+
for(int i = 1; i <= rnum; i++){
|
1177
|
+
char buf[RECBUFSIZ];
|
1178
|
+
int len = sprintf(buf, "%08d", base + (rnd ? myrand(i) : i));
|
1179
|
+
if(as){
|
1180
|
+
if(!tchdbputasync(hdb, buf, len, buf, len)){
|
1181
|
+
eprint(hdb, __LINE__, "tchdbputasync");
|
1182
|
+
err = true;
|
1183
|
+
break;
|
1184
|
+
}
|
1185
|
+
} else {
|
1186
|
+
if(!tchdbput(hdb, buf, len, buf, len)){
|
1187
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1188
|
+
err = true;
|
1189
|
+
break;
|
1190
|
+
}
|
1191
|
+
}
|
1192
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1193
|
+
iputchar('.');
|
1194
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
return err ? "error" : NULL;
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
|
1201
|
+
/* thread the read function */
|
1202
|
+
static void *threadread(void *targ){
|
1203
|
+
TCHDB *hdb = ((TARGREAD *)targ)->hdb;
|
1204
|
+
int rnum = ((TARGREAD *)targ)->rnum;
|
1205
|
+
bool wb = ((TARGREAD *)targ)->wb;
|
1206
|
+
bool rnd = ((TARGREAD *)targ)->rnd;
|
1207
|
+
int id = ((TARGREAD *)targ)->id;
|
1208
|
+
bool err = false;
|
1209
|
+
int base = id * rnum;
|
1210
|
+
for(int i = 1; i <= rnum && !err; i++){
|
1211
|
+
char kbuf[RECBUFSIZ];
|
1212
|
+
int ksiz = sprintf(kbuf, "%08d", base + (rnd ? myrandnd(i) : i));
|
1213
|
+
int vsiz;
|
1214
|
+
if(wb){
|
1215
|
+
char vbuf[RECBUFSIZ];
|
1216
|
+
int vsiz = tchdbget3(hdb, kbuf, ksiz, vbuf, RECBUFSIZ);
|
1217
|
+
if(vsiz < 0 && (!rnd || tchdbecode(hdb) != TCENOREC)){
|
1218
|
+
eprint(hdb, __LINE__, "tchdbget3");
|
1219
|
+
err = true;
|
1220
|
+
}
|
1221
|
+
} else {
|
1222
|
+
char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
|
1223
|
+
if(!vbuf && (!rnd || tchdbecode(hdb) != TCENOREC)){
|
1224
|
+
eprint(hdb, __LINE__, "tchdbget");
|
1225
|
+
err = true;
|
1226
|
+
}
|
1227
|
+
tcfree(vbuf);
|
1228
|
+
}
|
1229
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1230
|
+
iputchar('.');
|
1231
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
return err ? "error" : NULL;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
|
1238
|
+
/* thread the remove function */
|
1239
|
+
static void *threadremove(void *targ){
|
1240
|
+
TCHDB *hdb = ((TARGREMOVE *)targ)->hdb;
|
1241
|
+
int rnum = ((TARGREMOVE *)targ)->rnum;
|
1242
|
+
bool rnd = ((TARGREMOVE *)targ)->rnd;
|
1243
|
+
int id = ((TARGREMOVE *)targ)->id;
|
1244
|
+
bool err = false;
|
1245
|
+
int base = id * rnum;
|
1246
|
+
for(int i = 1; i <= rnum; i++){
|
1247
|
+
char kbuf[RECBUFSIZ];
|
1248
|
+
int ksiz = sprintf(kbuf, "%08d", base + (rnd ? myrand(i + 1) : i));
|
1249
|
+
if(!tchdbout(hdb, kbuf, ksiz) && (!rnd || tchdbecode(hdb) != TCENOREC)){
|
1250
|
+
eprint(hdb, __LINE__, "tchdbout");
|
1251
|
+
err = true;
|
1252
|
+
break;
|
1253
|
+
}
|
1254
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1255
|
+
iputchar('.');
|
1256
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
return err ? "error" : NULL;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
|
1263
|
+
/* thread the wicked function */
|
1264
|
+
static void *threadwicked(void *targ){
|
1265
|
+
TCHDB *hdb = ((TARGWICKED *)targ)->hdb;
|
1266
|
+
int rnum = ((TARGWICKED *)targ)->rnum;
|
1267
|
+
bool nc = ((TARGWICKED *)targ)->nc;
|
1268
|
+
int id = ((TARGWICKED *)targ)->id;
|
1269
|
+
TCMAP *map = ((TARGWICKED *)targ)->map;
|
1270
|
+
bool err = false;
|
1271
|
+
for(int i = 1; i <= rnum && !err; i++){
|
1272
|
+
char kbuf[RECBUFSIZ];
|
1273
|
+
int ksiz = sprintf(kbuf, "%d", myrand(rnum * (id + 1)));
|
1274
|
+
char vbuf[RECBUFSIZ];
|
1275
|
+
int vsiz = myrand(RECBUFSIZ);
|
1276
|
+
memset(vbuf, '*', vsiz);
|
1277
|
+
vbuf[vsiz] = '\0';
|
1278
|
+
char *rbuf;
|
1279
|
+
if(!nc) tcglobalmutexlock();
|
1280
|
+
switch(myrand(16)){
|
1281
|
+
case 0:
|
1282
|
+
if(id == 0) iputchar('0');
|
1283
|
+
if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
|
1284
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1285
|
+
err = true;
|
1286
|
+
}
|
1287
|
+
if(!nc) tcmapput(map, kbuf, ksiz, vbuf, vsiz);
|
1288
|
+
break;
|
1289
|
+
case 1:
|
1290
|
+
if(id == 0) iputchar('1');
|
1291
|
+
if(!tchdbput2(hdb, kbuf, vbuf)){
|
1292
|
+
eprint(hdb, __LINE__, "tchdbput2");
|
1293
|
+
err = true;
|
1294
|
+
}
|
1295
|
+
if(!nc) tcmapput2(map, kbuf, vbuf);
|
1296
|
+
break;
|
1297
|
+
case 2:
|
1298
|
+
if(id == 0) iputchar('2');
|
1299
|
+
if(!tchdbputkeep(hdb, kbuf, ksiz, vbuf, vsiz) && tchdbecode(hdb) != TCEKEEP){
|
1300
|
+
eprint(hdb, __LINE__, "tchdbputkeep");
|
1301
|
+
err = true;
|
1302
|
+
}
|
1303
|
+
if(!nc) tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
|
1304
|
+
break;
|
1305
|
+
case 3:
|
1306
|
+
if(id == 0) iputchar('3');
|
1307
|
+
if(!tchdbputkeep2(hdb, kbuf, vbuf) && tchdbecode(hdb) != TCEKEEP){
|
1308
|
+
eprint(hdb, __LINE__, "tchdbputkeep2");
|
1309
|
+
err = true;
|
1310
|
+
}
|
1311
|
+
if(!nc) tcmapputkeep2(map, kbuf, vbuf);
|
1312
|
+
break;
|
1313
|
+
case 4:
|
1314
|
+
if(id == 0) iputchar('4');
|
1315
|
+
if(!tchdbputcat(hdb, kbuf, ksiz, vbuf, vsiz)){
|
1316
|
+
eprint(hdb, __LINE__, "tchdbputcat");
|
1317
|
+
err = true;
|
1318
|
+
}
|
1319
|
+
if(!nc) tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
|
1320
|
+
break;
|
1321
|
+
case 5:
|
1322
|
+
if(id == 0) iputchar('5');
|
1323
|
+
if(!tchdbputcat2(hdb, kbuf, vbuf)){
|
1324
|
+
eprint(hdb, __LINE__, "tchdbputcat2");
|
1325
|
+
err = true;
|
1326
|
+
}
|
1327
|
+
if(!nc) tcmapputcat2(map, kbuf, vbuf);
|
1328
|
+
break;
|
1329
|
+
case 6:
|
1330
|
+
if(id == 0) iputchar('6');
|
1331
|
+
if(i > rnum / 4 * 3){
|
1332
|
+
if(!tchdbputasync(hdb, kbuf, ksiz, vbuf, vsiz)){
|
1333
|
+
eprint(hdb, __LINE__, "tchdbputasync");
|
1334
|
+
err = true;
|
1335
|
+
}
|
1336
|
+
} else {
|
1337
|
+
if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
|
1338
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1339
|
+
err = true;
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
if(!nc) tcmapput(map, kbuf, ksiz, vbuf, vsiz);
|
1343
|
+
break;
|
1344
|
+
case 7:
|
1345
|
+
if(id == 0) iputchar('7');
|
1346
|
+
if(i > rnum / 4 * 3){
|
1347
|
+
if(!tchdbputasync2(hdb, kbuf, vbuf)){
|
1348
|
+
eprint(hdb, __LINE__, "tchdbputasync2");
|
1349
|
+
err = true;
|
1350
|
+
}
|
1351
|
+
} else {
|
1352
|
+
if(!tchdbput2(hdb, kbuf, vbuf)){
|
1353
|
+
eprint(hdb, __LINE__, "tchdbput2");
|
1354
|
+
err = true;
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
if(!nc) tcmapput2(map, kbuf, vbuf);
|
1358
|
+
break;
|
1359
|
+
case 8:
|
1360
|
+
if(id == 0) iputchar('8');
|
1361
|
+
if(myrand(2) == 0){
|
1362
|
+
if(!tchdbout(hdb, kbuf, ksiz) && tchdbecode(hdb) != TCENOREC){
|
1363
|
+
eprint(hdb, __LINE__, "tchdbout");
|
1364
|
+
err = true;
|
1365
|
+
}
|
1366
|
+
if(!nc) tcmapout(map, kbuf, ksiz);
|
1367
|
+
}
|
1368
|
+
break;
|
1369
|
+
case 9:
|
1370
|
+
if(id == 0) iputchar('9');
|
1371
|
+
if(myrand(2) == 0){
|
1372
|
+
if(!tchdbout2(hdb, kbuf) && tchdbecode(hdb) != TCENOREC){
|
1373
|
+
eprint(hdb, __LINE__, "tchdbout2");
|
1374
|
+
err = true;
|
1375
|
+
}
|
1376
|
+
if(!nc) tcmapout2(map, kbuf);
|
1377
|
+
}
|
1378
|
+
break;
|
1379
|
+
case 10:
|
1380
|
+
if(id == 0) iputchar('A');
|
1381
|
+
if(!(rbuf = tchdbget(hdb, kbuf, ksiz, &vsiz))){
|
1382
|
+
if(tchdbecode(hdb) != TCENOREC){
|
1383
|
+
eprint(hdb, __LINE__, "tchdbget");
|
1384
|
+
err = true;
|
1385
|
+
}
|
1386
|
+
rbuf = tcsprintf("[%d]", myrand(i + 1));
|
1387
|
+
vsiz = strlen(rbuf);
|
1388
|
+
}
|
1389
|
+
vsiz += myrand(vsiz);
|
1390
|
+
if(myrand(3) == 0) vsiz += PATH_MAX;
|
1391
|
+
rbuf = tcrealloc(rbuf, vsiz + 1);
|
1392
|
+
for(int j = 0; j < vsiz; j++){
|
1393
|
+
rbuf[j] = myrand(0x100);
|
1394
|
+
}
|
1395
|
+
if(!tchdbput(hdb, kbuf, ksiz, rbuf, vsiz)){
|
1396
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1397
|
+
err = true;
|
1398
|
+
}
|
1399
|
+
if(!nc) tcmapput(map, kbuf, ksiz, rbuf, vsiz);
|
1400
|
+
tcfree(rbuf);
|
1401
|
+
break;
|
1402
|
+
case 11:
|
1403
|
+
if(id == 0) iputchar('B');
|
1404
|
+
if(!(rbuf = tchdbget(hdb, kbuf, ksiz, &vsiz)) && tchdbecode(hdb) != TCENOREC){
|
1405
|
+
eprint(hdb, __LINE__, "tchdbget");
|
1406
|
+
err = true;
|
1407
|
+
}
|
1408
|
+
tcfree(rbuf);
|
1409
|
+
break;
|
1410
|
+
case 12:
|
1411
|
+
if(id == 0) iputchar('C');
|
1412
|
+
if(!(rbuf = tchdbget2(hdb, kbuf)) && tchdbecode(hdb) != TCENOREC){
|
1413
|
+
eprint(hdb, __LINE__, "tchdbget2");
|
1414
|
+
err = true;
|
1415
|
+
}
|
1416
|
+
tcfree(rbuf);
|
1417
|
+
break;
|
1418
|
+
case 13:
|
1419
|
+
if(id == 0) iputchar('D');
|
1420
|
+
if(myrand(1) == 0) vsiz = 1;
|
1421
|
+
if((vsiz = tchdbget3(hdb, kbuf, ksiz, vbuf, vsiz)) < 0 && tchdbecode(hdb) != TCENOREC){
|
1422
|
+
eprint(hdb, __LINE__, "tchdbget3");
|
1423
|
+
err = true;
|
1424
|
+
}
|
1425
|
+
break;
|
1426
|
+
case 14:
|
1427
|
+
if(id == 0) iputchar('E');
|
1428
|
+
if(myrand(rnum / 50) == 0){
|
1429
|
+
if(!tchdbiterinit(hdb)){
|
1430
|
+
eprint(hdb, __LINE__, "tchdbiterinit");
|
1431
|
+
err = true;
|
1432
|
+
}
|
1433
|
+
}
|
1434
|
+
TCXSTR *ikey = tcxstrnew();
|
1435
|
+
TCXSTR *ival = tcxstrnew();
|
1436
|
+
for(int j = myrand(rnum) / 1000 + 1; j >= 0; j--){
|
1437
|
+
if(j % 3 == 0){
|
1438
|
+
if(!tchdbiternext3(hdb, ikey, ival)){
|
1439
|
+
int ecode = tchdbecode(hdb);
|
1440
|
+
if(ecode != TCEINVALID && ecode != TCENOREC){
|
1441
|
+
eprint(hdb, __LINE__, "tchdbiternext3");
|
1442
|
+
err = true;
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
} else {
|
1446
|
+
int iksiz;
|
1447
|
+
char *ikbuf = tchdbiternext(hdb, &iksiz);
|
1448
|
+
if(ikbuf){
|
1449
|
+
tcfree(ikbuf);
|
1450
|
+
} else {
|
1451
|
+
int ecode = tchdbecode(hdb);
|
1452
|
+
if(ecode != TCEINVALID && ecode != TCENOREC){
|
1453
|
+
eprint(hdb, __LINE__, "tchdbiternext");
|
1454
|
+
err = true;
|
1455
|
+
}
|
1456
|
+
}
|
1457
|
+
}
|
1458
|
+
}
|
1459
|
+
tcxstrdel(ival);
|
1460
|
+
tcxstrdel(ikey);
|
1461
|
+
break;
|
1462
|
+
default:
|
1463
|
+
if(id == 0) iputchar('@');
|
1464
|
+
if(tchdbtranbegin(hdb)){
|
1465
|
+
if(myrand(2) == 0){
|
1466
|
+
if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
|
1467
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1468
|
+
err = true;
|
1469
|
+
}
|
1470
|
+
if(!nc) tcmapput(map, kbuf, ksiz, vbuf, vsiz);
|
1471
|
+
} else {
|
1472
|
+
if(!tchdbout(hdb, kbuf, ksiz) && tchdbecode(hdb) != TCENOREC){
|
1473
|
+
eprint(hdb, __LINE__, "tchdbout");
|
1474
|
+
err = true;
|
1475
|
+
}
|
1476
|
+
if(!nc) tcmapout(map, kbuf, ksiz);
|
1477
|
+
}
|
1478
|
+
if(nc && myrand(2) == 0){
|
1479
|
+
if(!tchdbtranabort(hdb)){
|
1480
|
+
eprint(hdb, __LINE__, "tchdbtranabort");
|
1481
|
+
err = true;
|
1482
|
+
}
|
1483
|
+
} else {
|
1484
|
+
if(!tchdbtrancommit(hdb)){
|
1485
|
+
eprint(hdb, __LINE__, "tchdbtrancommit");
|
1486
|
+
err = true;
|
1487
|
+
}
|
1488
|
+
}
|
1489
|
+
} else {
|
1490
|
+
eprint(hdb, __LINE__, "tchdbtranbegin");
|
1491
|
+
err = true;
|
1492
|
+
}
|
1493
|
+
if(myrand(1000) == 0){
|
1494
|
+
if(!tchdbforeach(hdb, iterfunc, NULL)){
|
1495
|
+
eprint(hdb, __LINE__, "tchdbforeach");
|
1496
|
+
err = true;
|
1497
|
+
}
|
1498
|
+
}
|
1499
|
+
if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
|
1500
|
+
break;
|
1501
|
+
}
|
1502
|
+
if(!nc) tcglobalmutexunlock();
|
1503
|
+
if(id == 0){
|
1504
|
+
if(i % 50 == 0) iprintf(" (%08d)\n", i);
|
1505
|
+
if(id == 0 && i == rnum / 4){
|
1506
|
+
if(!tchdboptimize(hdb, rnum / 50, -1, -1, -1) && tchdbecode(hdb) != TCEINVALID){
|
1507
|
+
eprint(hdb, __LINE__, "tchdboptimize");
|
1508
|
+
err = true;
|
1509
|
+
}
|
1510
|
+
if(!tchdbiterinit(hdb)){
|
1511
|
+
eprint(hdb, __LINE__, "tchdbiterinit");
|
1512
|
+
err = true;
|
1513
|
+
}
|
1514
|
+
}
|
1515
|
+
}
|
1516
|
+
}
|
1517
|
+
return err ? "error" : NULL;
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
|
1521
|
+
/* thread the typical function */
|
1522
|
+
static void *threadtypical(void *targ){
|
1523
|
+
TCHDB *hdb = ((TARGTYPICAL *)targ)->hdb;
|
1524
|
+
int rnum = ((TARGTYPICAL *)targ)->rnum;
|
1525
|
+
bool nc = ((TARGTYPICAL *)targ)->nc;
|
1526
|
+
int rratio = ((TARGTYPICAL *)targ)->rratio;
|
1527
|
+
int id = ((TARGTYPICAL *)targ)->id;
|
1528
|
+
bool err = false;
|
1529
|
+
TCMAP *map = (!nc && id == 0) ? tcmapnew2(rnum + 1) : NULL;
|
1530
|
+
int base = id * rnum;
|
1531
|
+
int mrange = tclmax(50 + rratio, 100);
|
1532
|
+
for(int i = 1; !err && i <= rnum; i++){
|
1533
|
+
char buf[RECBUFSIZ];
|
1534
|
+
int len = sprintf(buf, "%08d", base + myrandnd(i));
|
1535
|
+
int rnd = myrand(mrange);
|
1536
|
+
if(rnd < 10){
|
1537
|
+
if(!tchdbput(hdb, buf, len, buf, len)){
|
1538
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1539
|
+
err = true;
|
1540
|
+
}
|
1541
|
+
if(map) tcmapput(map, buf, len, buf, len);
|
1542
|
+
} else if(rnd < 15){
|
1543
|
+
if(!tchdbputkeep(hdb, buf, len, buf, len) && tchdbecode(hdb) != TCEKEEP){
|
1544
|
+
eprint(hdb, __LINE__, "tchdbputkeep");
|
1545
|
+
err = true;
|
1546
|
+
}
|
1547
|
+
if(map) tcmapputkeep(map, buf, len, buf, len);
|
1548
|
+
} else if(rnd < 20){
|
1549
|
+
if(!tchdbputcat(hdb, buf, len, buf, len)){
|
1550
|
+
eprint(hdb, __LINE__, "tchdbputcat");
|
1551
|
+
err = true;
|
1552
|
+
}
|
1553
|
+
if(map) tcmapputcat(map, buf, len, buf, len);
|
1554
|
+
} else if(rnd < 25){
|
1555
|
+
if(i > rnum / 10 * 9){
|
1556
|
+
if(!tchdbputasync(hdb, buf, len, buf, len)){
|
1557
|
+
eprint(hdb, __LINE__, "tchdbputasync");
|
1558
|
+
err = true;
|
1559
|
+
}
|
1560
|
+
} else {
|
1561
|
+
if(!tchdbput(hdb, buf, len, buf, len)){
|
1562
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1563
|
+
err = true;
|
1564
|
+
}
|
1565
|
+
}
|
1566
|
+
if(map) tcmapput(map, buf, len, buf, len);
|
1567
|
+
} else if(rnd < 30){
|
1568
|
+
if(!tchdbout(hdb, buf, len) && tchdbecode(hdb) && tchdbecode(hdb) != TCENOREC){
|
1569
|
+
eprint(hdb, __LINE__, "tchdbout");
|
1570
|
+
err = true;
|
1571
|
+
}
|
1572
|
+
if(map) tcmapout(map, buf, len);
|
1573
|
+
} else if(rnd < 31){
|
1574
|
+
if(myrand(10) == 0 && !tchdbiterinit(hdb) && tchdbecode(hdb) != TCENOREC){
|
1575
|
+
eprint(hdb, __LINE__, "tchdbiterinit");
|
1576
|
+
err = true;
|
1577
|
+
}
|
1578
|
+
for(int j = 0; !err && j < 10; j++){
|
1579
|
+
int ksiz;
|
1580
|
+
char *kbuf = tchdbiternext(hdb, &ksiz);
|
1581
|
+
if(kbuf){
|
1582
|
+
tcfree(kbuf);
|
1583
|
+
} else if(tchdbecode(hdb) != TCEINVALID && tchdbecode(hdb) != TCENOREC){
|
1584
|
+
eprint(hdb, __LINE__, "tchdbiternext");
|
1585
|
+
err = true;
|
1586
|
+
}
|
1587
|
+
}
|
1588
|
+
} else {
|
1589
|
+
int vsiz;
|
1590
|
+
char *vbuf = tchdbget(hdb, buf, len, &vsiz);
|
1591
|
+
if(vbuf){
|
1592
|
+
if(map){
|
1593
|
+
int msiz;
|
1594
|
+
const char *mbuf = tcmapget(map, buf, len, &msiz);
|
1595
|
+
if(!mbuf || msiz != vsiz || memcmp(mbuf, vbuf, vsiz)){
|
1596
|
+
eprint(hdb, __LINE__, "(validation)");
|
1597
|
+
err = true;
|
1598
|
+
}
|
1599
|
+
}
|
1600
|
+
tcfree(vbuf);
|
1601
|
+
} else {
|
1602
|
+
if(tchdbecode(hdb) != TCENOREC){
|
1603
|
+
eprint(hdb, __LINE__, "tchdbget");
|
1604
|
+
err = true;
|
1605
|
+
}
|
1606
|
+
if(map && tcmapget(map, buf, len, &vsiz)){
|
1607
|
+
eprint(hdb, __LINE__, "(validation)");
|
1608
|
+
err = true;
|
1609
|
+
}
|
1610
|
+
}
|
1611
|
+
}
|
1612
|
+
if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
|
1613
|
+
iputchar('.');
|
1614
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1615
|
+
}
|
1616
|
+
}
|
1617
|
+
if(map){
|
1618
|
+
tcmapiterinit(map);
|
1619
|
+
int ksiz;
|
1620
|
+
const char *kbuf;
|
1621
|
+
while(!err && (kbuf = tcmapiternext(map, &ksiz)) != NULL){
|
1622
|
+
int vsiz;
|
1623
|
+
char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
|
1624
|
+
if(vbuf){
|
1625
|
+
int msiz;
|
1626
|
+
const char *mbuf = tcmapget(map, kbuf, ksiz, &msiz);
|
1627
|
+
if(!mbuf || msiz != vsiz || memcmp(mbuf, vbuf, vsiz)){
|
1628
|
+
eprint(hdb, __LINE__, "(validation)");
|
1629
|
+
err = true;
|
1630
|
+
}
|
1631
|
+
tcfree(vbuf);
|
1632
|
+
} else {
|
1633
|
+
eprint(hdb, __LINE__, "(validation)");
|
1634
|
+
err = true;
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
tcmapdel(map);
|
1638
|
+
}
|
1639
|
+
return err ? "error" : NULL;
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
|
1643
|
+
/* thread the race function */
|
1644
|
+
static void *threadrace(void *targ){
|
1645
|
+
TCHDB *hdb = ((TARGRACE *)targ)->hdb;
|
1646
|
+
int rnum = ((TARGRACE *)targ)->rnum;
|
1647
|
+
int id = ((TARGRACE *)targ)->id;
|
1648
|
+
bool err = false;
|
1649
|
+
int mid = rnum * 2;
|
1650
|
+
for(int i = 1; !err && i <= rnum; i++){
|
1651
|
+
char buf[RECBUFSIZ];
|
1652
|
+
int len = sprintf(buf, "%d", myrandnd(i));
|
1653
|
+
int rnd = myrand(100);
|
1654
|
+
if(rnd < 10){
|
1655
|
+
if(!tchdbputkeep(hdb, buf, len, buf, len) && tchdbecode(hdb) != TCEKEEP){
|
1656
|
+
eprint(hdb, __LINE__, "tchdbputkeep");
|
1657
|
+
err = true;
|
1658
|
+
}
|
1659
|
+
} else if(rnd < 20){
|
1660
|
+
if(!tchdbputcat(hdb, buf, len, buf, len)){
|
1661
|
+
eprint(hdb, __LINE__, "tchdbputcat");
|
1662
|
+
err = true;
|
1663
|
+
}
|
1664
|
+
} else if(rnd < 30){
|
1665
|
+
if(!tchdbout(hdb, buf, len) && tchdbecode(hdb) != TCENOREC){
|
1666
|
+
eprint(hdb, __LINE__, "tchdbout");
|
1667
|
+
err = true;
|
1668
|
+
}
|
1669
|
+
} else if(rnd < 31){
|
1670
|
+
if(!tchdbputasync(hdb, buf, len, buf, len)){
|
1671
|
+
eprint(hdb, __LINE__, "tchdbputasync");
|
1672
|
+
err = true;
|
1673
|
+
}
|
1674
|
+
} else {
|
1675
|
+
if(myrand(10) == 0){
|
1676
|
+
int rsiz = myrand(256);
|
1677
|
+
char *rbuf = tcmalloc(rsiz + 1);
|
1678
|
+
for(int j = 0; j < rsiz; j++){
|
1679
|
+
rbuf[j] = myrand('z' - 'a') + 'a';
|
1680
|
+
}
|
1681
|
+
if(myrand(2) == 0){
|
1682
|
+
if(!tchdbput(hdb, buf, len, rbuf, rsiz)){
|
1683
|
+
eprint(hdb, __LINE__, "tchdbputcat");
|
1684
|
+
err = true;
|
1685
|
+
}
|
1686
|
+
} else {
|
1687
|
+
if(!tchdbputcat(hdb, buf, len, rbuf, rsiz)){
|
1688
|
+
eprint(hdb, __LINE__, "tchdbputcat");
|
1689
|
+
err = true;
|
1690
|
+
}
|
1691
|
+
}
|
1692
|
+
tcfree(rbuf);
|
1693
|
+
} else {
|
1694
|
+
if(!tchdbput(hdb, buf, len, buf, len)){
|
1695
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1696
|
+
err = true;
|
1697
|
+
}
|
1698
|
+
}
|
1699
|
+
}
|
1700
|
+
if(id == 0){
|
1701
|
+
if(myrand(mid) == 0){
|
1702
|
+
iprintf("[v]");
|
1703
|
+
if(!tchdbvanish(hdb)){
|
1704
|
+
eprint(hdb, __LINE__, "tchdbvanish");
|
1705
|
+
err = true;
|
1706
|
+
}
|
1707
|
+
}
|
1708
|
+
if(myrand(mid) == 0){
|
1709
|
+
iprintf("[o]");
|
1710
|
+
if(!tchdboptimize(hdb, myrand(rnum) + 1, myrand(10), myrand(10), 0)){
|
1711
|
+
eprint(hdb, __LINE__, "tchdboptimize");
|
1712
|
+
err = true;
|
1713
|
+
}
|
1714
|
+
}
|
1715
|
+
if(myrand(mid) == 0){
|
1716
|
+
iprintf("[d]");
|
1717
|
+
if(!tchdbdefrag(hdb, -1)){
|
1718
|
+
eprint(hdb, __LINE__, "tchdbdefrag");
|
1719
|
+
err = true;
|
1720
|
+
}
|
1721
|
+
}
|
1722
|
+
if(myrand(mid) == 0){
|
1723
|
+
iprintf("[i]");
|
1724
|
+
if(!tchdbiterinit(hdb)){
|
1725
|
+
eprint(hdb, __LINE__, "tchdbput");
|
1726
|
+
err = true;
|
1727
|
+
}
|
1728
|
+
char *kbuf;
|
1729
|
+
int ksiz;
|
1730
|
+
while((kbuf = tchdbiternext(hdb, &ksiz)) != NULL){
|
1731
|
+
int vsiz;
|
1732
|
+
char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
|
1733
|
+
if(vbuf){
|
1734
|
+
tcfree(vbuf);
|
1735
|
+
} else if(tchdbecode(hdb) != TCENOREC){
|
1736
|
+
eprint(hdb, __LINE__, "tchdbget");
|
1737
|
+
err = true;
|
1738
|
+
}
|
1739
|
+
tcfree(kbuf);
|
1740
|
+
}
|
1741
|
+
if(tchdbecode(hdb) != TCENOREC){
|
1742
|
+
eprint(hdb, __LINE__, "(validation)");
|
1743
|
+
err = true;
|
1744
|
+
}
|
1745
|
+
}
|
1746
|
+
if(rnum > 250 && i % (rnum / 250) == 0){
|
1747
|
+
iputchar('.');
|
1748
|
+
if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
}
|
1752
|
+
return err ? "error" : NULL;
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
|
1756
|
+
|
1757
|
+
// END OF FILE
|