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,786 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* The command line utility of the fixed-length 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 <tcfdb.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(TCFDB *fdb);
|
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 width, int64_t limsiz);
|
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,
|
49
|
+
const char *rlstr, const char *rustr, const char *ristr);
|
50
|
+
static int procoptimize(const char *path, int width, int64_t limsiz, int omode);
|
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 fixed-length database API\n", g_progname);
|
91
|
+
fprintf(stderr, "\n");
|
92
|
+
fprintf(stderr, "usage:\n");
|
93
|
+
fprintf(stderr, " %s create path [width [limsiz]]\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] [-rb lkey ukey] [-ri str] path\n",
|
99
|
+
g_progname);
|
100
|
+
fprintf(stderr, " %s optimize [-nl|-nb] path [width [limsiz]]\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(TCFDB *fdb){
|
110
|
+
const char *path = tcfdbpath(fdb);
|
111
|
+
int ecode = tcfdbecode(fdb);
|
112
|
+
fprintf(stderr, "%s: %s: %d: %s\n", g_progname, path ? path : "-", ecode, tcfdberrmsg(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 *wstr = NULL;
|
164
|
+
char *lstr = NULL;
|
165
|
+
for(int i = 2; i < argc; i++){
|
166
|
+
if(!path && argv[i][0] == '-'){
|
167
|
+
usage();
|
168
|
+
} else if(!path){
|
169
|
+
path = argv[i];
|
170
|
+
} else if(!wstr){
|
171
|
+
wstr = argv[i];
|
172
|
+
} else if(!lstr){
|
173
|
+
lstr = argv[i];
|
174
|
+
} else {
|
175
|
+
usage();
|
176
|
+
}
|
177
|
+
}
|
178
|
+
if(!path) usage();
|
179
|
+
int width = wstr ? tcatoix(wstr) : -1;
|
180
|
+
int64_t limsiz = lstr ? tcatoix(lstr) : -1;
|
181
|
+
int rv = proccreate(path, width, limsiz);
|
182
|
+
return rv;
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
/* parse arguments of inform command */
|
187
|
+
static int runinform(int argc, char **argv){
|
188
|
+
char *path = NULL;
|
189
|
+
int omode = 0;
|
190
|
+
for(int i = 2; i < argc; i++){
|
191
|
+
if(!path && argv[i][0] == '-'){
|
192
|
+
if(!strcmp(argv[i], "-nl")){
|
193
|
+
omode |= FDBONOLCK;
|
194
|
+
} else if(!strcmp(argv[i], "-nb")){
|
195
|
+
omode |= FDBOLCKNB;
|
196
|
+
} else {
|
197
|
+
usage();
|
198
|
+
}
|
199
|
+
} else if(!path){
|
200
|
+
path = argv[i];
|
201
|
+
} else {
|
202
|
+
usage();
|
203
|
+
}
|
204
|
+
}
|
205
|
+
if(!path) usage();
|
206
|
+
int rv = procinform(path, omode);
|
207
|
+
return rv;
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
/* parse arguments of put command */
|
212
|
+
static int runput(int argc, char **argv){
|
213
|
+
char *path = NULL;
|
214
|
+
char *key = NULL;
|
215
|
+
char *value = NULL;
|
216
|
+
int omode = 0;
|
217
|
+
int dmode = 0;
|
218
|
+
bool sx = false;
|
219
|
+
for(int i = 2; i < argc; i++){
|
220
|
+
if(!path && argv[i][0] == '-'){
|
221
|
+
if(!strcmp(argv[i], "-nl")){
|
222
|
+
omode |= FDBONOLCK;
|
223
|
+
} else if(!strcmp(argv[i], "-nb")){
|
224
|
+
omode |= FDBOLCKNB;
|
225
|
+
} else if(!strcmp(argv[i], "-dk")){
|
226
|
+
dmode = -1;
|
227
|
+
} else if(!strcmp(argv[i], "-dc")){
|
228
|
+
dmode = 1;
|
229
|
+
} else if(!strcmp(argv[i], "-dai")){
|
230
|
+
dmode = 10;
|
231
|
+
} else if(!strcmp(argv[i], "-dad")){
|
232
|
+
dmode = 11;
|
233
|
+
} else if(!strcmp(argv[i], "-sx")){
|
234
|
+
sx = true;
|
235
|
+
} else {
|
236
|
+
usage();
|
237
|
+
}
|
238
|
+
} else if(!path){
|
239
|
+
path = argv[i];
|
240
|
+
} else if(!key){
|
241
|
+
key = argv[i];
|
242
|
+
} else if(!value){
|
243
|
+
value = argv[i];
|
244
|
+
} else {
|
245
|
+
usage();
|
246
|
+
}
|
247
|
+
}
|
248
|
+
if(!path || !key || !value) usage();
|
249
|
+
char *kbuf, *vbuf;
|
250
|
+
int ksiz, vsiz;
|
251
|
+
if(sx){
|
252
|
+
kbuf = tchexdecode(key, &ksiz);
|
253
|
+
vbuf = tchexdecode(value, &vsiz);
|
254
|
+
} else {
|
255
|
+
ksiz = strlen(key);
|
256
|
+
kbuf = tcmemdup(key, ksiz);
|
257
|
+
vsiz = strlen(value);
|
258
|
+
vbuf = tcmemdup(value, vsiz);
|
259
|
+
}
|
260
|
+
int rv = procput(path, kbuf, ksiz, vbuf, vsiz, omode, dmode);
|
261
|
+
tcfree(vbuf);
|
262
|
+
tcfree(kbuf);
|
263
|
+
return rv;
|
264
|
+
}
|
265
|
+
|
266
|
+
|
267
|
+
/* parse arguments of out command */
|
268
|
+
static int runout(int argc, char **argv){
|
269
|
+
char *path = NULL;
|
270
|
+
char *key = NULL;
|
271
|
+
int omode = 0;
|
272
|
+
bool sx = false;
|
273
|
+
for(int i = 2; i < argc; i++){
|
274
|
+
if(!path && argv[i][0] == '-'){
|
275
|
+
if(!strcmp(argv[i], "-nl")){
|
276
|
+
omode |= FDBONOLCK;
|
277
|
+
} else if(!strcmp(argv[i], "-nb")){
|
278
|
+
omode |= FDBOLCKNB;
|
279
|
+
} else if(!strcmp(argv[i], "-sx")){
|
280
|
+
sx = true;
|
281
|
+
} else {
|
282
|
+
usage();
|
283
|
+
}
|
284
|
+
} else if(!path){
|
285
|
+
path = argv[i];
|
286
|
+
} else if(!key){
|
287
|
+
key = argv[i];
|
288
|
+
} else {
|
289
|
+
usage();
|
290
|
+
}
|
291
|
+
}
|
292
|
+
if(!path || !key) usage();
|
293
|
+
int ksiz;
|
294
|
+
char *kbuf;
|
295
|
+
if(sx){
|
296
|
+
kbuf = tchexdecode(key, &ksiz);
|
297
|
+
} else {
|
298
|
+
ksiz = strlen(key);
|
299
|
+
kbuf = tcmemdup(key, ksiz);
|
300
|
+
}
|
301
|
+
int rv = procout(path, kbuf, ksiz, omode);
|
302
|
+
tcfree(kbuf);
|
303
|
+
return rv;
|
304
|
+
}
|
305
|
+
|
306
|
+
|
307
|
+
/* parse arguments of get command */
|
308
|
+
static int runget(int argc, char **argv){
|
309
|
+
char *path = NULL;
|
310
|
+
char *key = NULL;
|
311
|
+
int omode = 0;
|
312
|
+
bool sx = false;
|
313
|
+
bool px = false;
|
314
|
+
bool pz = false;
|
315
|
+
for(int i = 2; i < argc; i++){
|
316
|
+
if(!path && argv[i][0] == '-'){
|
317
|
+
if(!strcmp(argv[i], "-nl")){
|
318
|
+
omode |= FDBONOLCK;
|
319
|
+
} else if(!strcmp(argv[i], "-nb")){
|
320
|
+
omode |= FDBOLCKNB;
|
321
|
+
} else if(!strcmp(argv[i], "-sx")){
|
322
|
+
sx = true;
|
323
|
+
} else if(!strcmp(argv[i], "-px")){
|
324
|
+
px = true;
|
325
|
+
} else if(!strcmp(argv[i], "-pz")){
|
326
|
+
pz = true;
|
327
|
+
} else {
|
328
|
+
usage();
|
329
|
+
}
|
330
|
+
} else if(!path){
|
331
|
+
path = argv[i];
|
332
|
+
} else if(!key){
|
333
|
+
key = argv[i];
|
334
|
+
} else {
|
335
|
+
usage();
|
336
|
+
}
|
337
|
+
}
|
338
|
+
if(!path || !key) usage();
|
339
|
+
int ksiz;
|
340
|
+
char *kbuf;
|
341
|
+
if(sx){
|
342
|
+
kbuf = tchexdecode(key, &ksiz);
|
343
|
+
} else {
|
344
|
+
ksiz = strlen(key);
|
345
|
+
kbuf = tcmemdup(key, ksiz);
|
346
|
+
}
|
347
|
+
int rv = procget(path, kbuf, ksiz, omode, px, pz);
|
348
|
+
tcfree(kbuf);
|
349
|
+
return rv;
|
350
|
+
}
|
351
|
+
|
352
|
+
|
353
|
+
/* parse arguments of list command */
|
354
|
+
static int runlist(int argc, char **argv){
|
355
|
+
char *path = NULL;
|
356
|
+
int omode = 0;
|
357
|
+
int max = -1;
|
358
|
+
bool pv = false;
|
359
|
+
bool px = false;
|
360
|
+
char *rlstr = NULL;
|
361
|
+
char *rustr = NULL;
|
362
|
+
char *ristr = NULL;
|
363
|
+
for(int i = 2; i < argc; i++){
|
364
|
+
if(!path && argv[i][0] == '-'){
|
365
|
+
if(!strcmp(argv[i], "-nl")){
|
366
|
+
omode |= FDBONOLCK;
|
367
|
+
} else if(!strcmp(argv[i], "-nb")){
|
368
|
+
omode |= FDBOLCKNB;
|
369
|
+
} else if(!strcmp(argv[i], "-m")){
|
370
|
+
if(++i >= argc) usage();
|
371
|
+
max = tcatoix(argv[i]);
|
372
|
+
} else if(!strcmp(argv[i], "-pv")){
|
373
|
+
pv = true;
|
374
|
+
} else if(!strcmp(argv[i], "-px")){
|
375
|
+
px = true;
|
376
|
+
} else if(!strcmp(argv[i], "-rb")){
|
377
|
+
if(++i >= argc) usage();
|
378
|
+
rlstr = argv[i];
|
379
|
+
if(++i >= argc) usage();
|
380
|
+
rustr = argv[i];
|
381
|
+
} else if(!strcmp(argv[i], "-ri")){
|
382
|
+
if(++i >= argc) usage();
|
383
|
+
ristr = argv[i];
|
384
|
+
} else {
|
385
|
+
usage();
|
386
|
+
}
|
387
|
+
} else if(!path){
|
388
|
+
path = argv[i];
|
389
|
+
} else {
|
390
|
+
usage();
|
391
|
+
}
|
392
|
+
}
|
393
|
+
if(!path) usage();
|
394
|
+
int rv = proclist(path, omode, max, pv, px, rlstr, rustr, ristr);
|
395
|
+
return rv;
|
396
|
+
}
|
397
|
+
|
398
|
+
|
399
|
+
/* parse arguments of optimize command */
|
400
|
+
static int runoptimize(int argc, char **argv){
|
401
|
+
char *path = NULL;
|
402
|
+
char *wstr = NULL;
|
403
|
+
char *lstr = NULL;
|
404
|
+
int omode = 0;
|
405
|
+
for(int i = 2; i < argc; i++){
|
406
|
+
if(!path && argv[i][0] == '-'){
|
407
|
+
if(!strcmp(argv[i], "-nl")){
|
408
|
+
omode |= FDBONOLCK;
|
409
|
+
} else if(!strcmp(argv[i], "-nb")){
|
410
|
+
omode |= FDBOLCKNB;
|
411
|
+
} else {
|
412
|
+
usage();
|
413
|
+
}
|
414
|
+
} else if(!path){
|
415
|
+
path = argv[i];
|
416
|
+
} else if(!wstr){
|
417
|
+
wstr = argv[i];
|
418
|
+
} else if(!lstr){
|
419
|
+
lstr = argv[i];
|
420
|
+
} else {
|
421
|
+
usage();
|
422
|
+
}
|
423
|
+
}
|
424
|
+
if(!path) usage();
|
425
|
+
int width = wstr ? tcatoix(wstr) : -1;
|
426
|
+
int64_t limsiz = lstr ? tcatoix(lstr) : -1;
|
427
|
+
int rv = procoptimize(path, width, limsiz, omode);
|
428
|
+
return rv;
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
/* parse arguments of importtsv command */
|
433
|
+
static int runimporttsv(int argc, char **argv){
|
434
|
+
char *path = NULL;
|
435
|
+
char *file = NULL;
|
436
|
+
int omode = 0;
|
437
|
+
bool sc = false;
|
438
|
+
for(int i = 2; i < argc; i++){
|
439
|
+
if(!path && argv[i][0] == '-'){
|
440
|
+
if(!strcmp(argv[i], "-nl")){
|
441
|
+
omode |= FDBONOLCK;
|
442
|
+
} else if(!strcmp(argv[i], "-nb")){
|
443
|
+
omode |= FDBOLCKNB;
|
444
|
+
} else if(!strcmp(argv[i], "-sc")){
|
445
|
+
sc = true;
|
446
|
+
} else {
|
447
|
+
usage();
|
448
|
+
}
|
449
|
+
} else if(!path){
|
450
|
+
path = argv[i];
|
451
|
+
} else if(!file){
|
452
|
+
file = argv[i];
|
453
|
+
} else {
|
454
|
+
usage();
|
455
|
+
}
|
456
|
+
}
|
457
|
+
if(!path) usage();
|
458
|
+
int rv = procimporttsv(path, file, omode, sc);
|
459
|
+
return rv;
|
460
|
+
}
|
461
|
+
|
462
|
+
|
463
|
+
/* parse arguments of version command */
|
464
|
+
static int runversion(int argc, char **argv){
|
465
|
+
int rv = procversion();
|
466
|
+
return rv;
|
467
|
+
}
|
468
|
+
|
469
|
+
|
470
|
+
/* perform create command */
|
471
|
+
static int proccreate(const char *path, int width, int64_t limsiz){
|
472
|
+
TCFDB *fdb = tcfdbnew();
|
473
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
474
|
+
if(!tcfdbtune(fdb, width, limsiz)){
|
475
|
+
printerr(fdb);
|
476
|
+
tcfdbdel(fdb);
|
477
|
+
return 1;
|
478
|
+
}
|
479
|
+
if(!tcfdbopen(fdb, path, FDBOWRITER | FDBOCREAT | FDBOTRUNC)){
|
480
|
+
printerr(fdb);
|
481
|
+
tcfdbdel(fdb);
|
482
|
+
return 1;
|
483
|
+
}
|
484
|
+
bool err = false;
|
485
|
+
if(!tcfdbclose(fdb)){
|
486
|
+
printerr(fdb);
|
487
|
+
err = true;
|
488
|
+
}
|
489
|
+
tcfdbdel(fdb);
|
490
|
+
return err ? 1 : 0;
|
491
|
+
}
|
492
|
+
|
493
|
+
|
494
|
+
/* perform inform command */
|
495
|
+
static int procinform(const char *path, int omode){
|
496
|
+
TCFDB *fdb = tcfdbnew();
|
497
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
498
|
+
if(!tcfdbopen(fdb, path, FDBOREADER | omode)){
|
499
|
+
printerr(fdb);
|
500
|
+
tcfdbdel(fdb);
|
501
|
+
return 1;
|
502
|
+
}
|
503
|
+
bool err = false;
|
504
|
+
const char *npath = tcfdbpath(fdb);
|
505
|
+
if(!npath) npath = "(unknown)";
|
506
|
+
printf("path: %s\n", npath);
|
507
|
+
const char *type = "(unknown)";
|
508
|
+
switch(tcfdbtype(fdb)){
|
509
|
+
case TCDBTHASH: type = "hash"; break;
|
510
|
+
case TCDBTBTREE: type = "btree"; break;
|
511
|
+
case TCDBTFIXED: type = "fixed"; break;
|
512
|
+
case TCDBTTABLE: type = "table"; break;
|
513
|
+
}
|
514
|
+
printf("database type: %s\n", type);
|
515
|
+
uint8_t flags = tcfdbflags(fdb);
|
516
|
+
printf("additional flags:");
|
517
|
+
if(flags & FDBFOPEN) printf(" open");
|
518
|
+
if(flags & FDBFFATAL) printf(" fatal");
|
519
|
+
printf("\n");
|
520
|
+
printf("minimum ID number: %llu\n", (unsigned long long)tcfdbmin(fdb));
|
521
|
+
printf("maximum ID number: %llu\n", (unsigned long long)tcfdbmax(fdb));
|
522
|
+
printf("width of the value: %u\n", (unsigned int)tcfdbwidth(fdb));
|
523
|
+
printf("limit file size: %llu\n", (unsigned long long)tcfdblimsiz(fdb));
|
524
|
+
printf("limit ID number: %llu\n", (unsigned long long)tcfdblimid(fdb));
|
525
|
+
printf("inode number: %lld\n", (long long)tcfdbinode(fdb));
|
526
|
+
char date[48];
|
527
|
+
tcdatestrwww(tcfdbmtime(fdb), INT_MAX, date);
|
528
|
+
printf("modified time: %s\n", date);
|
529
|
+
printf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
|
530
|
+
printf("file size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
|
531
|
+
if(!tcfdbclose(fdb)){
|
532
|
+
if(!err) printerr(fdb);
|
533
|
+
err = true;
|
534
|
+
}
|
535
|
+
tcfdbdel(fdb);
|
536
|
+
return err ? 1 : 0;
|
537
|
+
}
|
538
|
+
|
539
|
+
|
540
|
+
/* perform put command */
|
541
|
+
static int procput(const char *path, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
|
542
|
+
int omode, int dmode){
|
543
|
+
TCFDB *fdb = tcfdbnew();
|
544
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
545
|
+
if(!tcfdbopen(fdb, path, FDBOWRITER | omode)){
|
546
|
+
printerr(fdb);
|
547
|
+
tcfdbdel(fdb);
|
548
|
+
return 1;
|
549
|
+
}
|
550
|
+
bool err = false;
|
551
|
+
switch(dmode){
|
552
|
+
case -1:
|
553
|
+
if(!tcfdbputkeep2(fdb, kbuf, ksiz, vbuf, vsiz)){
|
554
|
+
printerr(fdb);
|
555
|
+
err = true;
|
556
|
+
}
|
557
|
+
break;
|
558
|
+
case 1:
|
559
|
+
if(!tcfdbputcat2(fdb, kbuf, ksiz, vbuf, vsiz)){
|
560
|
+
printerr(fdb);
|
561
|
+
err = true;
|
562
|
+
}
|
563
|
+
break;
|
564
|
+
case 10:
|
565
|
+
if(tcfdbaddint(fdb, tcfdbkeytoid(kbuf, ksiz), tcatoi(vbuf)) == INT_MIN){
|
566
|
+
printerr(fdb);
|
567
|
+
err = true;
|
568
|
+
}
|
569
|
+
break;
|
570
|
+
case 11:
|
571
|
+
if(isnan(tcfdbadddouble(fdb, tcfdbkeytoid(kbuf, ksiz), tcatof(vbuf)))){
|
572
|
+
printerr(fdb);
|
573
|
+
err = true;
|
574
|
+
}
|
575
|
+
break;
|
576
|
+
default:
|
577
|
+
if(!tcfdbput2(fdb, kbuf, ksiz, vbuf, vsiz)){
|
578
|
+
printerr(fdb);
|
579
|
+
err = true;
|
580
|
+
}
|
581
|
+
break;
|
582
|
+
}
|
583
|
+
if(!tcfdbclose(fdb)){
|
584
|
+
if(!err) printerr(fdb);
|
585
|
+
err = true;
|
586
|
+
}
|
587
|
+
tcfdbdel(fdb);
|
588
|
+
return err ? 1 : 0;
|
589
|
+
}
|
590
|
+
|
591
|
+
|
592
|
+
/* perform out command */
|
593
|
+
static int procout(const char *path, const char *kbuf, int ksiz, int omode){
|
594
|
+
TCFDB *fdb = tcfdbnew();
|
595
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
596
|
+
if(!tcfdbopen(fdb, path, FDBOWRITER | omode)){
|
597
|
+
printerr(fdb);
|
598
|
+
tcfdbdel(fdb);
|
599
|
+
return 1;
|
600
|
+
}
|
601
|
+
bool err = false;
|
602
|
+
if(!tcfdbout2(fdb, kbuf, ksiz)){
|
603
|
+
printerr(fdb);
|
604
|
+
err = true;
|
605
|
+
}
|
606
|
+
if(!tcfdbclose(fdb)){
|
607
|
+
if(!err) printerr(fdb);
|
608
|
+
err = true;
|
609
|
+
}
|
610
|
+
tcfdbdel(fdb);
|
611
|
+
return err ? 1 : 0;
|
612
|
+
}
|
613
|
+
|
614
|
+
|
615
|
+
/* perform get command */
|
616
|
+
static int procget(const char *path, const char *kbuf, int ksiz, int omode, bool px, bool pz){
|
617
|
+
TCFDB *fdb = tcfdbnew();
|
618
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
619
|
+
if(!tcfdbopen(fdb, path, FDBOREADER | omode)){
|
620
|
+
printerr(fdb);
|
621
|
+
tcfdbdel(fdb);
|
622
|
+
return 1;
|
623
|
+
}
|
624
|
+
bool err = false;
|
625
|
+
int vsiz;
|
626
|
+
char *vbuf = tcfdbget2(fdb, kbuf, ksiz, &vsiz);
|
627
|
+
if(vbuf){
|
628
|
+
printdata(vbuf, vsiz, px);
|
629
|
+
if(!pz) putchar('\n');
|
630
|
+
tcfree(vbuf);
|
631
|
+
} else {
|
632
|
+
printerr(fdb);
|
633
|
+
err = true;
|
634
|
+
}
|
635
|
+
if(!tcfdbclose(fdb)){
|
636
|
+
if(!err) printerr(fdb);
|
637
|
+
err = true;
|
638
|
+
}
|
639
|
+
tcfdbdel(fdb);
|
640
|
+
return err ? 1 : 0;
|
641
|
+
}
|
642
|
+
|
643
|
+
|
644
|
+
/* perform list command */
|
645
|
+
static int proclist(const char *path, int omode, int max, bool pv, bool px,
|
646
|
+
const char *rlstr, const char *rustr, const char *ristr){
|
647
|
+
TCFDB *fdb = tcfdbnew();
|
648
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
649
|
+
if(!tcfdbopen(fdb, path, FDBOREADER | omode)){
|
650
|
+
printerr(fdb);
|
651
|
+
tcfdbdel(fdb);
|
652
|
+
return 1;
|
653
|
+
}
|
654
|
+
bool err = false;
|
655
|
+
if(rlstr || ristr){
|
656
|
+
TCLIST *keys = ristr ? tcfdbrange5(fdb, ristr, max) : tcfdbrange3(fdb, rlstr, rustr, max);
|
657
|
+
for(int i = 0; i < tclistnum(keys); i++){
|
658
|
+
int ksiz;
|
659
|
+
const char *kbuf = tclistval(keys, i, &ksiz);
|
660
|
+
printf("%s", kbuf);
|
661
|
+
if(pv){
|
662
|
+
int vsiz;
|
663
|
+
char *vbuf = tcfdbget2(fdb, kbuf, ksiz, &vsiz);
|
664
|
+
if(vbuf){
|
665
|
+
putchar('\t');
|
666
|
+
printdata(vbuf, vsiz, px);
|
667
|
+
tcfree(vbuf);
|
668
|
+
}
|
669
|
+
}
|
670
|
+
putchar('\n');
|
671
|
+
}
|
672
|
+
tclistdel(keys);
|
673
|
+
} else {
|
674
|
+
if(!tcfdbiterinit(fdb)){
|
675
|
+
printerr(fdb);
|
676
|
+
err = true;
|
677
|
+
}
|
678
|
+
int cnt = 0;
|
679
|
+
uint64_t id;
|
680
|
+
while((id = tcfdbiternext(fdb)) > 0){
|
681
|
+
printf("%llu", (unsigned long long)id);
|
682
|
+
if(pv){
|
683
|
+
int vsiz;
|
684
|
+
char *vbuf = tcfdbget(fdb, id, &vsiz);
|
685
|
+
if(vbuf){
|
686
|
+
putchar('\t');
|
687
|
+
printdata(vbuf, vsiz, px);
|
688
|
+
tcfree(vbuf);
|
689
|
+
}
|
690
|
+
}
|
691
|
+
putchar('\n');
|
692
|
+
if(max >= 0 && ++cnt >= max) break;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
if(!tcfdbclose(fdb)){
|
696
|
+
if(!err) printerr(fdb);
|
697
|
+
err = true;
|
698
|
+
}
|
699
|
+
tcfdbdel(fdb);
|
700
|
+
return err ? 1 : 0;
|
701
|
+
}
|
702
|
+
|
703
|
+
|
704
|
+
/* perform optimize command */
|
705
|
+
static int procoptimize(const char *path, int width, int64_t limsiz, int omode){
|
706
|
+
TCFDB *fdb = tcfdbnew();
|
707
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
708
|
+
if(!tcfdbopen(fdb, path, FDBOWRITER | omode)){
|
709
|
+
printerr(fdb);
|
710
|
+
tcfdbdel(fdb);
|
711
|
+
return 1;
|
712
|
+
}
|
713
|
+
bool err = false;
|
714
|
+
if(!tcfdboptimize(fdb, width, limsiz)){
|
715
|
+
printerr(fdb);
|
716
|
+
err = true;
|
717
|
+
}
|
718
|
+
if(!tcfdbclose(fdb)){
|
719
|
+
if(!err) printerr(fdb);
|
720
|
+
err = true;
|
721
|
+
}
|
722
|
+
tcfdbdel(fdb);
|
723
|
+
return err ? 1 : 0;
|
724
|
+
}
|
725
|
+
|
726
|
+
|
727
|
+
/* perform importtsv command */
|
728
|
+
static int procimporttsv(const char *path, const char *file, int omode, bool sc){
|
729
|
+
FILE *ifp = file ? fopen(file, "rb") : stdin;
|
730
|
+
if(!ifp){
|
731
|
+
fprintf(stderr, "%s: could not open\n", file ? file : "(stdin)");
|
732
|
+
return 1;
|
733
|
+
}
|
734
|
+
TCFDB *fdb = tcfdbnew();
|
735
|
+
if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
|
736
|
+
if(!tcfdbopen(fdb, path, FDBOWRITER | FDBOCREAT | omode)){
|
737
|
+
printerr(fdb);
|
738
|
+
tcfdbdel(fdb);
|
739
|
+
if(ifp != stdin) fclose(ifp);
|
740
|
+
return 1;
|
741
|
+
}
|
742
|
+
bool err = false;
|
743
|
+
char *line;
|
744
|
+
int cnt = 0;
|
745
|
+
while(!err && (line = mygetline(ifp)) != NULL){
|
746
|
+
char *pv = strchr(line, '\t');
|
747
|
+
if(!pv){
|
748
|
+
tcfree(line);
|
749
|
+
continue;
|
750
|
+
}
|
751
|
+
*pv = '\0';
|
752
|
+
if(sc) tcstrutfnorm(line, TCUNSPACE | TCUNLOWER | TCUNNOACC | TCUNWIDTH);
|
753
|
+
if(!tcfdbput3(fdb, line, pv + 1)){
|
754
|
+
printerr(fdb);
|
755
|
+
err = true;
|
756
|
+
}
|
757
|
+
tcfree(line);
|
758
|
+
if(cnt > 0 && cnt % 100 == 0){
|
759
|
+
putchar('.');
|
760
|
+
fflush(stdout);
|
761
|
+
if(cnt % 5000 == 0) printf(" (%08d)\n", cnt);
|
762
|
+
}
|
763
|
+
cnt++;
|
764
|
+
}
|
765
|
+
printf(" (%08d)\n", cnt);
|
766
|
+
if(!tcfdbclose(fdb)){
|
767
|
+
if(!err) printerr(fdb);
|
768
|
+
err = true;
|
769
|
+
}
|
770
|
+
tcfdbdel(fdb);
|
771
|
+
if(ifp != stdin) fclose(ifp);
|
772
|
+
return err ? 1 : 0;
|
773
|
+
}
|
774
|
+
|
775
|
+
|
776
|
+
/* perform version command */
|
777
|
+
static int procversion(void){
|
778
|
+
printf("Tokyo Cabinet version %s (%d:%s) for %s\n",
|
779
|
+
tcversion, _TC_LIBVER, _TC_FORMATVER, TCSYSNAME);
|
780
|
+
printf("Copyright (C) 2006-2009 Mikio Hirabayashi\n");
|
781
|
+
return 0;
|
782
|
+
}
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
// END OF FILE
|