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,1019 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* The command line utility of the abstract 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 <tcbdb.h>
|
19
|
+
#include <tcadb.h>
|
20
|
+
#include "myconf.h"
|
21
|
+
|
22
|
+
|
23
|
+
/* global variables */
|
24
|
+
const char *g_progname; // program name
|
25
|
+
|
26
|
+
|
27
|
+
/* function prototypes */
|
28
|
+
int main(int argc, char **argv);
|
29
|
+
static void usage(void);
|
30
|
+
static void printerr(TCADB *adb);
|
31
|
+
static int sepstrtochr(const char *str);
|
32
|
+
static char *strtozsv(const char *str, int sep, int *sp);
|
33
|
+
static int printdata(const char *ptr, int size, bool px, int sep);
|
34
|
+
static void setskeltran(ADBSKEL *skel);
|
35
|
+
static bool mapbdbproc(void *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
36
|
+
void *op);
|
37
|
+
static int runcreate(int argc, char **argv);
|
38
|
+
static int runinform(int argc, char **argv);
|
39
|
+
static int runput(int argc, char **argv);
|
40
|
+
static int runout(int argc, char **argv);
|
41
|
+
static int runget(int argc, char **argv);
|
42
|
+
static int runlist(int argc, char **argv);
|
43
|
+
static int runoptimize(int argc, char **argv);
|
44
|
+
static int runmisc(int argc, char **argv);
|
45
|
+
static int runmap(int argc, char **argv);
|
46
|
+
static int runversion(int argc, char **argv);
|
47
|
+
static int proccreate(const char *name);
|
48
|
+
static int procinform(const char *name);
|
49
|
+
static int procput(const char *name, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
50
|
+
int dmode);
|
51
|
+
static int procout(const char *name, const char *kbuf, int ksiz);
|
52
|
+
static int procget(const char *name, const char *kbuf, int ksiz, int sep, bool px, bool pz);
|
53
|
+
static int proclist(const char *name, int sep, int max, bool pv, bool px, const char *fmstr);
|
54
|
+
static int procoptimize(const char *name, const char *params);
|
55
|
+
static int procmisc(const char *name, const char *func, const TCLIST *args, int sep, bool px);
|
56
|
+
static int procmap(const char *name, const char *dest, const char *fmstr);
|
57
|
+
static int procversion(void);
|
58
|
+
|
59
|
+
|
60
|
+
/* main routine */
|
61
|
+
int main(int argc, char **argv){
|
62
|
+
g_progname = argv[0];
|
63
|
+
if(argc < 2) usage();
|
64
|
+
int rv = 0;
|
65
|
+
if(!strcmp(argv[1], "create")){
|
66
|
+
rv = runcreate(argc, argv);
|
67
|
+
} else if(!strcmp(argv[1], "inform")){
|
68
|
+
rv = runinform(argc, argv);
|
69
|
+
} else if(!strcmp(argv[1], "put")){
|
70
|
+
rv = runput(argc, argv);
|
71
|
+
} else if(!strcmp(argv[1], "out")){
|
72
|
+
rv = runout(argc, argv);
|
73
|
+
} else if(!strcmp(argv[1], "get")){
|
74
|
+
rv = runget(argc, argv);
|
75
|
+
} else if(!strcmp(argv[1], "list")){
|
76
|
+
rv = runlist(argc, argv);
|
77
|
+
} else if(!strcmp(argv[1], "optimize")){
|
78
|
+
rv = runoptimize(argc, argv);
|
79
|
+
} else if(!strcmp(argv[1], "misc")){
|
80
|
+
rv = runmisc(argc, argv);
|
81
|
+
} else if(!strcmp(argv[1], "map")){
|
82
|
+
rv = runmap(argc, argv);
|
83
|
+
} else if(!strcmp(argv[1], "version") || !strcmp(argv[1], "--version")){
|
84
|
+
rv = runversion(argc, argv);
|
85
|
+
} else {
|
86
|
+
usage();
|
87
|
+
}
|
88
|
+
return rv;
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
/* print the usage and exit */
|
93
|
+
static void usage(void){
|
94
|
+
fprintf(stderr, "%s: the command line utility of the abstract database API\n", g_progname);
|
95
|
+
fprintf(stderr, "\n");
|
96
|
+
fprintf(stderr, "usage:\n");
|
97
|
+
fprintf(stderr, " %s create name\n", g_progname);
|
98
|
+
fprintf(stderr, " %s inform name\n", g_progname);
|
99
|
+
fprintf(stderr, " %s put [-sx] [-sep chr] [-dk|-dc|-dai|-dad] name key value\n", g_progname);
|
100
|
+
fprintf(stderr, " %s out [-sx] [-sep chr] name key\n", g_progname);
|
101
|
+
fprintf(stderr, " %s get [-sx] [-sep chr] [-px] [-pz] name key\n", g_progname);
|
102
|
+
fprintf(stderr, " %s list [-sep chr] [-m num] [-pv] [-px] [-fm str] name\n", g_progname);
|
103
|
+
fprintf(stderr, " %s optimize name [params]\n", g_progname);
|
104
|
+
fprintf(stderr, " %s misc [-sx] [-sep chr] [-px] name func [arg...]\n", g_progname);
|
105
|
+
fprintf(stderr, " %s map [-fm str] name dest\n", g_progname);
|
106
|
+
fprintf(stderr, " %s version\n", g_progname);
|
107
|
+
fprintf(stderr, "\n");
|
108
|
+
exit(1);
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
/* get the character of separation string */
|
113
|
+
static int sepstrtochr(const char *str){
|
114
|
+
if(!strcmp(str, "\\t")) return '\t';
|
115
|
+
if(!strcmp(str, "\\r")) return '\r';
|
116
|
+
if(!strcmp(str, "\\n")) return '\n';
|
117
|
+
return *(unsigned char *)str;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
/* encode a string as a zero separaterd string */
|
122
|
+
static char *strtozsv(const char *str, int sep, int *sp){
|
123
|
+
int size = strlen(str);
|
124
|
+
char *buf = tcmemdup(str, size);
|
125
|
+
for(int i = 0; i < size; i++){
|
126
|
+
if(buf[i] == sep) buf[i] = '\0';
|
127
|
+
}
|
128
|
+
*sp = size;
|
129
|
+
return buf;
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
/* print error information */
|
134
|
+
static void printerr(TCADB *adb){
|
135
|
+
const char *path = tcadbpath(adb);
|
136
|
+
fprintf(stderr, "%s: %s: error\n", g_progname, path ? path : "-");
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
/* print record data */
|
141
|
+
static int printdata(const char *ptr, int size, bool px, int sep){
|
142
|
+
int len = 0;
|
143
|
+
while(size-- > 0){
|
144
|
+
if(px){
|
145
|
+
if(len > 0) putchar(' ');
|
146
|
+
len += printf("%02X", *(unsigned char *)ptr);
|
147
|
+
} else if(sep > 0){
|
148
|
+
if(*ptr == '\0'){
|
149
|
+
putchar(sep);
|
150
|
+
} else {
|
151
|
+
putchar(*ptr);
|
152
|
+
}
|
153
|
+
len++;
|
154
|
+
} else {
|
155
|
+
putchar(*ptr);
|
156
|
+
len++;
|
157
|
+
}
|
158
|
+
ptr++;
|
159
|
+
}
|
160
|
+
return len;
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
/* set the transparent skeleton database */
|
165
|
+
static void setskeltran(ADBSKEL *skel){
|
166
|
+
memset(skel, 0, sizeof(*skel));
|
167
|
+
skel->opq = tcadbnew();
|
168
|
+
skel->del = (void (*)(void *))tcadbdel;
|
169
|
+
skel->open = (bool (*)(void *, const char *))tcadbopen;
|
170
|
+
skel->close = (bool (*)(void *))tcadbclose;
|
171
|
+
skel->put = (bool (*)(void *, const void *, int, const void *, int))tcadbput;
|
172
|
+
skel->putkeep = (bool (*)(void *, const void *, int, const void *, int))tcadbputkeep;
|
173
|
+
skel->putcat = (bool (*)(void *, const void *, int, const void *, int))tcadbputcat;
|
174
|
+
skel->out = (bool (*)(void *, const void *, int))tcadbout;
|
175
|
+
skel->get = (void *(*)(void *, const void *, int, int *))tcadbget;
|
176
|
+
skel->vsiz = (int (*)(void *, const void *, int))tcadbvsiz;
|
177
|
+
skel->iterinit = (bool (*)(void *))tcadbiterinit;
|
178
|
+
skel->iternext = (void *(*)(void *, int *))tcadbiternext;
|
179
|
+
skel->fwmkeys = (TCLIST *(*)(void *, const void *, int, int))tcadbfwmkeys;
|
180
|
+
skel->addint = (int (*)(void *, const void *, int, int))tcadbaddint;
|
181
|
+
skel->adddouble = (double (*)(void *, const void *, int, double))tcadbadddouble;
|
182
|
+
skel->sync = (bool (*)(void *))tcadbsync;
|
183
|
+
skel->optimize = (bool (*)(void *, const char *))tcadboptimize;
|
184
|
+
skel->vanish = (bool (*)(void *))tcadbvanish;
|
185
|
+
skel->copy = (bool (*)(void *, const char *))tcadbcopy;
|
186
|
+
skel->tranbegin = (bool (*)(void *))tcadbtranbegin;
|
187
|
+
skel->trancommit = (bool (*)(void *))tcadbtrancommit;
|
188
|
+
skel->tranabort = (bool (*)(void *))tcadbtranabort;
|
189
|
+
skel->path = (const char *(*)(void *))tcadbpath;
|
190
|
+
skel->rnum = (uint64_t (*)(void *))tcadbrnum;
|
191
|
+
skel->size = (uint64_t (*)(void *))tcadbsize;
|
192
|
+
skel->misc = (TCLIST *(*)(void *, const char *, const TCLIST *))tcadbmisc;
|
193
|
+
skel->putproc =
|
194
|
+
(bool (*)(void *, const void *, int, const void *, int, TCPDPROC, void *))tcadbputproc;
|
195
|
+
skel->foreach = (bool (*)(void *, TCITER, void *))tcadbforeach;
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
/* mapping function */
|
200
|
+
static bool mapbdbproc(void *map, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
201
|
+
void *op){
|
202
|
+
bool err = false;
|
203
|
+
if(!tcadbmapbdbemit(map, kbuf, ksiz, vbuf, vsiz)) err = true;
|
204
|
+
return !err;
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
/* parse arguments of create command */
|
209
|
+
static int runcreate(int argc, char **argv){
|
210
|
+
char *name = NULL;
|
211
|
+
for(int i = 2; i < argc; i++){
|
212
|
+
if(!name && argv[i][0] == '-'){
|
213
|
+
usage();
|
214
|
+
} else if(!name){
|
215
|
+
name = argv[i];
|
216
|
+
} else {
|
217
|
+
usage();
|
218
|
+
}
|
219
|
+
}
|
220
|
+
if(!name) usage();
|
221
|
+
int rv = proccreate(name);
|
222
|
+
return rv;
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
/* parse arguments of inform command */
|
227
|
+
static int runinform(int argc, char **argv){
|
228
|
+
char *name = NULL;
|
229
|
+
for(int i = 2; i < argc; i++){
|
230
|
+
if(!name && argv[i][0] == '-'){
|
231
|
+
usage();
|
232
|
+
} else if(!name){
|
233
|
+
name = argv[i];
|
234
|
+
} else {
|
235
|
+
usage();
|
236
|
+
}
|
237
|
+
}
|
238
|
+
if(!name) usage();
|
239
|
+
name = tcsprintf("%s#mode=r", name);
|
240
|
+
int rv = procinform(name);
|
241
|
+
tcfree(name);
|
242
|
+
return rv;
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
/* parse arguments of put command */
|
247
|
+
static int runput(int argc, char **argv){
|
248
|
+
char *name = NULL;
|
249
|
+
char *key = NULL;
|
250
|
+
char *value = NULL;
|
251
|
+
int dmode = 0;
|
252
|
+
bool sx = false;
|
253
|
+
int sep = -1;
|
254
|
+
for(int i = 2; i < argc; i++){
|
255
|
+
if(!name && argv[i][0] == '-'){
|
256
|
+
if(!strcmp(argv[i], "-dk")){
|
257
|
+
dmode = -1;
|
258
|
+
} else if(!strcmp(argv[i], "-dc")){
|
259
|
+
dmode = 1;
|
260
|
+
} else if(!strcmp(argv[i], "-dai")){
|
261
|
+
dmode = 10;
|
262
|
+
} else if(!strcmp(argv[i], "-dad")){
|
263
|
+
dmode = 11;
|
264
|
+
} else if(!strcmp(argv[i], "-sx")){
|
265
|
+
sx = true;
|
266
|
+
} else if(!strcmp(argv[i], "-sep")){
|
267
|
+
if(++i >= argc) usage();
|
268
|
+
sep = sepstrtochr(argv[i]);
|
269
|
+
} else {
|
270
|
+
usage();
|
271
|
+
}
|
272
|
+
} else if(!name){
|
273
|
+
name = argv[i];
|
274
|
+
} else if(!key){
|
275
|
+
key = argv[i];
|
276
|
+
} else if(!value){
|
277
|
+
value = argv[i];
|
278
|
+
} else {
|
279
|
+
usage();
|
280
|
+
}
|
281
|
+
}
|
282
|
+
if(!name || !key || !value) usage();
|
283
|
+
char *kbuf, *vbuf;
|
284
|
+
int ksiz, vsiz;
|
285
|
+
if(sx){
|
286
|
+
kbuf = tchexdecode(key, &ksiz);
|
287
|
+
vbuf = tchexdecode(value, &vsiz);
|
288
|
+
} else if(sep > 0){
|
289
|
+
kbuf = strtozsv(key, sep, &ksiz);
|
290
|
+
vbuf = strtozsv(value, sep, &vsiz);
|
291
|
+
} else {
|
292
|
+
ksiz = strlen(key);
|
293
|
+
kbuf = tcmemdup(key, ksiz);
|
294
|
+
vsiz = strlen(value);
|
295
|
+
vbuf = tcmemdup(value, vsiz);
|
296
|
+
}
|
297
|
+
int rv = procput(name, kbuf, ksiz, vbuf, vsiz, dmode);
|
298
|
+
tcfree(vbuf);
|
299
|
+
tcfree(kbuf);
|
300
|
+
return rv;
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
/* parse arguments of out command */
|
305
|
+
static int runout(int argc, char **argv){
|
306
|
+
char *name = NULL;
|
307
|
+
char *key = NULL;
|
308
|
+
bool sx = false;
|
309
|
+
int sep = -1;
|
310
|
+
for(int i = 2; i < argc; i++){
|
311
|
+
if(!name && argv[i][0] == '-'){
|
312
|
+
if(!strcmp(argv[i], "-sx")){
|
313
|
+
sx = true;
|
314
|
+
} else if(!strcmp(argv[i], "-sep")){
|
315
|
+
if(++i >= argc) usage();
|
316
|
+
sep = sepstrtochr(argv[i]);
|
317
|
+
} else {
|
318
|
+
usage();
|
319
|
+
}
|
320
|
+
} else if(!name){
|
321
|
+
name = argv[i];
|
322
|
+
} else if(!key){
|
323
|
+
key = argv[i];
|
324
|
+
} else {
|
325
|
+
usage();
|
326
|
+
}
|
327
|
+
}
|
328
|
+
if(!name || !key) usage();
|
329
|
+
int ksiz;
|
330
|
+
char *kbuf;
|
331
|
+
if(sx){
|
332
|
+
kbuf = tchexdecode(key, &ksiz);
|
333
|
+
} else if(sep > 0){
|
334
|
+
kbuf = strtozsv(key, sep, &ksiz);
|
335
|
+
} else {
|
336
|
+
ksiz = strlen(key);
|
337
|
+
kbuf = tcmemdup(key, ksiz);
|
338
|
+
}
|
339
|
+
int rv = procout(name, kbuf, ksiz);
|
340
|
+
tcfree(kbuf);
|
341
|
+
return rv;
|
342
|
+
}
|
343
|
+
|
344
|
+
|
345
|
+
/* parse arguments of get command */
|
346
|
+
static int runget(int argc, char **argv){
|
347
|
+
char *name = NULL;
|
348
|
+
char *key = NULL;
|
349
|
+
bool sx = false;
|
350
|
+
int sep = -1;
|
351
|
+
bool px = false;
|
352
|
+
bool pz = false;
|
353
|
+
for(int i = 2; i < argc; i++){
|
354
|
+
if(!name && argv[i][0] == '-'){
|
355
|
+
if(!strcmp(argv[i], "-sx")){
|
356
|
+
sx = true;
|
357
|
+
} else if(!strcmp(argv[i], "-sep")){
|
358
|
+
if(++i >= argc) usage();
|
359
|
+
sep = sepstrtochr(argv[i]);
|
360
|
+
} else if(!strcmp(argv[i], "-px")){
|
361
|
+
px = true;
|
362
|
+
} else if(!strcmp(argv[i], "-pz")){
|
363
|
+
pz = true;
|
364
|
+
} else {
|
365
|
+
usage();
|
366
|
+
}
|
367
|
+
} else if(!name){
|
368
|
+
name = argv[i];
|
369
|
+
} else if(!key){
|
370
|
+
key = argv[i];
|
371
|
+
} else {
|
372
|
+
usage();
|
373
|
+
}
|
374
|
+
}
|
375
|
+
if(!name || !key) usage();
|
376
|
+
int ksiz;
|
377
|
+
char *kbuf;
|
378
|
+
if(sx){
|
379
|
+
kbuf = tchexdecode(key, &ksiz);
|
380
|
+
} else if(sep > 0){
|
381
|
+
kbuf = strtozsv(key, sep, &ksiz);
|
382
|
+
} else {
|
383
|
+
ksiz = strlen(key);
|
384
|
+
kbuf = tcmemdup(key, ksiz);
|
385
|
+
}
|
386
|
+
name = tcsprintf("%s#mode=r", name);
|
387
|
+
int rv = procget(name, kbuf, ksiz, sep, px, pz);
|
388
|
+
tcfree(name);
|
389
|
+
tcfree(kbuf);
|
390
|
+
return rv;
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
/* parse arguments of list command */
|
395
|
+
static int runlist(int argc, char **argv){
|
396
|
+
char *name = NULL;
|
397
|
+
int sep = -1;
|
398
|
+
int max = -1;
|
399
|
+
bool pv = false;
|
400
|
+
bool px = false;
|
401
|
+
char *fmstr = NULL;
|
402
|
+
for(int i = 2; i < argc; i++){
|
403
|
+
if(!name && argv[i][0] == '-'){
|
404
|
+
if(!strcmp(argv[i], "-sep")){
|
405
|
+
if(++i >= argc) usage();
|
406
|
+
sep = sepstrtochr(argv[i]);
|
407
|
+
} else if(!strcmp(argv[i], "-m")){
|
408
|
+
if(++i >= argc) usage();
|
409
|
+
max = tcatoix(argv[i]);
|
410
|
+
} else if(!strcmp(argv[i], "-pv")){
|
411
|
+
pv = true;
|
412
|
+
} else if(!strcmp(argv[i], "-px")){
|
413
|
+
px = true;
|
414
|
+
} else if(!strcmp(argv[i], "-fm")){
|
415
|
+
if(++i >= argc) usage();
|
416
|
+
fmstr = argv[i];
|
417
|
+
} else {
|
418
|
+
usage();
|
419
|
+
}
|
420
|
+
} else if(!name){
|
421
|
+
name = argv[i];
|
422
|
+
} else {
|
423
|
+
usage();
|
424
|
+
}
|
425
|
+
}
|
426
|
+
if(!name) usage();
|
427
|
+
name = tcsprintf("%s#mode=r", name);
|
428
|
+
int rv = proclist(name, sep, max, pv, px, fmstr);
|
429
|
+
tcfree(name);
|
430
|
+
return rv;
|
431
|
+
}
|
432
|
+
|
433
|
+
|
434
|
+
/* parse arguments of optimize command */
|
435
|
+
static int runoptimize(int argc, char **argv){
|
436
|
+
char *name = NULL;
|
437
|
+
char *params = NULL;
|
438
|
+
for(int i = 2; i < argc; i++){
|
439
|
+
if(!name && argv[i][0] == '-'){
|
440
|
+
usage();
|
441
|
+
} else if(!name){
|
442
|
+
name = argv[i];
|
443
|
+
} else if(!params){
|
444
|
+
params = argv[i];
|
445
|
+
} else {
|
446
|
+
usage();
|
447
|
+
}
|
448
|
+
}
|
449
|
+
if(!name) usage();
|
450
|
+
int rv = procoptimize(name, params);
|
451
|
+
return rv;
|
452
|
+
}
|
453
|
+
|
454
|
+
|
455
|
+
/* parse arguments of misc command */
|
456
|
+
static int runmisc(int argc, char **argv){
|
457
|
+
char *name = NULL;
|
458
|
+
char *func = NULL;
|
459
|
+
TCLIST *args = tcmpoollistnew(tcmpoolglobal());
|
460
|
+
bool sx = false;
|
461
|
+
int sep = -1;
|
462
|
+
bool px = false;
|
463
|
+
for(int i = 2; i < argc; i++){
|
464
|
+
if(!name && argv[i][0] == '-'){
|
465
|
+
if(!strcmp(argv[i], "-sx")){
|
466
|
+
sx = true;
|
467
|
+
} else if(!strcmp(argv[i], "-sep")){
|
468
|
+
if(++i >= argc) usage();
|
469
|
+
sep = sepstrtochr(argv[i]);
|
470
|
+
} else if(!strcmp(argv[i], "-px")){
|
471
|
+
px = true;
|
472
|
+
} else {
|
473
|
+
usage();
|
474
|
+
}
|
475
|
+
} else if(!name){
|
476
|
+
name = argv[i];
|
477
|
+
} else if(!func){
|
478
|
+
func = argv[i];
|
479
|
+
} else {
|
480
|
+
if(sx){
|
481
|
+
int size;
|
482
|
+
char *buf = tchexdecode(argv[i], &size);
|
483
|
+
tclistpush(args, buf, size);
|
484
|
+
tcfree(buf);
|
485
|
+
} else if(sep > 0){
|
486
|
+
int size;
|
487
|
+
char *buf = strtozsv(argv[i], sep, &size);
|
488
|
+
tclistpush(args, buf, size);
|
489
|
+
tcfree(buf);
|
490
|
+
} else {
|
491
|
+
tclistpush2(args, argv[i]);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
}
|
495
|
+
if(!name || !func) usage();
|
496
|
+
int rv = procmisc(name, func, args, sep, px);
|
497
|
+
return rv;
|
498
|
+
}
|
499
|
+
|
500
|
+
|
501
|
+
/* parse arguments of map command */
|
502
|
+
static int runmap(int argc, char **argv){
|
503
|
+
char *name = NULL;
|
504
|
+
char *dest = NULL;
|
505
|
+
char *fmstr = NULL;
|
506
|
+
for(int i = 2; i < argc; i++){
|
507
|
+
if(!name && argv[i][0] == '-'){
|
508
|
+
if(!strcmp(argv[i], "-fm")){
|
509
|
+
if(++i >= argc) usage();
|
510
|
+
fmstr = argv[i];
|
511
|
+
} else {
|
512
|
+
usage();
|
513
|
+
}
|
514
|
+
} else if(!name){
|
515
|
+
name = argv[i];
|
516
|
+
} else if(!dest){
|
517
|
+
dest = argv[i];
|
518
|
+
} else {
|
519
|
+
usage();
|
520
|
+
}
|
521
|
+
}
|
522
|
+
if(!name || !dest) usage();
|
523
|
+
name = tcsprintf("%s#mode=r", name);
|
524
|
+
int rv = procmap(name, dest, fmstr);
|
525
|
+
tcfree(name);
|
526
|
+
return rv;
|
527
|
+
}
|
528
|
+
|
529
|
+
|
530
|
+
/* parse arguments of version command */
|
531
|
+
static int runversion(int argc, char **argv){
|
532
|
+
int rv = procversion();
|
533
|
+
return rv;
|
534
|
+
}
|
535
|
+
|
536
|
+
|
537
|
+
/* perform create command */
|
538
|
+
static int proccreate(const char *name){
|
539
|
+
TCADB *adb = tcadbnew();
|
540
|
+
ADBSKEL skel;
|
541
|
+
if(*name == '@'){
|
542
|
+
setskeltran(&skel);
|
543
|
+
if(!tcadbsetskel(adb, &skel)){
|
544
|
+
printerr(adb);
|
545
|
+
skel.del(skel.opq);
|
546
|
+
tcadbdel(adb);
|
547
|
+
return 1;
|
548
|
+
}
|
549
|
+
name++;
|
550
|
+
} else if(*name == '%'){
|
551
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
552
|
+
printerr(adb);
|
553
|
+
tcadbdel(adb);
|
554
|
+
return 1;
|
555
|
+
}
|
556
|
+
name++;
|
557
|
+
}
|
558
|
+
if(!tcadbopen(adb, name)){
|
559
|
+
printerr(adb);
|
560
|
+
tcadbdel(adb);
|
561
|
+
return 1;
|
562
|
+
}
|
563
|
+
bool err = false;
|
564
|
+
if(!tcadbclose(adb)){
|
565
|
+
printerr(adb);
|
566
|
+
err = true;
|
567
|
+
}
|
568
|
+
tcadbdel(adb);
|
569
|
+
return err ? 1 : 0;
|
570
|
+
}
|
571
|
+
|
572
|
+
|
573
|
+
/* perform inform command */
|
574
|
+
static int procinform(const char *name){
|
575
|
+
TCADB *adb = tcadbnew();
|
576
|
+
ADBSKEL skel;
|
577
|
+
if(*name == '@'){
|
578
|
+
setskeltran(&skel);
|
579
|
+
if(!tcadbsetskel(adb, &skel)){
|
580
|
+
printerr(adb);
|
581
|
+
skel.del(skel.opq);
|
582
|
+
tcadbdel(adb);
|
583
|
+
return 1;
|
584
|
+
}
|
585
|
+
name++;
|
586
|
+
} else if(*name == '%'){
|
587
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
588
|
+
printerr(adb);
|
589
|
+
tcadbdel(adb);
|
590
|
+
return 1;
|
591
|
+
}
|
592
|
+
name++;
|
593
|
+
}
|
594
|
+
if(!tcadbopen(adb, name)){
|
595
|
+
printerr(adb);
|
596
|
+
tcadbdel(adb);
|
597
|
+
return 1;
|
598
|
+
}
|
599
|
+
bool err = false;
|
600
|
+
const char *path = tcadbpath(adb);
|
601
|
+
if(!path) path = "(unknown)";
|
602
|
+
printf("path: %s\n", path);
|
603
|
+
const char *type = "(unknown)";
|
604
|
+
switch(tcadbomode(adb)){
|
605
|
+
case ADBOVOID: type = "not opened"; break;
|
606
|
+
case ADBOMDB: type = "on-memory hash database"; break;
|
607
|
+
case ADBONDB: type = "on-memory tree database"; break;
|
608
|
+
case ADBOHDB: type = "hash database"; break;
|
609
|
+
case ADBOBDB: type = "B+ tree database"; break;
|
610
|
+
case ADBOFDB: type = "fixed-length database"; break;
|
611
|
+
case ADBOTDB: type = "table database"; break;
|
612
|
+
case ADBOSKEL: type = "skeleton database"; break;
|
613
|
+
}
|
614
|
+
printf("database type: %s\n", type);
|
615
|
+
printf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
|
616
|
+
printf("size: %llu\n", (unsigned long long)tcadbsize(adb));
|
617
|
+
if(!tcadbclose(adb)){
|
618
|
+
printerr(adb);
|
619
|
+
err = true;
|
620
|
+
}
|
621
|
+
tcadbdel(adb);
|
622
|
+
return err ? 1 : 0;
|
623
|
+
}
|
624
|
+
|
625
|
+
|
626
|
+
/* perform put command */
|
627
|
+
static int procput(const char *name, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
628
|
+
int dmode){
|
629
|
+
TCADB *adb = tcadbnew();
|
630
|
+
ADBSKEL skel;
|
631
|
+
if(*name == '@'){
|
632
|
+
setskeltran(&skel);
|
633
|
+
if(!tcadbsetskel(adb, &skel)){
|
634
|
+
printerr(adb);
|
635
|
+
skel.del(skel.opq);
|
636
|
+
tcadbdel(adb);
|
637
|
+
return 1;
|
638
|
+
}
|
639
|
+
name++;
|
640
|
+
} else if(*name == '%'){
|
641
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
642
|
+
printerr(adb);
|
643
|
+
tcadbdel(adb);
|
644
|
+
return 1;
|
645
|
+
}
|
646
|
+
name++;
|
647
|
+
}
|
648
|
+
if(!tcadbopen(adb, name)){
|
649
|
+
printerr(adb);
|
650
|
+
tcadbdel(adb);
|
651
|
+
return 1;
|
652
|
+
}
|
653
|
+
bool err = false;
|
654
|
+
switch(dmode){
|
655
|
+
case -1:
|
656
|
+
if(!tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz)){
|
657
|
+
printerr(adb);
|
658
|
+
err = true;
|
659
|
+
}
|
660
|
+
break;
|
661
|
+
case 1:
|
662
|
+
if(!tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz)){
|
663
|
+
printerr(adb);
|
664
|
+
err = true;
|
665
|
+
}
|
666
|
+
break;
|
667
|
+
case 10:
|
668
|
+
if(tcadbaddint(adb, kbuf, ksiz, tcatoi(vbuf)) == INT_MIN){
|
669
|
+
printerr(adb);
|
670
|
+
err = true;
|
671
|
+
}
|
672
|
+
break;
|
673
|
+
case 11:
|
674
|
+
if(isnan(tcadbadddouble(adb, kbuf, ksiz, tcatof(vbuf)))){
|
675
|
+
printerr(adb);
|
676
|
+
err = true;
|
677
|
+
}
|
678
|
+
break;
|
679
|
+
default:
|
680
|
+
if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
|
681
|
+
printerr(adb);
|
682
|
+
err = true;
|
683
|
+
}
|
684
|
+
break;
|
685
|
+
}
|
686
|
+
if(!tcadbclose(adb)){
|
687
|
+
if(!err) printerr(adb);
|
688
|
+
err = true;
|
689
|
+
}
|
690
|
+
tcadbdel(adb);
|
691
|
+
return err ? 1 : 0;
|
692
|
+
}
|
693
|
+
|
694
|
+
|
695
|
+
/* perform out command */
|
696
|
+
static int procout(const char *name, const char *kbuf, int ksiz){
|
697
|
+
TCADB *adb = tcadbnew();
|
698
|
+
ADBSKEL skel;
|
699
|
+
if(*name == '@'){
|
700
|
+
setskeltran(&skel);
|
701
|
+
if(!tcadbsetskel(adb, &skel)){
|
702
|
+
printerr(adb);
|
703
|
+
skel.del(skel.opq);
|
704
|
+
tcadbdel(adb);
|
705
|
+
return 1;
|
706
|
+
}
|
707
|
+
name++;
|
708
|
+
} else if(*name == '%'){
|
709
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
710
|
+
printerr(adb);
|
711
|
+
tcadbdel(adb);
|
712
|
+
return 1;
|
713
|
+
}
|
714
|
+
name++;
|
715
|
+
}
|
716
|
+
if(!tcadbopen(adb, name)){
|
717
|
+
printerr(adb);
|
718
|
+
tcadbdel(adb);
|
719
|
+
return 1;
|
720
|
+
}
|
721
|
+
bool err = false;
|
722
|
+
if(!tcadbout(adb, kbuf, ksiz)){
|
723
|
+
printerr(adb);
|
724
|
+
err = true;
|
725
|
+
}
|
726
|
+
if(!tcadbclose(adb)){
|
727
|
+
if(!err) printerr(adb);
|
728
|
+
err = true;
|
729
|
+
}
|
730
|
+
tcadbdel(adb);
|
731
|
+
return err ? 1 : 0;
|
732
|
+
}
|
733
|
+
|
734
|
+
|
735
|
+
/* perform get command */
|
736
|
+
static int procget(const char *name, const char *kbuf, int ksiz, int sep, bool px, bool pz){
|
737
|
+
TCADB *adb = tcadbnew();
|
738
|
+
ADBSKEL skel;
|
739
|
+
if(*name == '@'){
|
740
|
+
setskeltran(&skel);
|
741
|
+
if(!tcadbsetskel(adb, &skel)){
|
742
|
+
printerr(adb);
|
743
|
+
skel.del(skel.opq);
|
744
|
+
tcadbdel(adb);
|
745
|
+
return 1;
|
746
|
+
}
|
747
|
+
name++;
|
748
|
+
} else if(*name == '%'){
|
749
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
750
|
+
printerr(adb);
|
751
|
+
tcadbdel(adb);
|
752
|
+
return 1;
|
753
|
+
}
|
754
|
+
name++;
|
755
|
+
}
|
756
|
+
if(!tcadbopen(adb, name)){
|
757
|
+
printerr(adb);
|
758
|
+
tcadbdel(adb);
|
759
|
+
return 1;
|
760
|
+
}
|
761
|
+
bool err = false;
|
762
|
+
int vsiz;
|
763
|
+
char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
|
764
|
+
if(vbuf){
|
765
|
+
printdata(vbuf, vsiz, px, sep);
|
766
|
+
if(!pz) putchar('\n');
|
767
|
+
tcfree(vbuf);
|
768
|
+
} else {
|
769
|
+
printerr(adb);
|
770
|
+
err = true;
|
771
|
+
}
|
772
|
+
if(!tcadbclose(adb)){
|
773
|
+
if(!err) printerr(adb);
|
774
|
+
err = true;
|
775
|
+
}
|
776
|
+
tcadbdel(adb);
|
777
|
+
return err ? 1 : 0;
|
778
|
+
}
|
779
|
+
|
780
|
+
|
781
|
+
/* perform list command */
|
782
|
+
static int proclist(const char *name, int sep, int max, bool pv, bool px, const char *fmstr){
|
783
|
+
TCADB *adb = tcadbnew();
|
784
|
+
ADBSKEL skel;
|
785
|
+
if(*name == '@'){
|
786
|
+
setskeltran(&skel);
|
787
|
+
if(!tcadbsetskel(adb, &skel)){
|
788
|
+
printerr(adb);
|
789
|
+
skel.del(skel.opq);
|
790
|
+
tcadbdel(adb);
|
791
|
+
return 1;
|
792
|
+
}
|
793
|
+
name++;
|
794
|
+
} else if(*name == '%'){
|
795
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
796
|
+
printerr(adb);
|
797
|
+
tcadbdel(adb);
|
798
|
+
return 1;
|
799
|
+
}
|
800
|
+
name++;
|
801
|
+
}
|
802
|
+
if(!tcadbopen(adb, name)){
|
803
|
+
printerr(adb);
|
804
|
+
tcadbdel(adb);
|
805
|
+
return 1;
|
806
|
+
}
|
807
|
+
bool err = false;
|
808
|
+
if(fmstr){
|
809
|
+
TCLIST *keys = tcadbfwmkeys2(adb, fmstr, max);
|
810
|
+
for(int i = 0; i < tclistnum(keys); i++){
|
811
|
+
int ksiz;
|
812
|
+
const char *kbuf = tclistval(keys, i, &ksiz);
|
813
|
+
printdata(kbuf, ksiz, px, sep);
|
814
|
+
if(pv){
|
815
|
+
int vsiz;
|
816
|
+
char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
|
817
|
+
if(vbuf){
|
818
|
+
putchar('\t');
|
819
|
+
printdata(vbuf, vsiz, px, sep);
|
820
|
+
tcfree(vbuf);
|
821
|
+
}
|
822
|
+
}
|
823
|
+
putchar('\n');
|
824
|
+
}
|
825
|
+
tclistdel(keys);
|
826
|
+
} else {
|
827
|
+
if(!tcadbiterinit(adb)){
|
828
|
+
printerr(adb);
|
829
|
+
err = true;
|
830
|
+
}
|
831
|
+
int ksiz;
|
832
|
+
char *kbuf;
|
833
|
+
int cnt = 0;
|
834
|
+
while((kbuf = tcadbiternext(adb, &ksiz)) != NULL){
|
835
|
+
printdata(kbuf, ksiz, px, sep);
|
836
|
+
if(pv){
|
837
|
+
int vsiz;
|
838
|
+
char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
|
839
|
+
if(vbuf){
|
840
|
+
putchar('\t');
|
841
|
+
printdata(vbuf, vsiz, px, sep);
|
842
|
+
tcfree(vbuf);
|
843
|
+
}
|
844
|
+
}
|
845
|
+
putchar('\n');
|
846
|
+
tcfree(kbuf);
|
847
|
+
if(max >= 0 && ++cnt >= max) break;
|
848
|
+
}
|
849
|
+
}
|
850
|
+
if(!tcadbclose(adb)){
|
851
|
+
if(!err) printerr(adb);
|
852
|
+
err = true;
|
853
|
+
}
|
854
|
+
tcadbdel(adb);
|
855
|
+
return err ? 1 : 0;
|
856
|
+
}
|
857
|
+
|
858
|
+
|
859
|
+
/* perform optimize command */
|
860
|
+
static int procoptimize(const char *name, const char *params){
|
861
|
+
TCADB *adb = tcadbnew();
|
862
|
+
ADBSKEL skel;
|
863
|
+
if(*name == '@'){
|
864
|
+
setskeltran(&skel);
|
865
|
+
if(!tcadbsetskel(adb, &skel)){
|
866
|
+
printerr(adb);
|
867
|
+
skel.del(skel.opq);
|
868
|
+
tcadbdel(adb);
|
869
|
+
return 1;
|
870
|
+
}
|
871
|
+
name++;
|
872
|
+
} else if(*name == '%'){
|
873
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
874
|
+
printerr(adb);
|
875
|
+
tcadbdel(adb);
|
876
|
+
return 1;
|
877
|
+
}
|
878
|
+
name++;
|
879
|
+
}
|
880
|
+
if(!tcadbopen(adb, name)){
|
881
|
+
printerr(adb);
|
882
|
+
tcadbdel(adb);
|
883
|
+
return 1;
|
884
|
+
}
|
885
|
+
bool err = false;
|
886
|
+
if(!tcadboptimize(adb, params)){
|
887
|
+
printerr(adb);
|
888
|
+
err = true;
|
889
|
+
}
|
890
|
+
if(!tcadbclose(adb)){
|
891
|
+
if(!err) printerr(adb);
|
892
|
+
err = true;
|
893
|
+
}
|
894
|
+
tcadbdel(adb);
|
895
|
+
return err ? 1 : 0;
|
896
|
+
}
|
897
|
+
|
898
|
+
|
899
|
+
/* perform misc command */
|
900
|
+
static int procmisc(const char *name, const char *func, const TCLIST *args, int sep, bool px){
|
901
|
+
TCADB *adb = tcadbnew();
|
902
|
+
ADBSKEL skel;
|
903
|
+
if(*name == '@'){
|
904
|
+
setskeltran(&skel);
|
905
|
+
if(!tcadbsetskel(adb, &skel)){
|
906
|
+
printerr(adb);
|
907
|
+
skel.del(skel.opq);
|
908
|
+
tcadbdel(adb);
|
909
|
+
return 1;
|
910
|
+
}
|
911
|
+
name++;
|
912
|
+
} else if(*name == '%'){
|
913
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
914
|
+
printerr(adb);
|
915
|
+
tcadbdel(adb);
|
916
|
+
return 1;
|
917
|
+
}
|
918
|
+
name++;
|
919
|
+
}
|
920
|
+
if(!tcadbopen(adb, name)){
|
921
|
+
printerr(adb);
|
922
|
+
tcadbdel(adb);
|
923
|
+
return 1;
|
924
|
+
}
|
925
|
+
bool err = false;
|
926
|
+
TCLIST *res = tcadbmisc(adb, func, args);
|
927
|
+
if(res){
|
928
|
+
for(int i = 0; i < tclistnum(res); i++){
|
929
|
+
int rsiz;
|
930
|
+
const char *rbuf = tclistval(res, i, &rsiz);
|
931
|
+
printdata(rbuf, rsiz, px, sep);
|
932
|
+
printf("\n");
|
933
|
+
}
|
934
|
+
tclistdel(res);
|
935
|
+
} else {
|
936
|
+
printerr(adb);
|
937
|
+
err = true;
|
938
|
+
}
|
939
|
+
if(!tcadbclose(adb)){
|
940
|
+
if(!err) printerr(adb);
|
941
|
+
err = true;
|
942
|
+
}
|
943
|
+
tcadbdel(adb);
|
944
|
+
return err ? 1 : 0;
|
945
|
+
}
|
946
|
+
|
947
|
+
|
948
|
+
/* perform map command */
|
949
|
+
static int procmap(const char *name, const char *dest, const char *fmstr){
|
950
|
+
TCADB *adb = tcadbnew();
|
951
|
+
ADBSKEL skel;
|
952
|
+
if(*name == '@'){
|
953
|
+
setskeltran(&skel);
|
954
|
+
if(!tcadbsetskel(adb, &skel)){
|
955
|
+
printerr(adb);
|
956
|
+
skel.del(skel.opq);
|
957
|
+
tcadbdel(adb);
|
958
|
+
return 1;
|
959
|
+
}
|
960
|
+
name++;
|
961
|
+
} else if(*name == '%'){
|
962
|
+
if(!tcadbsetskelmulti(adb, 8)){
|
963
|
+
printerr(adb);
|
964
|
+
tcadbdel(adb);
|
965
|
+
return 1;
|
966
|
+
}
|
967
|
+
name++;
|
968
|
+
}
|
969
|
+
if(!tcadbopen(adb, name)){
|
970
|
+
printerr(adb);
|
971
|
+
tcadbdel(adb);
|
972
|
+
return 1;
|
973
|
+
}
|
974
|
+
bool err = false;
|
975
|
+
TCBDB *bdb = tcbdbnew();
|
976
|
+
if(!tcbdbopen(bdb, dest, BDBOWRITER | BDBOCREAT | BDBOTRUNC)){
|
977
|
+
printerr(adb);
|
978
|
+
tcbdbdel(bdb);
|
979
|
+
tcadbdel(adb);
|
980
|
+
return 1;
|
981
|
+
}
|
982
|
+
if(fmstr){
|
983
|
+
TCLIST *keys = tcadbfwmkeys2(adb, fmstr, -1);
|
984
|
+
if(!tcadbmapbdb(adb, keys, bdb, mapbdbproc, NULL, -1)){
|
985
|
+
printerr(adb);
|
986
|
+
err = true;
|
987
|
+
}
|
988
|
+
tclistdel(keys);
|
989
|
+
} else {
|
990
|
+
if(!tcadbmapbdb(adb, NULL, bdb, mapbdbproc, NULL, -1)){
|
991
|
+
printerr(adb);
|
992
|
+
err = true;
|
993
|
+
}
|
994
|
+
}
|
995
|
+
if(!tcbdbclose(bdb)){
|
996
|
+
printerr(adb);
|
997
|
+
err = true;
|
998
|
+
}
|
999
|
+
tcbdbdel(bdb);
|
1000
|
+
if(!tcadbclose(adb)){
|
1001
|
+
printerr(adb);
|
1002
|
+
err = true;
|
1003
|
+
}
|
1004
|
+
tcadbdel(adb);
|
1005
|
+
return err ? 1 : 0;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
|
1009
|
+
/* perform version command */
|
1010
|
+
static int procversion(void){
|
1011
|
+
printf("Tokyo Cabinet version %s (%d:%s) for %s\n",
|
1012
|
+
tcversion, _TC_LIBVER, _TC_FORMATVER, TCSYSNAME);
|
1013
|
+
printf("Copyright (C) 2006-2009 Mikio Hirabayashi\n");
|
1014
|
+
return 0;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
|
1018
|
+
|
1019
|
+
// END OF FILE
|