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,842 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* The command line utility 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
|
+
|
22
|
+
/* global variables */
|
23
|
+
const char *g_progname; // program name
|
24
|
+
int g_dbgfd; // debugging output
|
25
|
+
|
26
|
+
|
27
|
+
/* function prototypes */
|
28
|
+
int main(int argc, char **argv);
|
29
|
+
static void usage(void);
|
30
|
+
static void printerr(TCHDB *hdb);
|
31
|
+
static int printdata(const char *ptr, int size, bool px);
|
32
|
+
static char *mygetline(FILE *ifp);
|
33
|
+
static int runcreate(int argc, char **argv);
|
34
|
+
static int runinform(int argc, char **argv);
|
35
|
+
static int runput(int argc, char **argv);
|
36
|
+
static int runout(int argc, char **argv);
|
37
|
+
static int runget(int argc, char **argv);
|
38
|
+
static int runlist(int argc, char **argv);
|
39
|
+
static int runoptimize(int argc, char **argv);
|
40
|
+
static int runimporttsv(int argc, char **argv);
|
41
|
+
static int runversion(int argc, char **argv);
|
42
|
+
static int proccreate(const char *path, int bnum, int apow, int fpow, int opts);
|
43
|
+
static int procinform(const char *path, int omode);
|
44
|
+
static int procput(const char *path, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
45
|
+
int omode, int dmode);
|
46
|
+
static int procout(const char *path, const char *kbuf, int ksiz, int omode);
|
47
|
+
static int procget(const char *path, const char *kbuf, int ksiz, int omode, bool px, bool pz);
|
48
|
+
static int proclist(const char *path, int omode, int max, bool pv, bool px, const char *fmstr);
|
49
|
+
static int procoptimize(const char *path, int bnum, int apow, int fpow, int opts, int omode,
|
50
|
+
bool df);
|
51
|
+
static int procimporttsv(const char *path, const char *file, int omode, bool sc);
|
52
|
+
static int procversion(void);
|
53
|
+
|
54
|
+
|
55
|
+
/* main routine */
|
56
|
+
int main(int argc, char **argv){
|
57
|
+
g_progname = argv[0];
|
58
|
+
g_dbgfd = -1;
|
59
|
+
const char *ebuf = getenv("TCDBGFD");
|
60
|
+
if(ebuf) g_dbgfd = tcatoix(ebuf);
|
61
|
+
if(argc < 2) usage();
|
62
|
+
int rv = 0;
|
63
|
+
if(!strcmp(argv[1], "create")){
|
64
|
+
rv = runcreate(argc, argv);
|
65
|
+
} else if(!strcmp(argv[1], "inform")){
|
66
|
+
rv = runinform(argc, argv);
|
67
|
+
} else if(!strcmp(argv[1], "put")){
|
68
|
+
rv = runput(argc, argv);
|
69
|
+
} else if(!strcmp(argv[1], "out")){
|
70
|
+
rv = runout(argc, argv);
|
71
|
+
} else if(!strcmp(argv[1], "get")){
|
72
|
+
rv = runget(argc, argv);
|
73
|
+
} else if(!strcmp(argv[1], "list")){
|
74
|
+
rv = runlist(argc, argv);
|
75
|
+
} else if(!strcmp(argv[1], "optimize")){
|
76
|
+
rv = runoptimize(argc, argv);
|
77
|
+
} else if(!strcmp(argv[1], "importtsv")){
|
78
|
+
rv = runimporttsv(argc, argv);
|
79
|
+
} else if(!strcmp(argv[1], "version") || !strcmp(argv[1], "--version")){
|
80
|
+
rv = runversion(argc, argv);
|
81
|
+
} else {
|
82
|
+
usage();
|
83
|
+
}
|
84
|
+
return rv;
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
/* print the usage and exit */
|
89
|
+
static void usage(void){
|
90
|
+
fprintf(stderr, "%s: the command line utility of the hash database API\n", g_progname);
|
91
|
+
fprintf(stderr, "\n");
|
92
|
+
fprintf(stderr, "usage:\n");
|
93
|
+
fprintf(stderr, " %s create [-tl] [-td|-tb|-tt|-tx] path [bnum [apow [fpow]]]\n", g_progname);
|
94
|
+
fprintf(stderr, " %s inform [-nl|-nb] path\n", g_progname);
|
95
|
+
fprintf(stderr, " %s put [-nl|-nb] [-sx] [-dk|-dc|-dai|-dad] path key value\n", g_progname);
|
96
|
+
fprintf(stderr, " %s out [-nl|-nb] [-sx] path key\n", g_progname);
|
97
|
+
fprintf(stderr, " %s get [-nl|-nb] [-sx] [-px] [-pz] path key\n", g_progname);
|
98
|
+
fprintf(stderr, " %s list [-nl|-nb] [-m num] [-pv] [-px] [-fm str] path\n", g_progname);
|
99
|
+
fprintf(stderr, " %s optimize [-tl] [-td|-tb|-tt|-tx] [-tz] [-nl|-nb] [-df]"
|
100
|
+
" path [bnum [apow [fpow]]]\n", g_progname);
|
101
|
+
fprintf(stderr, " %s importtsv [-nl|-nb] [-sc] path [file]\n", g_progname);
|
102
|
+
fprintf(stderr, " %s version\n", g_progname);
|
103
|
+
fprintf(stderr, "\n");
|
104
|
+
exit(1);
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
/* print error information */
|
109
|
+
static void printerr(TCHDB *hdb){
|
110
|
+
const char *path = tchdbpath(hdb);
|
111
|
+
int ecode = tchdbecode(hdb);
|
112
|
+
fprintf(stderr, "%s: %s: %d: %s\n", g_progname, path ? path : "-", ecode, tchdberrmsg(ecode));
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
/* print record data */
|
117
|
+
static int printdata(const char *ptr, int size, bool px){
|
118
|
+
int len = 0;
|
119
|
+
while(size-- > 0){
|
120
|
+
if(px){
|
121
|
+
if(len > 0) putchar(' ');
|
122
|
+
len += printf("%02X", *(unsigned char *)ptr);
|
123
|
+
} else {
|
124
|
+
putchar(*ptr);
|
125
|
+
len++;
|
126
|
+
}
|
127
|
+
ptr++;
|
128
|
+
}
|
129
|
+
return len;
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
/* read a line from a file descriptor */
|
134
|
+
static char *mygetline(FILE *ifp){
|
135
|
+
int len = 0;
|
136
|
+
int blen = 1024;
|
137
|
+
char *buf = tcmalloc(blen);
|
138
|
+
bool end = true;
|
139
|
+
int c;
|
140
|
+
while((c = fgetc(ifp)) != EOF){
|
141
|
+
end = false;
|
142
|
+
if(c == '\0') continue;
|
143
|
+
if(blen <= len){
|
144
|
+
blen *= 2;
|
145
|
+
buf = tcrealloc(buf, blen + 1);
|
146
|
+
}
|
147
|
+
if(c == '\n' || c == '\r') c = '\0';
|
148
|
+
buf[len++] = c;
|
149
|
+
if(c == '\0') break;
|
150
|
+
}
|
151
|
+
if(end){
|
152
|
+
tcfree(buf);
|
153
|
+
return NULL;
|
154
|
+
}
|
155
|
+
buf[len] = '\0';
|
156
|
+
return buf;
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
/* parse arguments of create command */
|
161
|
+
static int runcreate(int argc, char **argv){
|
162
|
+
char *path = NULL;
|
163
|
+
char *bstr = NULL;
|
164
|
+
char *astr = NULL;
|
165
|
+
char *fstr = NULL;
|
166
|
+
int opts = 0;
|
167
|
+
for(int i = 2; i < argc; i++){
|
168
|
+
if(!path && argv[i][0] == '-'){
|
169
|
+
if(!strcmp(argv[i], "-tl")){
|
170
|
+
opts |= HDBTLARGE;
|
171
|
+
} else if(!strcmp(argv[i], "-td")){
|
172
|
+
opts |= HDBTDEFLATE;
|
173
|
+
} else if(!strcmp(argv[i], "-tb")){
|
174
|
+
opts |= HDBTBZIP;
|
175
|
+
} else if(!strcmp(argv[i], "-tt")){
|
176
|
+
opts |= HDBTTCBS;
|
177
|
+
} else if(!strcmp(argv[i], "-tx")){
|
178
|
+
opts |= HDBTEXCODEC;
|
179
|
+
} else {
|
180
|
+
usage();
|
181
|
+
}
|
182
|
+
} else if(!path){
|
183
|
+
path = argv[i];
|
184
|
+
} else if(!bstr){
|
185
|
+
bstr = argv[i];
|
186
|
+
} else if(!astr){
|
187
|
+
astr = argv[i];
|
188
|
+
} else if(!fstr){
|
189
|
+
fstr = argv[i];
|
190
|
+
} else {
|
191
|
+
usage();
|
192
|
+
}
|
193
|
+
}
|
194
|
+
if(!path) usage();
|
195
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
196
|
+
int apow = astr ? tcatoix(astr) : -1;
|
197
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
198
|
+
int rv = proccreate(path, bnum, apow, fpow, opts);
|
199
|
+
return rv;
|
200
|
+
}
|
201
|
+
|
202
|
+
|
203
|
+
/* parse arguments of inform command */
|
204
|
+
static int runinform(int argc, char **argv){
|
205
|
+
char *path = NULL;
|
206
|
+
int omode = 0;
|
207
|
+
for(int i = 2; i < argc; i++){
|
208
|
+
if(!path && argv[i][0] == '-'){
|
209
|
+
if(!strcmp(argv[i], "-nl")){
|
210
|
+
omode |= HDBONOLCK;
|
211
|
+
} else if(!strcmp(argv[i], "-nb")){
|
212
|
+
omode |= HDBOLCKNB;
|
213
|
+
} else {
|
214
|
+
usage();
|
215
|
+
}
|
216
|
+
} else if(!path){
|
217
|
+
path = argv[i];
|
218
|
+
} else {
|
219
|
+
usage();
|
220
|
+
}
|
221
|
+
}
|
222
|
+
if(!path) usage();
|
223
|
+
int rv = procinform(path, omode);
|
224
|
+
return rv;
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
/* parse arguments of put command */
|
229
|
+
static int runput(int argc, char **argv){
|
230
|
+
char *path = NULL;
|
231
|
+
char *key = NULL;
|
232
|
+
char *value = NULL;
|
233
|
+
int omode = 0;
|
234
|
+
int dmode = 0;
|
235
|
+
bool sx = false;
|
236
|
+
for(int i = 2; i < argc; i++){
|
237
|
+
if(!path && argv[i][0] == '-'){
|
238
|
+
if(!strcmp(argv[i], "-nl")){
|
239
|
+
omode |= HDBONOLCK;
|
240
|
+
} else if(!strcmp(argv[i], "-nb")){
|
241
|
+
omode |= HDBOLCKNB;
|
242
|
+
} else if(!strcmp(argv[i], "-dk")){
|
243
|
+
dmode = -1;
|
244
|
+
} else if(!strcmp(argv[i], "-dc")){
|
245
|
+
dmode = 1;
|
246
|
+
} else if(!strcmp(argv[i], "-dai")){
|
247
|
+
dmode = 10;
|
248
|
+
} else if(!strcmp(argv[i], "-dad")){
|
249
|
+
dmode = 11;
|
250
|
+
} else if(!strcmp(argv[i], "-sx")){
|
251
|
+
sx = true;
|
252
|
+
} else {
|
253
|
+
usage();
|
254
|
+
}
|
255
|
+
} else if(!path){
|
256
|
+
path = argv[i];
|
257
|
+
} else if(!key){
|
258
|
+
key = argv[i];
|
259
|
+
} else if(!value){
|
260
|
+
value = argv[i];
|
261
|
+
} else {
|
262
|
+
usage();
|
263
|
+
}
|
264
|
+
}
|
265
|
+
if(!path || !key || !value) usage();
|
266
|
+
char *kbuf, *vbuf;
|
267
|
+
int ksiz, vsiz;
|
268
|
+
if(sx){
|
269
|
+
kbuf = tchexdecode(key, &ksiz);
|
270
|
+
vbuf = tchexdecode(value, &vsiz);
|
271
|
+
} else {
|
272
|
+
ksiz = strlen(key);
|
273
|
+
kbuf = tcmemdup(key, ksiz);
|
274
|
+
vsiz = strlen(value);
|
275
|
+
vbuf = tcmemdup(value, vsiz);
|
276
|
+
}
|
277
|
+
int rv = procput(path, kbuf, ksiz, vbuf, vsiz, omode, dmode);
|
278
|
+
tcfree(vbuf);
|
279
|
+
tcfree(kbuf);
|
280
|
+
return rv;
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
/* parse arguments of out command */
|
285
|
+
static int runout(int argc, char **argv){
|
286
|
+
char *path = NULL;
|
287
|
+
char *key = NULL;
|
288
|
+
int omode = 0;
|
289
|
+
bool sx = false;
|
290
|
+
for(int i = 2; i < argc; i++){
|
291
|
+
if(!path && argv[i][0] == '-'){
|
292
|
+
if(!strcmp(argv[i], "-nl")){
|
293
|
+
omode |= HDBONOLCK;
|
294
|
+
} else if(!strcmp(argv[i], "-nb")){
|
295
|
+
omode |= HDBOLCKNB;
|
296
|
+
} else if(!strcmp(argv[i], "-sx")){
|
297
|
+
sx = true;
|
298
|
+
} else {
|
299
|
+
usage();
|
300
|
+
}
|
301
|
+
} else if(!path){
|
302
|
+
path = argv[i];
|
303
|
+
} else if(!key){
|
304
|
+
key = argv[i];
|
305
|
+
} else {
|
306
|
+
usage();
|
307
|
+
}
|
308
|
+
}
|
309
|
+
if(!path || !key) usage();
|
310
|
+
int ksiz;
|
311
|
+
char *kbuf;
|
312
|
+
if(sx){
|
313
|
+
kbuf = tchexdecode(key, &ksiz);
|
314
|
+
} else {
|
315
|
+
ksiz = strlen(key);
|
316
|
+
kbuf = tcmemdup(key, ksiz);
|
317
|
+
}
|
318
|
+
int rv = procout(path, kbuf, ksiz, omode);
|
319
|
+
tcfree(kbuf);
|
320
|
+
return rv;
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
/* parse arguments of get command */
|
325
|
+
static int runget(int argc, char **argv){
|
326
|
+
char *path = NULL;
|
327
|
+
char *key = NULL;
|
328
|
+
int omode = 0;
|
329
|
+
bool sx = false;
|
330
|
+
bool px = false;
|
331
|
+
bool pz = false;
|
332
|
+
for(int i = 2; i < argc; i++){
|
333
|
+
if(!path && argv[i][0] == '-'){
|
334
|
+
if(!strcmp(argv[i], "-nl")){
|
335
|
+
omode |= HDBONOLCK;
|
336
|
+
} else if(!strcmp(argv[i], "-nb")){
|
337
|
+
omode |= HDBOLCKNB;
|
338
|
+
} else if(!strcmp(argv[i], "-sx")){
|
339
|
+
sx = true;
|
340
|
+
} else if(!strcmp(argv[i], "-px")){
|
341
|
+
px = true;
|
342
|
+
} else if(!strcmp(argv[i], "-pz")){
|
343
|
+
pz = true;
|
344
|
+
} else {
|
345
|
+
usage();
|
346
|
+
}
|
347
|
+
} else if(!path){
|
348
|
+
path = argv[i];
|
349
|
+
} else if(!key){
|
350
|
+
key = argv[i];
|
351
|
+
} else {
|
352
|
+
usage();
|
353
|
+
}
|
354
|
+
}
|
355
|
+
if(!path || !key) usage();
|
356
|
+
int ksiz;
|
357
|
+
char *kbuf;
|
358
|
+
if(sx){
|
359
|
+
kbuf = tchexdecode(key, &ksiz);
|
360
|
+
} else {
|
361
|
+
ksiz = strlen(key);
|
362
|
+
kbuf = tcmemdup(key, ksiz);
|
363
|
+
}
|
364
|
+
int rv = procget(path, kbuf, ksiz, omode, px, pz);
|
365
|
+
tcfree(kbuf);
|
366
|
+
return rv;
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
/* parse arguments of list command */
|
371
|
+
static int runlist(int argc, char **argv){
|
372
|
+
char *path = NULL;
|
373
|
+
int omode = 0;
|
374
|
+
int max = -1;
|
375
|
+
bool pv = false;
|
376
|
+
bool px = false;
|
377
|
+
char *fmstr = NULL;
|
378
|
+
for(int i = 2; i < argc; i++){
|
379
|
+
if(!path && argv[i][0] == '-'){
|
380
|
+
if(!strcmp(argv[i], "-nl")){
|
381
|
+
omode |= HDBONOLCK;
|
382
|
+
} else if(!strcmp(argv[i], "-nb")){
|
383
|
+
omode |= HDBOLCKNB;
|
384
|
+
} else if(!strcmp(argv[i], "-m")){
|
385
|
+
if(++i >= argc) usage();
|
386
|
+
max = tcatoix(argv[i]);
|
387
|
+
} else if(!strcmp(argv[i], "-pv")){
|
388
|
+
pv = true;
|
389
|
+
} else if(!strcmp(argv[i], "-px")){
|
390
|
+
px = true;
|
391
|
+
} else if(!strcmp(argv[i], "-fm")){
|
392
|
+
if(++i >= argc) usage();
|
393
|
+
fmstr = argv[i];
|
394
|
+
} else {
|
395
|
+
usage();
|
396
|
+
}
|
397
|
+
} else if(!path){
|
398
|
+
path = argv[i];
|
399
|
+
} else {
|
400
|
+
usage();
|
401
|
+
}
|
402
|
+
}
|
403
|
+
if(!path) usage();
|
404
|
+
int rv = proclist(path, omode, max, pv, px, fmstr);
|
405
|
+
return rv;
|
406
|
+
}
|
407
|
+
|
408
|
+
|
409
|
+
/* parse arguments of optimize command */
|
410
|
+
static int runoptimize(int argc, char **argv){
|
411
|
+
char *path = NULL;
|
412
|
+
char *bstr = NULL;
|
413
|
+
char *astr = NULL;
|
414
|
+
char *fstr = NULL;
|
415
|
+
int opts = UINT8_MAX;
|
416
|
+
int omode = 0;
|
417
|
+
bool df = false;
|
418
|
+
for(int i = 2; i < argc; i++){
|
419
|
+
if(!path && argv[i][0] == '-'){
|
420
|
+
if(!strcmp(argv[i], "-tl")){
|
421
|
+
if(opts == UINT8_MAX) opts = 0;
|
422
|
+
opts |= HDBTLARGE;
|
423
|
+
} else if(!strcmp(argv[i], "-td")){
|
424
|
+
if(opts == UINT8_MAX) opts = 0;
|
425
|
+
opts |= HDBTDEFLATE;
|
426
|
+
} else if(!strcmp(argv[i], "-tb")){
|
427
|
+
if(opts == UINT8_MAX) opts = 0;
|
428
|
+
opts |= HDBTBZIP;
|
429
|
+
} else if(!strcmp(argv[i], "-tt")){
|
430
|
+
if(opts == UINT8_MAX) opts = 0;
|
431
|
+
opts |= HDBTTCBS;
|
432
|
+
} else if(!strcmp(argv[i], "-tx")){
|
433
|
+
if(opts == UINT8_MAX) opts = 0;
|
434
|
+
opts |= HDBTEXCODEC;
|
435
|
+
} else if(!strcmp(argv[i], "-tz")){
|
436
|
+
if(opts == UINT8_MAX) opts = 0;
|
437
|
+
} else if(!strcmp(argv[i], "-nl")){
|
438
|
+
omode |= HDBONOLCK;
|
439
|
+
} else if(!strcmp(argv[i], "-nb")){
|
440
|
+
omode |= HDBOLCKNB;
|
441
|
+
} else if(!strcmp(argv[i], "-df")){
|
442
|
+
df = true;
|
443
|
+
} else {
|
444
|
+
usage();
|
445
|
+
}
|
446
|
+
} else if(!path){
|
447
|
+
path = argv[i];
|
448
|
+
} else if(!bstr){
|
449
|
+
bstr = argv[i];
|
450
|
+
} else if(!astr){
|
451
|
+
astr = argv[i];
|
452
|
+
} else if(!fstr){
|
453
|
+
fstr = argv[i];
|
454
|
+
} else {
|
455
|
+
usage();
|
456
|
+
}
|
457
|
+
}
|
458
|
+
if(!path) usage();
|
459
|
+
int bnum = bstr ? tcatoix(bstr) : -1;
|
460
|
+
int apow = astr ? tcatoix(astr) : -1;
|
461
|
+
int fpow = fstr ? tcatoix(fstr) : -1;
|
462
|
+
int rv = procoptimize(path, bnum, apow, fpow, opts, omode, df);
|
463
|
+
return rv;
|
464
|
+
}
|
465
|
+
|
466
|
+
|
467
|
+
/* parse arguments of importtsv command */
|
468
|
+
static int runimporttsv(int argc, char **argv){
|
469
|
+
char *path = NULL;
|
470
|
+
char *file = NULL;
|
471
|
+
int omode = 0;
|
472
|
+
bool sc = false;
|
473
|
+
for(int i = 2; i < argc; i++){
|
474
|
+
if(!path && argv[i][0] == '-'){
|
475
|
+
if(!strcmp(argv[i], "-nl")){
|
476
|
+
omode |= HDBONOLCK;
|
477
|
+
} else if(!strcmp(argv[i], "-nb")){
|
478
|
+
omode |= HDBOLCKNB;
|
479
|
+
} else if(!strcmp(argv[i], "-sc")){
|
480
|
+
sc = true;
|
481
|
+
} else {
|
482
|
+
usage();
|
483
|
+
}
|
484
|
+
} else if(!path){
|
485
|
+
path = argv[i];
|
486
|
+
} else if(!file){
|
487
|
+
file = argv[i];
|
488
|
+
} else {
|
489
|
+
usage();
|
490
|
+
}
|
491
|
+
}
|
492
|
+
if(!path) usage();
|
493
|
+
int rv = procimporttsv(path, file, omode, sc);
|
494
|
+
return rv;
|
495
|
+
}
|
496
|
+
|
497
|
+
|
498
|
+
/* parse arguments of version command */
|
499
|
+
static int runversion(int argc, char **argv){
|
500
|
+
int rv = procversion();
|
501
|
+
return rv;
|
502
|
+
}
|
503
|
+
|
504
|
+
|
505
|
+
/* perform create command */
|
506
|
+
static int proccreate(const char *path, int bnum, int apow, int fpow, int opts){
|
507
|
+
TCHDB *hdb = tchdbnew();
|
508
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
509
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
510
|
+
if(!tchdbtune(hdb, bnum, apow, fpow, opts)){
|
511
|
+
printerr(hdb);
|
512
|
+
tchdbdel(hdb);
|
513
|
+
return 1;
|
514
|
+
}
|
515
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC)){
|
516
|
+
printerr(hdb);
|
517
|
+
tchdbdel(hdb);
|
518
|
+
return 1;
|
519
|
+
}
|
520
|
+
bool err = false;
|
521
|
+
if(!tchdbclose(hdb)){
|
522
|
+
printerr(hdb);
|
523
|
+
err = true;
|
524
|
+
}
|
525
|
+
tchdbdel(hdb);
|
526
|
+
return err ? 1 : 0;
|
527
|
+
}
|
528
|
+
|
529
|
+
|
530
|
+
/* perform inform command */
|
531
|
+
static int procinform(const char *path, int omode){
|
532
|
+
TCHDB *hdb = tchdbnew();
|
533
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
534
|
+
tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL);
|
535
|
+
if(!tchdbopen(hdb, path, HDBOREADER | omode)){
|
536
|
+
printerr(hdb);
|
537
|
+
tchdbdel(hdb);
|
538
|
+
return 1;
|
539
|
+
}
|
540
|
+
bool err = false;
|
541
|
+
const char *npath = tchdbpath(hdb);
|
542
|
+
if(!npath) npath = "(unknown)";
|
543
|
+
printf("path: %s\n", npath);
|
544
|
+
const char *type = "(unknown)";
|
545
|
+
switch(tchdbtype(hdb)){
|
546
|
+
case TCDBTHASH: type = "hash"; break;
|
547
|
+
case TCDBTBTREE: type = "btree"; break;
|
548
|
+
case TCDBTFIXED: type = "fixed"; break;
|
549
|
+
case TCDBTTABLE: type = "table"; break;
|
550
|
+
}
|
551
|
+
printf("database type: %s\n", type);
|
552
|
+
uint8_t flags = tchdbflags(hdb);
|
553
|
+
printf("additional flags:");
|
554
|
+
if(flags & HDBFOPEN) printf(" open");
|
555
|
+
if(flags & HDBFFATAL) printf(" fatal");
|
556
|
+
printf("\n");
|
557
|
+
printf("bucket number: %llu\n", (unsigned long long)tchdbbnum(hdb));
|
558
|
+
if(hdb->cnt_writerec >= 0)
|
559
|
+
printf("used bucket number: %lld\n", (long long)tchdbbnumused(hdb));
|
560
|
+
printf("alignment: %u\n", tchdbalign(hdb));
|
561
|
+
printf("free block pool: %u\n", tchdbfbpmax(hdb));
|
562
|
+
printf("inode number: %lld\n", (long long)tchdbinode(hdb));
|
563
|
+
char date[48];
|
564
|
+
tcdatestrwww(tchdbmtime(hdb), INT_MAX, date);
|
565
|
+
printf("modified time: %s\n", date);
|
566
|
+
uint8_t opts = tchdbopts(hdb);
|
567
|
+
printf("options:");
|
568
|
+
if(opts & HDBTLARGE) printf(" large");
|
569
|
+
if(opts & HDBTDEFLATE) printf(" deflate");
|
570
|
+
if(opts & HDBTBZIP) printf(" bzip");
|
571
|
+
if(opts & HDBTTCBS) printf(" tcbs");
|
572
|
+
if(opts & HDBTEXCODEC) printf(" excodec");
|
573
|
+
printf("\n");
|
574
|
+
printf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb));
|
575
|
+
printf("file size: %llu\n", (unsigned long long)tchdbfsiz(hdb));
|
576
|
+
if(!tchdbclose(hdb)){
|
577
|
+
if(!err) printerr(hdb);
|
578
|
+
err = true;
|
579
|
+
}
|
580
|
+
tchdbdel(hdb);
|
581
|
+
return err ? 1 : 0;
|
582
|
+
}
|
583
|
+
|
584
|
+
|
585
|
+
/* perform put command */
|
586
|
+
static int procput(const char *path, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
587
|
+
int omode, int dmode){
|
588
|
+
TCHDB *hdb = tchdbnew();
|
589
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
590
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
591
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | omode)){
|
592
|
+
printerr(hdb);
|
593
|
+
tchdbdel(hdb);
|
594
|
+
return 1;
|
595
|
+
}
|
596
|
+
bool err = false;
|
597
|
+
switch(dmode){
|
598
|
+
case -1:
|
599
|
+
if(!tchdbputkeep(hdb, kbuf, ksiz, vbuf, vsiz)){
|
600
|
+
printerr(hdb);
|
601
|
+
err = true;
|
602
|
+
}
|
603
|
+
break;
|
604
|
+
case 1:
|
605
|
+
if(!tchdbputcat(hdb, kbuf, ksiz, vbuf, vsiz)){
|
606
|
+
printerr(hdb);
|
607
|
+
err = true;
|
608
|
+
}
|
609
|
+
break;
|
610
|
+
case 10:
|
611
|
+
if(tchdbaddint(hdb, kbuf, ksiz, tcatoi(vbuf)) == INT_MIN){
|
612
|
+
printerr(hdb);
|
613
|
+
err = true;
|
614
|
+
}
|
615
|
+
break;
|
616
|
+
case 11:
|
617
|
+
if(isnan(tchdbadddouble(hdb, kbuf, ksiz, tcatof(vbuf)))){
|
618
|
+
printerr(hdb);
|
619
|
+
err = true;
|
620
|
+
}
|
621
|
+
break;
|
622
|
+
default:
|
623
|
+
if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
|
624
|
+
printerr(hdb);
|
625
|
+
err = true;
|
626
|
+
}
|
627
|
+
break;
|
628
|
+
}
|
629
|
+
if(!tchdbclose(hdb)){
|
630
|
+
if(!err) printerr(hdb);
|
631
|
+
err = true;
|
632
|
+
}
|
633
|
+
tchdbdel(hdb);
|
634
|
+
return err ? 1 : 0;
|
635
|
+
}
|
636
|
+
|
637
|
+
|
638
|
+
/* perform out command */
|
639
|
+
static int procout(const char *path, const char *kbuf, int ksiz, int omode){
|
640
|
+
TCHDB *hdb = tchdbnew();
|
641
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
642
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
643
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | omode)){
|
644
|
+
printerr(hdb);
|
645
|
+
tchdbdel(hdb);
|
646
|
+
return 1;
|
647
|
+
}
|
648
|
+
bool err = false;
|
649
|
+
if(!tchdbout(hdb, kbuf, ksiz)){
|
650
|
+
printerr(hdb);
|
651
|
+
err = true;
|
652
|
+
}
|
653
|
+
if(!tchdbclose(hdb)){
|
654
|
+
if(!err) printerr(hdb);
|
655
|
+
err = true;
|
656
|
+
}
|
657
|
+
tchdbdel(hdb);
|
658
|
+
return err ? 1 : 0;
|
659
|
+
}
|
660
|
+
|
661
|
+
|
662
|
+
/* perform get command */
|
663
|
+
static int procget(const char *path, const char *kbuf, int ksiz, int omode, bool px, bool pz){
|
664
|
+
TCHDB *hdb = tchdbnew();
|
665
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
666
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
667
|
+
if(!tchdbopen(hdb, path, HDBOREADER | omode)){
|
668
|
+
printerr(hdb);
|
669
|
+
tchdbdel(hdb);
|
670
|
+
return 1;
|
671
|
+
}
|
672
|
+
bool err = false;
|
673
|
+
int vsiz;
|
674
|
+
char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
|
675
|
+
if(vbuf){
|
676
|
+
printdata(vbuf, vsiz, px);
|
677
|
+
if(!pz) putchar('\n');
|
678
|
+
tcfree(vbuf);
|
679
|
+
} else {
|
680
|
+
printerr(hdb);
|
681
|
+
err = true;
|
682
|
+
}
|
683
|
+
if(!tchdbclose(hdb)){
|
684
|
+
if(!err) printerr(hdb);
|
685
|
+
err = true;
|
686
|
+
}
|
687
|
+
tchdbdel(hdb);
|
688
|
+
return err ? 1 : 0;
|
689
|
+
}
|
690
|
+
|
691
|
+
|
692
|
+
/* perform list command */
|
693
|
+
static int proclist(const char *path, int omode, int max, bool pv, bool px, const char *fmstr){
|
694
|
+
TCHDB *hdb = tchdbnew();
|
695
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
696
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
697
|
+
if(!tchdbopen(hdb, path, HDBOREADER | omode)){
|
698
|
+
printerr(hdb);
|
699
|
+
tchdbdel(hdb);
|
700
|
+
return 1;
|
701
|
+
}
|
702
|
+
bool err = false;
|
703
|
+
if(fmstr){
|
704
|
+
TCLIST *keys = tchdbfwmkeys2(hdb, fmstr, max);
|
705
|
+
for(int i = 0; i < tclistnum(keys); i++){
|
706
|
+
int ksiz;
|
707
|
+
const char *kbuf = tclistval(keys, i, &ksiz);
|
708
|
+
printdata(kbuf, ksiz, px);
|
709
|
+
if(pv){
|
710
|
+
int vsiz;
|
711
|
+
char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
|
712
|
+
if(vbuf){
|
713
|
+
putchar('\t');
|
714
|
+
printdata(vbuf, vsiz, px);
|
715
|
+
tcfree(vbuf);
|
716
|
+
}
|
717
|
+
}
|
718
|
+
putchar('\n');
|
719
|
+
}
|
720
|
+
tclistdel(keys);
|
721
|
+
} else {
|
722
|
+
if(!tchdbiterinit(hdb)){
|
723
|
+
printerr(hdb);
|
724
|
+
err = true;
|
725
|
+
}
|
726
|
+
TCXSTR *key = tcxstrnew();
|
727
|
+
TCXSTR *val = tcxstrnew();
|
728
|
+
int cnt = 0;
|
729
|
+
while(tchdbiternext3(hdb, key, val)){
|
730
|
+
printdata(tcxstrptr(key), tcxstrsize(key), px);
|
731
|
+
if(pv){
|
732
|
+
putchar('\t');
|
733
|
+
printdata(tcxstrptr(val), tcxstrsize(val), px);
|
734
|
+
}
|
735
|
+
putchar('\n');
|
736
|
+
if(max >= 0 && ++cnt >= max) break;
|
737
|
+
}
|
738
|
+
tcxstrdel(val);
|
739
|
+
tcxstrdel(key);
|
740
|
+
}
|
741
|
+
if(!tchdbclose(hdb)){
|
742
|
+
if(!err) printerr(hdb);
|
743
|
+
err = true;
|
744
|
+
}
|
745
|
+
tchdbdel(hdb);
|
746
|
+
return err ? 1 : 0;
|
747
|
+
}
|
748
|
+
|
749
|
+
|
750
|
+
/* perform optimize command */
|
751
|
+
static int procoptimize(const char *path, int bnum, int apow, int fpow, int opts, int omode,
|
752
|
+
bool df){
|
753
|
+
TCHDB *hdb = tchdbnew();
|
754
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
755
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
756
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | omode)){
|
757
|
+
printerr(hdb);
|
758
|
+
tchdbdel(hdb);
|
759
|
+
return 1;
|
760
|
+
}
|
761
|
+
bool err = false;
|
762
|
+
if(df){
|
763
|
+
if(!tchdbdefrag(hdb, INT64_MAX)){
|
764
|
+
printerr(hdb);
|
765
|
+
err = true;
|
766
|
+
}
|
767
|
+
} else {
|
768
|
+
if(!tchdboptimize(hdb, bnum, apow, fpow, opts)){
|
769
|
+
printerr(hdb);
|
770
|
+
err = true;
|
771
|
+
}
|
772
|
+
}
|
773
|
+
if(!tchdbclose(hdb)){
|
774
|
+
if(!err) printerr(hdb);
|
775
|
+
err = true;
|
776
|
+
}
|
777
|
+
tchdbdel(hdb);
|
778
|
+
return err ? 1 : 0;
|
779
|
+
}
|
780
|
+
|
781
|
+
|
782
|
+
/* perform importtsv command */
|
783
|
+
static int procimporttsv(const char *path, const char *file, int omode, bool sc){
|
784
|
+
FILE *ifp = file ? fopen(file, "rb") : stdin;
|
785
|
+
if(!ifp){
|
786
|
+
fprintf(stderr, "%s: could not open\n", file ? file : "(stdin)");
|
787
|
+
return 1;
|
788
|
+
}
|
789
|
+
TCHDB *hdb = tchdbnew();
|
790
|
+
if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
|
791
|
+
if(!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
|
792
|
+
if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | omode)){
|
793
|
+
printerr(hdb);
|
794
|
+
tchdbdel(hdb);
|
795
|
+
if(ifp != stdin) fclose(ifp);
|
796
|
+
return 1;
|
797
|
+
}
|
798
|
+
bool err = false;
|
799
|
+
char *line;
|
800
|
+
int cnt = 0;
|
801
|
+
while(!err && (line = mygetline(ifp)) != NULL){
|
802
|
+
char *pv = strchr(line, '\t');
|
803
|
+
if(!pv){
|
804
|
+
tcfree(line);
|
805
|
+
continue;
|
806
|
+
}
|
807
|
+
*pv = '\0';
|
808
|
+
if(sc) tcstrutfnorm(line, TCUNSPACE | TCUNLOWER | TCUNNOACC | TCUNWIDTH);
|
809
|
+
if(!tchdbput2(hdb, line, pv + 1)){
|
810
|
+
printerr(hdb);
|
811
|
+
err = true;
|
812
|
+
}
|
813
|
+
tcfree(line);
|
814
|
+
if(cnt > 0 && cnt % 100 == 0){
|
815
|
+
putchar('.');
|
816
|
+
fflush(stdout);
|
817
|
+
if(cnt % 5000 == 0) printf(" (%08d)\n", cnt);
|
818
|
+
}
|
819
|
+
cnt++;
|
820
|
+
}
|
821
|
+
printf(" (%08d)\n", cnt);
|
822
|
+
if(!tchdbclose(hdb)){
|
823
|
+
if(!err) printerr(hdb);
|
824
|
+
err = true;
|
825
|
+
}
|
826
|
+
tchdbdel(hdb);
|
827
|
+
if(ifp != stdin) fclose(ifp);
|
828
|
+
return err ? 1 : 0;
|
829
|
+
}
|
830
|
+
|
831
|
+
|
832
|
+
/* perform version command */
|
833
|
+
static int procversion(void){
|
834
|
+
printf("Tokyo Cabinet version %s (%d:%s) for %s\n",
|
835
|
+
tcversion, _TC_LIBVER, _TC_FORMATVER, TCSYSNAME);
|
836
|
+
printf("Copyright (C) 2006-2009 Mikio Hirabayashi\n");
|
837
|
+
return 0;
|
838
|
+
}
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
// END OF FILE
|