heroku-tokyotyrant 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (340) hide show
  1. data/COPYING +504 -0
  2. data/README.rdoc +231 -0
  3. data/Rakefile +72 -0
  4. data/benchmarks/balancer.rb +101 -0
  5. data/benchmarks/bulk_db.rb +74 -0
  6. data/benchmarks/bulk_table.rb +87 -0
  7. data/benchmarks/db.rb +114 -0
  8. data/benchmarks/table.rb +161 -0
  9. data/ext/extconf.rb +43 -0
  10. data/ext/tokyo/bin/tcamgr +0 -0
  11. data/ext/tokyo/bin/tcamttest +0 -0
  12. data/ext/tokyo/bin/tcatest +0 -0
  13. data/ext/tokyo/bin/tcbmgr +0 -0
  14. data/ext/tokyo/bin/tcbmttest +0 -0
  15. data/ext/tokyo/bin/tcbtest +0 -0
  16. data/ext/tokyo/bin/tcfmgr +0 -0
  17. data/ext/tokyo/bin/tcfmttest +0 -0
  18. data/ext/tokyo/bin/tcftest +0 -0
  19. data/ext/tokyo/bin/tchmgr +0 -0
  20. data/ext/tokyo/bin/tchmttest +0 -0
  21. data/ext/tokyo/bin/tchtest +0 -0
  22. data/ext/tokyo/bin/tcrmgr +0 -0
  23. data/ext/tokyo/bin/tcrmttest +0 -0
  24. data/ext/tokyo/bin/tcrtest +0 -0
  25. data/ext/tokyo/bin/tctmgr +0 -0
  26. data/ext/tokyo/bin/tctmttest +0 -0
  27. data/ext/tokyo/bin/tcttest +0 -0
  28. data/ext/tokyo/bin/tcucodec +0 -0
  29. data/ext/tokyo/bin/tcumttest +0 -0
  30. data/ext/tokyo/bin/tcutest +0 -0
  31. data/ext/tokyo/bin/ttserver +0 -0
  32. data/ext/tokyo/bin/ttulmgr +0 -0
  33. data/ext/tokyo/bin/ttultest +0 -0
  34. data/ext/tokyo/include/tcadb.h +548 -0
  35. data/ext/tokyo/include/tcbdb.h +1101 -0
  36. data/ext/tokyo/include/tcfdb.h +858 -0
  37. data/ext/tokyo/include/tchdb.h +871 -0
  38. data/ext/tokyo/include/tcrdb.h +801 -0
  39. data/ext/tokyo/include/tctdb.h +1086 -0
  40. data/ext/tokyo/include/tculog.h +392 -0
  41. data/ext/tokyo/include/tcutil.h +4184 -0
  42. data/ext/tokyo/include/ttutil.h +494 -0
  43. data/ext/tokyo/lib/libtokyocabinet.9.4.0.dylib +0 -0
  44. data/ext/tokyo/lib/libtokyocabinet.9.dylib +0 -0
  45. data/ext/tokyo/lib/libtokyocabinet.a +0 -0
  46. data/ext/tokyo/lib/libtokyocabinet.dylib +0 -0
  47. data/ext/tokyo/lib/libtokyotyrant.3.22.0.dylib +0 -0
  48. data/ext/tokyo/lib/libtokyotyrant.3.dylib +0 -0
  49. data/ext/tokyo/lib/libtokyotyrant.a +0 -0
  50. data/ext/tokyo/lib/libtokyotyrant.dylib +0 -0
  51. data/ext/tokyo/lib/pkgconfig/tokyocabinet.pc +14 -0
  52. data/ext/tokyo/lib/pkgconfig/tokyotyrant.pc +14 -0
  53. data/ext/tokyo/lib/ttskeldir.bundle +0 -0
  54. data/ext/tokyo/lib/ttskelmock.bundle +0 -0
  55. data/ext/tokyo/lib/ttskelnull.bundle +0 -0
  56. data/ext/tokyo/lib/ttskelproxy.bundle +0 -0
  57. data/ext/tokyo/libexec/tcawmgr.cgi +0 -0
  58. data/ext/tokyo/sbin/ttservctl +163 -0
  59. data/ext/tokyo/share/man/man1/tcamgr.1 +97 -0
  60. data/ext/tokyo/share/man/man1/tcamttest.1 +35 -0
  61. data/ext/tokyo/share/man/man1/tcatest.1 +55 -0
  62. data/ext/tokyo/share/man/man1/tcbmgr.1 +125 -0
  63. data/ext/tokyo/share/man/man1/tcbmttest.1 +81 -0
  64. data/ext/tokyo/share/man/man1/tcbtest.1 +107 -0
  65. data/ext/tokyo/share/man/man1/tcfmgr.1 +98 -0
  66. data/ext/tokyo/share/man/man1/tcfmttest.1 +62 -0
  67. data/ext/tokyo/share/man/man1/tcftest.1 +73 -0
  68. data/ext/tokyo/share/man/man1/tchmgr.1 +110 -0
  69. data/ext/tokyo/share/man/man1/tchmttest.1 +85 -0
  70. data/ext/tokyo/share/man/man1/tchtest.1 +95 -0
  71. data/ext/tokyo/share/man/man1/tcrmgr.1 +164 -0
  72. data/ext/tokyo/share/man/man1/tcrmttest.1 +55 -0
  73. data/ext/tokyo/share/man/man1/tcrtest.1 +89 -0
  74. data/ext/tokyo/share/man/man1/tctmgr.1 +140 -0
  75. data/ext/tokyo/share/man/man1/tctmttest.1 +92 -0
  76. data/ext/tokyo/share/man/man1/tcttest.1 +105 -0
  77. data/ext/tokyo/share/man/man1/tcucodec.1 +162 -0
  78. data/ext/tokyo/share/man/man1/tcumttest.1 +41 -0
  79. data/ext/tokyo/share/man/man1/tcutest.1 +81 -0
  80. data/ext/tokyo/share/man/man1/ttserver.1 +84 -0
  81. data/ext/tokyo/share/man/man1/ttulmgr.1 +40 -0
  82. data/ext/tokyo/share/man/man1/ttultest.1 +16 -0
  83. data/ext/tokyo/share/man/man3/tcadb.3 +676 -0
  84. data/ext/tokyo/share/man/man3/tcbdb.3 +1355 -0
  85. data/ext/tokyo/share/man/man3/tcfdb.3 +975 -0
  86. data/ext/tokyo/share/man/man3/tchdb.3 +898 -0
  87. data/ext/tokyo/share/man/man3/tclist.3 +1 -0
  88. data/ext/tokyo/share/man/man3/tcmap.3 +1 -0
  89. data/ext/tokyo/share/man/man3/tcmdb.3 +1 -0
  90. data/ext/tokyo/share/man/man3/tcmpool.3 +1 -0
  91. data/ext/tokyo/share/man/man3/tcrdb.3 +1309 -0
  92. data/ext/tokyo/share/man/man3/tctdb.3 +1110 -0
  93. data/ext/tokyo/share/man/man3/tctree.3 +1 -0
  94. data/ext/tokyo/share/man/man3/tculog.3 +15 -0
  95. data/ext/tokyo/share/man/man3/tcutil.3 +4518 -0
  96. data/ext/tokyo/share/man/man3/tcxstr.3 +1 -0
  97. data/ext/tokyo/share/man/man3/tokyocabinet.3 +132 -0
  98. data/ext/tokyo/share/man/man3/ttutil.3 +14 -0
  99. data/ext/tokyo/share/man/man8/ttservctl.8 +37 -0
  100. data/ext/tokyo/share/tokyocabinet/COPYING +504 -0
  101. data/ext/tokyo/share/tokyocabinet/ChangeLog +1252 -0
  102. data/ext/tokyo/share/tokyocabinet/THANKS +12 -0
  103. data/ext/tokyo/share/tokyocabinet/doc/benchmark.pdf +0 -0
  104. data/ext/tokyo/share/tokyocabinet/doc/common.css +211 -0
  105. data/ext/tokyo/share/tokyocabinet/doc/icon16.png +0 -0
  106. data/ext/tokyo/share/tokyocabinet/doc/index.html +156 -0
  107. data/ext/tokyo/share/tokyocabinet/doc/index.ja.html +197 -0
  108. data/ext/tokyo/share/tokyocabinet/doc/logo-ja.png +0 -0
  109. data/ext/tokyo/share/tokyocabinet/doc/logo.png +0 -0
  110. data/ext/tokyo/share/tokyocabinet/doc/spex-en.html +7145 -0
  111. data/ext/tokyo/share/tokyocabinet/doc/spex-ja.html +7476 -0
  112. data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.pdf +0 -0
  113. data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.ppt +0 -0
  114. data/ext/tokyo/share/tokyotyrant/COPYING +504 -0
  115. data/ext/tokyo/share/tokyotyrant/ChangeLog +578 -0
  116. data/ext/tokyo/share/tokyotyrant/THANKS +15 -0
  117. data/ext/tokyo/share/tokyotyrant/doc/common.css +211 -0
  118. data/ext/tokyo/share/tokyotyrant/doc/index.html +79 -0
  119. data/ext/tokyo/share/tokyotyrant/doc/spex.html +2264 -0
  120. data/ext/tokyo/share/tokyotyrant/ext/mapreduce.lua +57 -0
  121. data/ext/tokyo/share/tokyotyrant/ext/queue.lua +55 -0
  122. data/ext/tokyo/share/tokyotyrant/ext/senatus.lua +532 -0
  123. data/ext/tokyo/share/tokyotyrant/ext/usherette.lua +438 -0
  124. data/ext/tokyo_tyrant.c +147 -0
  125. data/ext/tokyo_tyrant.h +48 -0
  126. data/ext/tokyo_tyrant_db.c +227 -0
  127. data/ext/tokyo_tyrant_db.h +8 -0
  128. data/ext/tokyo_tyrant_module.c +453 -0
  129. data/ext/tokyo_tyrant_module.h +10 -0
  130. data/ext/tokyo_tyrant_query.c +226 -0
  131. data/ext/tokyo_tyrant_query.h +9 -0
  132. data/ext/tokyo_tyrant_table.c +319 -0
  133. data/ext/tokyo_tyrant_table.h +8 -0
  134. data/ext/tokyocabinet-1.4.41/COPYING +504 -0
  135. data/ext/tokyocabinet-1.4.41/ChangeLog +1252 -0
  136. data/ext/tokyocabinet-1.4.41/Makefile.in +825 -0
  137. data/ext/tokyocabinet-1.4.41/README +38 -0
  138. data/ext/tokyocabinet-1.4.41/THANKS +12 -0
  139. data/ext/tokyocabinet-1.4.41/bros/Makefile +133 -0
  140. data/ext/tokyocabinet-1.4.41/bros/bdbtest.c +438 -0
  141. data/ext/tokyocabinet-1.4.41/bros/cdbtest.c +219 -0
  142. data/ext/tokyocabinet-1.4.41/bros/cmpsqltctest.c +186 -0
  143. data/ext/tokyocabinet-1.4.41/bros/gdbmtest.c +216 -0
  144. data/ext/tokyocabinet-1.4.41/bros/mapreporter +72 -0
  145. data/ext/tokyocabinet-1.4.41/bros/maptest.cc +677 -0
  146. data/ext/tokyocabinet-1.4.41/bros/ndbmtest.c +204 -0
  147. data/ext/tokyocabinet-1.4.41/bros/qdbmtest.c +375 -0
  148. data/ext/tokyocabinet-1.4.41/bros/reporter +141 -0
  149. data/ext/tokyocabinet-1.4.41/bros/result.xls +0 -0
  150. data/ext/tokyocabinet-1.4.41/bros/sdbmtest.c +204 -0
  151. data/ext/tokyocabinet-1.4.41/bros/sqltest.c +404 -0
  152. data/ext/tokyocabinet-1.4.41/bros/tctest.c +748 -0
  153. data/ext/tokyocabinet-1.4.41/bros/tdbtest.c +205 -0
  154. data/ext/tokyocabinet-1.4.41/configure +7402 -0
  155. data/ext/tokyocabinet-1.4.41/configure.in +362 -0
  156. data/ext/tokyocabinet-1.4.41/doc/benchmark.pdf +0 -0
  157. data/ext/tokyocabinet-1.4.41/doc/common.css +211 -0
  158. data/ext/tokyocabinet-1.4.41/doc/icon16.png +0 -0
  159. data/ext/tokyocabinet-1.4.41/doc/index.html +156 -0
  160. data/ext/tokyocabinet-1.4.41/doc/index.ja.html +197 -0
  161. data/ext/tokyocabinet-1.4.41/doc/logo-ja.png +0 -0
  162. data/ext/tokyocabinet-1.4.41/doc/logo.png +0 -0
  163. data/ext/tokyocabinet-1.4.41/doc/spex-en.html +7145 -0
  164. data/ext/tokyocabinet-1.4.41/doc/spex-ja.html +7476 -0
  165. data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.pdf +0 -0
  166. data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.ppt +0 -0
  167. data/ext/tokyocabinet-1.4.41/example/Makefile +113 -0
  168. data/ext/tokyocabinet-1.4.41/example/tcadbex.c +55 -0
  169. data/ext/tokyocabinet-1.4.41/example/tcbdbex.c +64 -0
  170. data/ext/tokyocabinet-1.4.41/example/tcfdbex.c +60 -0
  171. data/ext/tokyocabinet-1.4.41/example/tchdbex.c +60 -0
  172. data/ext/tokyocabinet-1.4.41/example/tctchat.c +97 -0
  173. data/ext/tokyocabinet-1.4.41/example/tctchat.tmpl +141 -0
  174. data/ext/tokyocabinet-1.4.41/example/tctdbex.c +85 -0
  175. data/ext/tokyocabinet-1.4.41/example/tctsearch.c +95 -0
  176. data/ext/tokyocabinet-1.4.41/example/tctsearch.tmpl +122 -0
  177. data/ext/tokyocabinet-1.4.41/example/tcutilex.c +77 -0
  178. data/ext/tokyocabinet-1.4.41/f.tsv +2 -0
  179. data/ext/tokyocabinet-1.4.41/lab/calccomp +118 -0
  180. data/ext/tokyocabinet-1.4.41/lab/datechange +56 -0
  181. data/ext/tokyocabinet-1.4.41/lab/diffcheck +45 -0
  182. data/ext/tokyocabinet-1.4.41/lab/htmltotsv +102 -0
  183. data/ext/tokyocabinet-1.4.41/lab/magic +19 -0
  184. data/ext/tokyocabinet-1.4.41/lab/printenv.cgi +27 -0
  185. data/ext/tokyocabinet-1.4.41/lab/stepcount +26 -0
  186. data/ext/tokyocabinet-1.4.41/lab/stopwatch +61 -0
  187. data/ext/tokyocabinet-1.4.41/lab/tabcheck +43 -0
  188. data/ext/tokyocabinet-1.4.41/lab/wgettsv +239 -0
  189. data/ext/tokyocabinet-1.4.41/lab/widthcheck +57 -0
  190. data/ext/tokyocabinet-1.4.41/man/htmltoman +104 -0
  191. data/ext/tokyocabinet-1.4.41/man/tcadb.3 +676 -0
  192. data/ext/tokyocabinet-1.4.41/man/tcamgr.1 +97 -0
  193. data/ext/tokyocabinet-1.4.41/man/tcamttest.1 +35 -0
  194. data/ext/tokyocabinet-1.4.41/man/tcatest.1 +55 -0
  195. data/ext/tokyocabinet-1.4.41/man/tcbdb.3 +1355 -0
  196. data/ext/tokyocabinet-1.4.41/man/tcbmgr.1 +125 -0
  197. data/ext/tokyocabinet-1.4.41/man/tcbmttest.1 +81 -0
  198. data/ext/tokyocabinet-1.4.41/man/tcbtest.1 +107 -0
  199. data/ext/tokyocabinet-1.4.41/man/tcfdb.3 +975 -0
  200. data/ext/tokyocabinet-1.4.41/man/tcfmgr.1 +98 -0
  201. data/ext/tokyocabinet-1.4.41/man/tcfmttest.1 +62 -0
  202. data/ext/tokyocabinet-1.4.41/man/tcftest.1 +73 -0
  203. data/ext/tokyocabinet-1.4.41/man/tchdb.3 +898 -0
  204. data/ext/tokyocabinet-1.4.41/man/tchmgr.1 +110 -0
  205. data/ext/tokyocabinet-1.4.41/man/tchmttest.1 +85 -0
  206. data/ext/tokyocabinet-1.4.41/man/tchtest.1 +95 -0
  207. data/ext/tokyocabinet-1.4.41/man/tclist.3 +1 -0
  208. data/ext/tokyocabinet-1.4.41/man/tcmap.3 +1 -0
  209. data/ext/tokyocabinet-1.4.41/man/tcmdb.3 +1 -0
  210. data/ext/tokyocabinet-1.4.41/man/tcmpool.3 +1 -0
  211. data/ext/tokyocabinet-1.4.41/man/tctdb.3 +1110 -0
  212. data/ext/tokyocabinet-1.4.41/man/tctmgr.1 +140 -0
  213. data/ext/tokyocabinet-1.4.41/man/tctmttest.1 +92 -0
  214. data/ext/tokyocabinet-1.4.41/man/tctree.3 +1 -0
  215. data/ext/tokyocabinet-1.4.41/man/tcttest.1 +105 -0
  216. data/ext/tokyocabinet-1.4.41/man/tcucodec.1 +162 -0
  217. data/ext/tokyocabinet-1.4.41/man/tcumttest.1 +41 -0
  218. data/ext/tokyocabinet-1.4.41/man/tcutest.1 +81 -0
  219. data/ext/tokyocabinet-1.4.41/man/tcutil.3 +4518 -0
  220. data/ext/tokyocabinet-1.4.41/man/tcxstr.3 +1 -0
  221. data/ext/tokyocabinet-1.4.41/man/tokyocabinet.3 +132 -0
  222. data/ext/tokyocabinet-1.4.41/md5.c +381 -0
  223. data/ext/tokyocabinet-1.4.41/md5.h +101 -0
  224. data/ext/tokyocabinet-1.4.41/myconf.c +493 -0
  225. data/ext/tokyocabinet-1.4.41/myconf.h +549 -0
  226. data/ext/tokyocabinet-1.4.41/tcadb.c +4339 -0
  227. data/ext/tokyocabinet-1.4.41/tcadb.h +548 -0
  228. data/ext/tokyocabinet-1.4.41/tcamgr.c +1019 -0
  229. data/ext/tokyocabinet-1.4.41/tcamttest.c +542 -0
  230. data/ext/tokyocabinet-1.4.41/tcatest.c +1845 -0
  231. data/ext/tokyocabinet-1.4.41/tcawmgr.c +482 -0
  232. data/ext/tokyocabinet-1.4.41/tcbdb.c +4180 -0
  233. data/ext/tokyocabinet-1.4.41/tcbdb.h +1101 -0
  234. data/ext/tokyocabinet-1.4.41/tcbmgr.c +1012 -0
  235. data/ext/tokyocabinet-1.4.41/tcbmttest.c +1810 -0
  236. data/ext/tokyocabinet-1.4.41/tcbtest.c +2586 -0
  237. data/ext/tokyocabinet-1.4.41/tcfdb.c +2746 -0
  238. data/ext/tokyocabinet-1.4.41/tcfdb.h +858 -0
  239. data/ext/tokyocabinet-1.4.41/tcfmgr.c +786 -0
  240. data/ext/tokyocabinet-1.4.41/tcfmttest.c +1220 -0
  241. data/ext/tokyocabinet-1.4.41/tcftest.c +1695 -0
  242. data/ext/tokyocabinet-1.4.41/tchdb.c +5153 -0
  243. data/ext/tokyocabinet-1.4.41/tchdb.h +871 -0
  244. data/ext/tokyocabinet-1.4.41/tchmgr.c +842 -0
  245. data/ext/tokyocabinet-1.4.41/tchmttest.c +1757 -0
  246. data/ext/tokyocabinet-1.4.41/tchtest.c +2129 -0
  247. data/ext/tokyocabinet-1.4.41/tctdb.c +6199 -0
  248. data/ext/tokyocabinet-1.4.41/tctdb.h +1086 -0
  249. data/ext/tokyocabinet-1.4.41/tctmgr.c +1241 -0
  250. data/ext/tokyocabinet-1.4.41/tctmttest.c +1563 -0
  251. data/ext/tokyocabinet-1.4.41/tcttest.c +2062 -0
  252. data/ext/tokyocabinet-1.4.41/tcucodec.c +1357 -0
  253. data/ext/tokyocabinet-1.4.41/tcumttest.c +578 -0
  254. data/ext/tokyocabinet-1.4.41/tcutest.c +1875 -0
  255. data/ext/tokyocabinet-1.4.41/tcutil.c +10528 -0
  256. data/ext/tokyocabinet-1.4.41/tcutil.h +4184 -0
  257. data/ext/tokyocabinet-1.4.41/tokyocabinet.idl +336 -0
  258. data/ext/tokyocabinet-1.4.41/tokyocabinet.pc.in +14 -0
  259. data/ext/tokyotyrant-1.1.39/COPYING +504 -0
  260. data/ext/tokyotyrant-1.1.39/ChangeLog +578 -0
  261. data/ext/tokyotyrant-1.1.39/Makefile.in +365 -0
  262. data/ext/tokyotyrant-1.1.39/README +38 -0
  263. data/ext/tokyotyrant-1.1.39/THANKS +15 -0
  264. data/ext/tokyotyrant-1.1.39/configure +6979 -0
  265. data/ext/tokyotyrant-1.1.39/configure.in +300 -0
  266. data/ext/tokyotyrant-1.1.39/doc/common.css +211 -0
  267. data/ext/tokyotyrant-1.1.39/doc/index.html +79 -0
  268. data/ext/tokyotyrant-1.1.39/doc/spex.html +2264 -0
  269. data/ext/tokyotyrant-1.1.39/example/Makefile +68 -0
  270. data/ext/tokyotyrant-1.1.39/example/httptest.pl +88 -0
  271. data/ext/tokyotyrant-1.1.39/example/mcftest.pl +39 -0
  272. data/ext/tokyotyrant-1.1.39/example/mctest.pl +43 -0
  273. data/ext/tokyotyrant-1.1.39/example/tcrdbex +0 -0
  274. data/ext/tokyotyrant-1.1.39/example/tcrdbex.c +49 -0
  275. data/ext/tokyotyrant-1.1.39/example/tcrdbex.o +0 -0
  276. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex +0 -0
  277. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.c +79 -0
  278. data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.o +0 -0
  279. data/ext/tokyotyrant-1.1.39/ext/mapreduce.lua +57 -0
  280. data/ext/tokyotyrant-1.1.39/ext/queue.lua +55 -0
  281. data/ext/tokyotyrant-1.1.39/ext/senatus.lua +532 -0
  282. data/ext/tokyotyrant-1.1.39/ext/usherette.lua +438 -0
  283. data/ext/tokyotyrant-1.1.39/lab/datechange +56 -0
  284. data/ext/tokyotyrant-1.1.39/lab/diffcheck +45 -0
  285. data/ext/tokyotyrant-1.1.39/lab/fibonacci.lua +20 -0
  286. data/ext/tokyotyrant-1.1.39/lab/footprint.lua +67 -0
  287. data/ext/tokyotyrant-1.1.39/lab/highlow.lua +88 -0
  288. data/ext/tokyotyrant-1.1.39/lab/killdualmaster +12 -0
  289. data/ext/tokyotyrant-1.1.39/lab/rundualmaster +38 -0
  290. data/ext/tokyotyrant-1.1.39/lab/stepcount +26 -0
  291. data/ext/tokyotyrant-1.1.39/lab/tabcheck +43 -0
  292. data/ext/tokyotyrant-1.1.39/lab/ushrtregister.pl +55 -0
  293. data/ext/tokyotyrant-1.1.39/lab/widthcheck +57 -0
  294. data/ext/tokyotyrant-1.1.39/man/htmltoman +100 -0
  295. data/ext/tokyotyrant-1.1.39/man/tcrdb.3 +1309 -0
  296. data/ext/tokyotyrant-1.1.39/man/tcrmgr.1 +164 -0
  297. data/ext/tokyotyrant-1.1.39/man/tcrmttest.1 +55 -0
  298. data/ext/tokyotyrant-1.1.39/man/tcrtest.1 +89 -0
  299. data/ext/tokyotyrant-1.1.39/man/tculog.3 +15 -0
  300. data/ext/tokyotyrant-1.1.39/man/ttservctl.8 +37 -0
  301. data/ext/tokyotyrant-1.1.39/man/ttserver.1 +84 -0
  302. data/ext/tokyotyrant-1.1.39/man/ttulmgr.1 +40 -0
  303. data/ext/tokyotyrant-1.1.39/man/ttultest.1 +16 -0
  304. data/ext/tokyotyrant-1.1.39/man/ttutil.3 +14 -0
  305. data/ext/tokyotyrant-1.1.39/myconf.c +169 -0
  306. data/ext/tokyotyrant-1.1.39/myconf.h +408 -0
  307. data/ext/tokyotyrant-1.1.39/scrext.c +2394 -0
  308. data/ext/tokyotyrant-1.1.39/scrext.h +96 -0
  309. data/ext/tokyotyrant-1.1.39/tcrdb.c +2637 -0
  310. data/ext/tokyotyrant-1.1.39/tcrdb.h +801 -0
  311. data/ext/tokyotyrant-1.1.39/tcrmgr.c +1559 -0
  312. data/ext/tokyotyrant-1.1.39/tcrmttest.c +915 -0
  313. data/ext/tokyotyrant-1.1.39/tcrtest.c +1542 -0
  314. data/ext/tokyotyrant-1.1.39/tculog.c +1211 -0
  315. data/ext/tokyotyrant-1.1.39/tculog.h +392 -0
  316. data/ext/tokyotyrant-1.1.39/tokyotyrant.idl +143 -0
  317. data/ext/tokyotyrant-1.1.39/tokyotyrant.pc.in +14 -0
  318. data/ext/tokyotyrant-1.1.39/ttservctl +163 -0
  319. data/ext/tokyotyrant-1.1.39/ttserver.c +3583 -0
  320. data/ext/tokyotyrant-1.1.39/ttskeldir.c +141 -0
  321. data/ext/tokyotyrant-1.1.39/ttskelmock.c +64 -0
  322. data/ext/tokyotyrant-1.1.39/ttskelnull.c +79 -0
  323. data/ext/tokyotyrant-1.1.39/ttskelproxy.c +74 -0
  324. data/ext/tokyotyrant-1.1.39/ttulmgr.c +266 -0
  325. data/ext/tokyotyrant-1.1.39/ttultest.c +371 -0
  326. data/ext/tokyotyrant-1.1.39/ttutil.c +1510 -0
  327. data/ext/tokyotyrant-1.1.39/ttutil.h +494 -0
  328. data/lib/tokyo_tyrant/balancer.rb +189 -0
  329. data/spec/ext.lua +4 -0
  330. data/spec/plu_db.rb +538 -0
  331. data/spec/spec.rb +1 -0
  332. data/spec/spec_base.rb +17 -0
  333. data/spec/start_tyrants.sh +36 -0
  334. data/spec/stop_tyrants.sh +9 -0
  335. data/spec/tokyo_tyrant_balancer_db_spec.rb +160 -0
  336. data/spec/tokyo_tyrant_balancer_table_spec.rb +177 -0
  337. data/spec/tokyo_tyrant_query_spec.rb +159 -0
  338. data/spec/tokyo_tyrant_spec.rb +254 -0
  339. data/spec/tokyo_tyrant_table_spec.rb +301 -0
  340. metadata +402 -0
@@ -0,0 +1,1012 @@
1
+ /*************************************************************************************************
2
+ * The command line utility of the B+ tree 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 "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(TCBDB *bdb);
31
+ static int printdata(const char *ptr, int size, bool px);
32
+ static char *mygetline(FILE *ifp);
33
+ static int mycmpfunc(const char *aptr, int asiz, const char *bptr, int bsiz, void *op);
34
+ static int runcreate(int argc, char **argv);
35
+ static int runinform(int argc, char **argv);
36
+ static int runput(int argc, char **argv);
37
+ static int runout(int argc, char **argv);
38
+ static int runget(int argc, char **argv);
39
+ static int runlist(int argc, char **argv);
40
+ static int runoptimize(int argc, char **argv);
41
+ static int runimporttsv(int argc, char **argv);
42
+ static int runversion(int argc, char **argv);
43
+ static int proccreate(const char *path, int lmemb, int nmemb,
44
+ int bnum, int apow, int fpow, TCCMP cmp, int opts);
45
+ static int procinform(const char *path, int omode);
46
+ static int procput(const char *path, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
47
+ TCCMP cmp, int omode, int dmode);
48
+ static int procout(const char *path, const char *kbuf, int ksiz, TCCMP cmp, int omode);
49
+ static int procget(const char *path, const char *kbuf, int ksiz, TCCMP cmp, int omode,
50
+ bool px, bool pz);
51
+ static int proclist(const char *path, TCCMP cmp, int omode, int max, bool pv, bool px, bool bk,
52
+ const char *jstr, const char *bstr, const char *estr, const char *fmstr);
53
+ static int procoptimize(const char *path, int lmemb, int nmemb,
54
+ int bnum, int apow, int fpow, TCCMP cmp, int opts, int omode, bool df);
55
+ static int procimporttsv(const char *path, const char *file, int omode, bool sc);
56
+ static int procversion(void);
57
+
58
+
59
+ /* main routine */
60
+ int main(int argc, char **argv){
61
+ g_progname = argv[0];
62
+ g_dbgfd = -1;
63
+ const char *ebuf = getenv("TCDBGFD");
64
+ if(ebuf) g_dbgfd = tcatoix(ebuf);
65
+ if(argc < 2) usage();
66
+ int rv = 0;
67
+ if(!strcmp(argv[1], "create")){
68
+ rv = runcreate(argc, argv);
69
+ } else if(!strcmp(argv[1], "inform")){
70
+ rv = runinform(argc, argv);
71
+ } else if(!strcmp(argv[1], "put")){
72
+ rv = runput(argc, argv);
73
+ } else if(!strcmp(argv[1], "out")){
74
+ rv = runout(argc, argv);
75
+ } else if(!strcmp(argv[1], "get")){
76
+ rv = runget(argc, argv);
77
+ } else if(!strcmp(argv[1], "list")){
78
+ rv = runlist(argc, argv);
79
+ } else if(!strcmp(argv[1], "optimize")){
80
+ rv = runoptimize(argc, argv);
81
+ } else if(!strcmp(argv[1], "importtsv")){
82
+ rv = runimporttsv(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 B+ tree database API\n", g_progname);
95
+ fprintf(stderr, "\n");
96
+ fprintf(stderr, "usage:\n");
97
+ fprintf(stderr, " %s create [-cd|-ci|-cj] [-tl] [-td|-tb|-tt|-tx] path"
98
+ " [lmemb [nmemb [bnum [apow [fpow]]]]]\n", g_progname);
99
+ fprintf(stderr, " %s inform [-nl|-nb] path\n", g_progname);
100
+ fprintf(stderr, " %s put [-cd|-ci|-cj] [-nl|-nb] [-sx] [-dk|-dc|-dd|-db|-dai|-dad] path"
101
+ " key value\n", g_progname);
102
+ fprintf(stderr, " %s out [-cd|-ci|-cj] [-nl|-nb] [-sx] path key\n", g_progname);
103
+ fprintf(stderr, " %s get [-cd|-ci|-cj] [-nl|-nb] [-sx] [-px] [-pz] path key\n", g_progname);
104
+ fprintf(stderr, " %s list [-cd|-ci|-cj] [-nl|-nb] [-m num] [-bk] [-pv] [-px] [-j str]"
105
+ " [-rb bkey ekey] [-fm str] path\n", g_progname);
106
+ fprintf(stderr, " %s optimize [-cd|-ci|-cj] [-tl] [-td|-tb|-tt|-tx] [-tz] [-nl|-nb] [-df]"
107
+ " path [lmemb [nmemb [bnum [apow [fpow]]]]]\n", g_progname);
108
+ fprintf(stderr, " %s importtsv [-nl|-nb] [-sc] path [file]\n", g_progname);
109
+ fprintf(stderr, " %s version\n", g_progname);
110
+ fprintf(stderr, "\n");
111
+ exit(1);
112
+ }
113
+
114
+
115
+ /* print error information */
116
+ static void printerr(TCBDB *bdb){
117
+ const char *path = tcbdbpath(bdb);
118
+ int ecode = tcbdbecode(bdb);
119
+ fprintf(stderr, "%s: %s: %d: %s\n", g_progname, path ? path : "-", ecode, tcbdberrmsg(ecode));
120
+ }
121
+
122
+
123
+ /* print record data */
124
+ static int printdata(const char *ptr, int size, bool px){
125
+ int len = 0;
126
+ while(size-- > 0){
127
+ if(px){
128
+ if(len > 0) putchar(' ');
129
+ len += printf("%02X", *(unsigned char *)ptr);
130
+ } else {
131
+ putchar(*ptr);
132
+ len++;
133
+ }
134
+ ptr++;
135
+ }
136
+ return len;
137
+ }
138
+
139
+
140
+ /* read a line from a file descriptor */
141
+ static char *mygetline(FILE *ifp){
142
+ int len = 0;
143
+ int blen = 1024;
144
+ char *buf = tcmalloc(blen);
145
+ bool end = true;
146
+ int c;
147
+ while((c = fgetc(ifp)) != EOF){
148
+ end = false;
149
+ if(c == '\0') continue;
150
+ if(blen <= len){
151
+ blen *= 2;
152
+ buf = tcrealloc(buf, blen + 1);
153
+ }
154
+ if(c == '\n' || c == '\r') c = '\0';
155
+ buf[len++] = c;
156
+ if(c == '\0') break;
157
+ }
158
+ if(end){
159
+ tcfree(buf);
160
+ return NULL;
161
+ }
162
+ buf[len] = '\0';
163
+ return buf;
164
+ }
165
+
166
+
167
+ /* dummy comparison function */
168
+ static int mycmpfunc(const char *aptr, int asiz, const char *bptr, int bsiz, void *op){
169
+ return 0;
170
+ }
171
+
172
+
173
+ /* parse arguments of create command */
174
+ static int runcreate(int argc, char **argv){
175
+ char *path = NULL;
176
+ char *lmstr = NULL;
177
+ char *nmstr = NULL;
178
+ char *bstr = NULL;
179
+ char *astr = NULL;
180
+ char *fstr = NULL;
181
+ TCCMP cmp = NULL;
182
+ int opts = 0;
183
+ for(int i = 2; i < argc; i++){
184
+ if(!path && argv[i][0] == '-'){
185
+ if(!strcmp(argv[i], "-cd")){
186
+ cmp = tccmpdecimal;
187
+ } else if(!strcmp(argv[i], "-ci")){
188
+ cmp = tccmpint32;
189
+ } else if(!strcmp(argv[i], "-cj")){
190
+ cmp = tccmpint64;
191
+ } else if(!strcmp(argv[i], "-tl")){
192
+ opts |= BDBTLARGE;
193
+ } else if(!strcmp(argv[i], "-td")){
194
+ opts |= BDBTDEFLATE;
195
+ } else if(!strcmp(argv[i], "-tb")){
196
+ opts |= BDBTBZIP;
197
+ } else if(!strcmp(argv[i], "-tt")){
198
+ opts |= BDBTTCBS;
199
+ } else if(!strcmp(argv[i], "-tx")){
200
+ opts |= BDBTEXCODEC;
201
+ } else {
202
+ usage();
203
+ }
204
+ } else if(!path){
205
+ path = argv[i];
206
+ } else if(!lmstr){
207
+ lmstr = argv[i];
208
+ } else if(!nmstr){
209
+ nmstr = argv[i];
210
+ } else if(!bstr){
211
+ bstr = argv[i];
212
+ } else if(!astr){
213
+ astr = argv[i];
214
+ } else if(!fstr){
215
+ fstr = argv[i];
216
+ } else {
217
+ usage();
218
+ }
219
+ }
220
+ if(!path) usage();
221
+ int lmemb = lmstr ? tcatoix(lmstr) : -1;
222
+ int nmemb = nmstr ? tcatoix(nmstr) : -1;
223
+ int bnum = bstr ? tcatoix(bstr) : -1;
224
+ int apow = astr ? tcatoix(astr) : -1;
225
+ int fpow = fstr ? tcatoix(fstr) : -1;
226
+ int rv = proccreate(path, lmemb, nmemb, bnum, apow, fpow, cmp, opts);
227
+ return rv;
228
+ }
229
+
230
+
231
+ /* parse arguments of inform command */
232
+ static int runinform(int argc, char **argv){
233
+ char *path = NULL;
234
+ int omode = 0;
235
+ for(int i = 2; i < argc; i++){
236
+ if(!path && argv[i][0] == '-'){
237
+ if(!strcmp(argv[i], "-nl")){
238
+ omode |= BDBONOLCK;
239
+ } else if(!strcmp(argv[i], "-nb")){
240
+ omode |= BDBOLCKNB;
241
+ } else {
242
+ usage();
243
+ }
244
+ } else if(!path){
245
+ path = argv[i];
246
+ } else {
247
+ usage();
248
+ }
249
+ }
250
+ if(!path) usage();
251
+ int rv = procinform(path, omode);
252
+ return rv;
253
+ }
254
+
255
+
256
+ /* parse arguments of put command */
257
+ static int runput(int argc, char **argv){
258
+ char *path = NULL;
259
+ char *key = NULL;
260
+ char *value = NULL;
261
+ TCCMP cmp = NULL;
262
+ int omode = 0;
263
+ int dmode = 0;
264
+ bool sx = false;
265
+ for(int i = 2; i < argc; i++){
266
+ if(!path && argv[i][0] == '-'){
267
+ if(!strcmp(argv[i], "-cd")){
268
+ cmp = tccmpdecimal;
269
+ } else if(!strcmp(argv[i], "-ci")){
270
+ cmp = tccmpint32;
271
+ } else if(!strcmp(argv[i], "-cj")){
272
+ cmp = tccmpint64;
273
+ } else if(!strcmp(argv[i], "-nl")){
274
+ omode |= BDBONOLCK;
275
+ } else if(!strcmp(argv[i], "-nb")){
276
+ omode |= BDBOLCKNB;
277
+ } else if(!strcmp(argv[i], "-dk")){
278
+ dmode = -1;
279
+ } else if(!strcmp(argv[i], "-dc")){
280
+ dmode = 1;
281
+ } else if(!strcmp(argv[i], "-dd")){
282
+ dmode = 2;
283
+ } else if(!strcmp(argv[i], "-db")){
284
+ dmode = 3;
285
+ } else if(!strcmp(argv[i], "-dai")){
286
+ dmode = 10;
287
+ } else if(!strcmp(argv[i], "-dad")){
288
+ dmode = 11;
289
+ } else if(!strcmp(argv[i], "-sx")){
290
+ sx = true;
291
+ } else {
292
+ usage();
293
+ }
294
+ } else if(!path){
295
+ path = argv[i];
296
+ } else if(!key){
297
+ key = argv[i];
298
+ } else if(!value){
299
+ value = argv[i];
300
+ } else {
301
+ usage();
302
+ }
303
+ }
304
+ if(!path || !key || !value) usage();
305
+ char *kbuf, *vbuf;
306
+ int ksiz, vsiz;
307
+ if(sx){
308
+ kbuf = tchexdecode(key, &ksiz);
309
+ vbuf = tchexdecode(value, &vsiz);
310
+ } else {
311
+ ksiz = strlen(key);
312
+ kbuf = tcmemdup(key, ksiz);
313
+ vsiz = strlen(value);
314
+ vbuf = tcmemdup(value, vsiz);
315
+ }
316
+ int rv = procput(path, kbuf, ksiz, vbuf, vsiz, cmp, omode, dmode);
317
+ tcfree(vbuf);
318
+ tcfree(kbuf);
319
+ return rv;
320
+ }
321
+
322
+
323
+ /* parse arguments of out command */
324
+ static int runout(int argc, char **argv){
325
+ char *path = NULL;
326
+ char *key = NULL;
327
+ TCCMP cmp = NULL;
328
+ int omode = 0;
329
+ bool sx = false;
330
+ for(int i = 2; i < argc; i++){
331
+ if(!path && argv[i][0] == '-'){
332
+ if(!strcmp(argv[i], "-cd")){
333
+ cmp = tccmpdecimal;
334
+ } else if(!strcmp(argv[i], "-ci")){
335
+ cmp = tccmpint32;
336
+ } else if(!strcmp(argv[i], "-cj")){
337
+ cmp = tccmpint64;
338
+ } else if(!strcmp(argv[i], "-nl")){
339
+ omode |= BDBONOLCK;
340
+ } else if(!strcmp(argv[i], "-nb")){
341
+ omode |= BDBOLCKNB;
342
+ } else if(!strcmp(argv[i], "-sx")){
343
+ sx = 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 = procout(path, kbuf, ksiz, cmp, omode);
365
+ tcfree(kbuf);
366
+ return rv;
367
+ }
368
+
369
+
370
+ /* parse arguments of get command */
371
+ static int runget(int argc, char **argv){
372
+ char *path = NULL;
373
+ char *key = NULL;
374
+ TCCMP cmp = NULL;
375
+ int omode = 0;
376
+ bool sx = false;
377
+ bool px = false;
378
+ bool pz = false;
379
+ for(int i = 2; i < argc; i++){
380
+ if(!path && argv[i][0] == '-'){
381
+ if(!strcmp(argv[i], "-cd")){
382
+ cmp = tccmpdecimal;
383
+ } else if(!strcmp(argv[i], "-ci")){
384
+ cmp = tccmpint32;
385
+ } else if(!strcmp(argv[i], "-cj")){
386
+ cmp = tccmpint64;
387
+ } else if(!strcmp(argv[i], "-nl")){
388
+ omode |= BDBONOLCK;
389
+ } else if(!strcmp(argv[i], "-nb")){
390
+ omode |= BDBOLCKNB;
391
+ } else if(!strcmp(argv[i], "-sx")){
392
+ sx = true;
393
+ } else if(!strcmp(argv[i], "-px")){
394
+ px = true;
395
+ } else if(!strcmp(argv[i], "-pz")){
396
+ pz = true;
397
+ } else {
398
+ usage();
399
+ }
400
+ } else if(!path){
401
+ path = argv[i];
402
+ } else if(!key){
403
+ key = argv[i];
404
+ } else {
405
+ usage();
406
+ }
407
+ }
408
+ if(!path || !key) usage();
409
+ int ksiz;
410
+ char *kbuf;
411
+ if(sx){
412
+ kbuf = tchexdecode(key, &ksiz);
413
+ } else {
414
+ ksiz = strlen(key);
415
+ kbuf = tcmemdup(key, ksiz);
416
+ }
417
+ int rv = procget(path, kbuf, ksiz, cmp, omode, px, pz);
418
+ tcfree(kbuf);
419
+ return rv;
420
+ }
421
+
422
+
423
+ /* parse arguments of list command */
424
+ static int runlist(int argc, char **argv){
425
+ char *path = NULL;
426
+ TCCMP cmp = NULL;
427
+ int omode = 0;
428
+ int max = -1;
429
+ bool pv = false;
430
+ bool px = false;
431
+ bool bk = false;
432
+ char *jstr = NULL;
433
+ char *bstr = NULL;
434
+ char *estr = NULL;
435
+ char *fmstr = NULL;
436
+ for(int i = 2; i < argc; i++){
437
+ if(!path && argv[i][0] == '-'){
438
+ if(!strcmp(argv[i], "-cd")){
439
+ cmp = tccmpdecimal;
440
+ } else if(!strcmp(argv[i], "-ci")){
441
+ cmp = tccmpint32;
442
+ } else if(!strcmp(argv[i], "-cj")){
443
+ cmp = tccmpint64;
444
+ } else if(!strcmp(argv[i], "-nl")){
445
+ omode |= BDBONOLCK;
446
+ } else if(!strcmp(argv[i], "-nb")){
447
+ omode |= BDBOLCKNB;
448
+ } else if(!strcmp(argv[i], "-m")){
449
+ if(++i >= argc) usage();
450
+ max = tcatoix(argv[i]);
451
+ } else if(!strcmp(argv[i], "-bk")){
452
+ bk = true;
453
+ } else if(!strcmp(argv[i], "-pv")){
454
+ pv = true;
455
+ } else if(!strcmp(argv[i], "-px")){
456
+ px = true;
457
+ } else if(!strcmp(argv[i], "-j")){
458
+ if(++i >= argc) usage();
459
+ jstr = argv[i];
460
+ } else if(!strcmp(argv[i], "-rb")){
461
+ if(++i >= argc) usage();
462
+ bstr = argv[i];
463
+ if(++i >= argc) usage();
464
+ estr = argv[i];
465
+ } else if(!strcmp(argv[i], "-fm")){
466
+ if(++i >= argc) usage();
467
+ fmstr = argv[i];
468
+ } else {
469
+ usage();
470
+ }
471
+ } else if(!path){
472
+ path = argv[i];
473
+ } else {
474
+ usage();
475
+ }
476
+ }
477
+ if(!path) usage();
478
+ int rv = proclist(path, cmp, omode, max, pv, px, bk, jstr, bstr, estr, fmstr);
479
+ return rv;
480
+ }
481
+
482
+
483
+ /* parse arguments of optimize command */
484
+ static int runoptimize(int argc, char **argv){
485
+ char *path = NULL;
486
+ char *lmstr = NULL;
487
+ char *nmstr = NULL;
488
+ char *bstr = NULL;
489
+ char *astr = NULL;
490
+ char *fstr = NULL;
491
+ TCCMP cmp = NULL;
492
+ int opts = UINT8_MAX;
493
+ int omode = 0;
494
+ bool df = false;
495
+ for(int i = 2; i < argc; i++){
496
+ if(!path && argv[i][0] == '-'){
497
+ if(!strcmp(argv[i], "-cd")){
498
+ cmp = tccmpdecimal;
499
+ } else if(!strcmp(argv[i], "-ci")){
500
+ cmp = tccmpint32;
501
+ } else if(!strcmp(argv[i], "-cj")){
502
+ cmp = tccmpint64;
503
+ } else if(!strcmp(argv[i], "-tl")){
504
+ if(opts == UINT8_MAX) opts = 0;
505
+ opts |= BDBTLARGE;
506
+ } else if(!strcmp(argv[i], "-td")){
507
+ if(opts == UINT8_MAX) opts = 0;
508
+ opts |= BDBTDEFLATE;
509
+ } else if(!strcmp(argv[i], "-tb")){
510
+ if(opts == UINT8_MAX) opts = 0;
511
+ opts |= BDBTBZIP;
512
+ } else if(!strcmp(argv[i], "-tt")){
513
+ if(opts == UINT8_MAX) opts = 0;
514
+ opts |= BDBTTCBS;
515
+ } else if(!strcmp(argv[i], "-tx")){
516
+ if(opts == UINT8_MAX) opts = 0;
517
+ opts |= BDBTEXCODEC;
518
+ } else if(!strcmp(argv[i], "-tz")){
519
+ if(opts == UINT8_MAX) opts = 0;
520
+ } else if(!strcmp(argv[i], "-nl")){
521
+ omode |= BDBONOLCK;
522
+ } else if(!strcmp(argv[i], "-nb")){
523
+ omode |= BDBOLCKNB;
524
+ } else if(!strcmp(argv[i], "-df")){
525
+ df = true;
526
+ } else {
527
+ usage();
528
+ }
529
+ } else if(!path){
530
+ path = argv[i];
531
+ } else if(!lmstr){
532
+ lmstr = argv[i];
533
+ } else if(!nmstr){
534
+ nmstr = argv[i];
535
+ } else if(!bstr){
536
+ bstr = argv[i];
537
+ } else if(!astr){
538
+ astr = argv[i];
539
+ } else if(!fstr){
540
+ fstr = argv[i];
541
+ } else {
542
+ usage();
543
+ }
544
+ }
545
+ if(!path) usage();
546
+ int lmemb = lmstr ? tcatoix(lmstr) : -1;
547
+ int nmemb = nmstr ? tcatoix(nmstr) : -1;
548
+ int bnum = bstr ? tcatoix(bstr) : -1;
549
+ int apow = astr ? tcatoix(astr) : -1;
550
+ int fpow = fstr ? tcatoix(fstr) : -1;
551
+ int rv = procoptimize(path, lmemb, nmemb, bnum, apow, fpow, cmp, opts, omode, df);
552
+ return rv;
553
+ }
554
+
555
+
556
+ /* parse arguments of importtsv command */
557
+ static int runimporttsv(int argc, char **argv){
558
+ char *path = NULL;
559
+ char *file = NULL;
560
+ int omode = 0;
561
+ bool sc = false;
562
+ for(int i = 2; i < argc; i++){
563
+ if(!path && argv[i][0] == '-'){
564
+ if(!strcmp(argv[i], "-nl")){
565
+ omode |= BDBONOLCK;
566
+ } else if(!strcmp(argv[i], "-nb")){
567
+ omode |= BDBOLCKNB;
568
+ } else if(!strcmp(argv[i], "-sc")){
569
+ sc = true;
570
+ } else {
571
+ usage();
572
+ }
573
+ } else if(!path){
574
+ path = argv[i];
575
+ } else if(!file){
576
+ file = argv[i];
577
+ } else {
578
+ usage();
579
+ }
580
+ }
581
+ if(!path) usage();
582
+ int rv = procimporttsv(path, file, omode, sc);
583
+ return rv;
584
+ }
585
+
586
+
587
+ /* parse arguments of version command */
588
+ static int runversion(int argc, char **argv){
589
+ int rv = procversion();
590
+ return rv;
591
+ }
592
+
593
+
594
+ /* perform create command */
595
+ static int proccreate(const char *path, int lmemb, int nmemb,
596
+ int bnum, int apow, int fpow, TCCMP cmp, int opts){
597
+ TCBDB *bdb = tcbdbnew();
598
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
599
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
600
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
601
+ if(!tcbdbtune(bdb, lmemb, nmemb, bnum, apow, fpow, opts)){
602
+ printerr(bdb);
603
+ tcbdbdel(bdb);
604
+ return 1;
605
+ }
606
+ if(!tcbdbopen(bdb, path, BDBOWRITER | BDBOCREAT | BDBOTRUNC)){
607
+ printerr(bdb);
608
+ tcbdbdel(bdb);
609
+ return 1;
610
+ }
611
+ bool err = false;
612
+ if(!tcbdbclose(bdb)){
613
+ printerr(bdb);
614
+ err = true;
615
+ }
616
+ tcbdbdel(bdb);
617
+ return err ? 1 : 0;
618
+ }
619
+
620
+
621
+ /* perform inform command */
622
+ static int procinform(const char *path, int omode){
623
+ TCBDB *bdb = tcbdbnew();
624
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
625
+ tcbdbsetcmpfunc(bdb, mycmpfunc, NULL);
626
+ tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL);
627
+ if(!tcbdbopen(bdb, path, BDBOREADER | omode)){
628
+ printerr(bdb);
629
+ tcbdbdel(bdb);
630
+ return 1;
631
+ }
632
+ bool err = false;
633
+ const char *npath = tcbdbpath(bdb);
634
+ if(!npath) npath = "(unknown)";
635
+ printf("path: %s\n", npath);
636
+ printf("database type: btree\n");
637
+ uint8_t flags = tcbdbflags(bdb);
638
+ printf("additional flags:");
639
+ if(flags & BDBFOPEN) printf(" open");
640
+ if(flags & BDBFFATAL) printf(" fatal");
641
+ printf("\n");
642
+ TCCMP cmp = tcbdbcmpfunc(bdb);
643
+ printf("comparison function: ");
644
+ if(cmp == tccmplexical){
645
+ printf("lexical");
646
+ } else if(cmp == tccmpdecimal){
647
+ printf("decimal");
648
+ } else if(cmp == tccmpint32){
649
+ printf("int32");
650
+ } else if(cmp == tccmpint64){
651
+ printf("int64");
652
+ } else {
653
+ printf("custom");
654
+ }
655
+ printf("\n");
656
+ printf("max leaf member: %d\n", tcbdblmemb(bdb));
657
+ printf("max node member: %d\n", tcbdbnmemb(bdb));
658
+ printf("leaf number: %llu\n", (unsigned long long)tcbdblnum(bdb));
659
+ printf("node number: %llu\n", (unsigned long long)tcbdbnnum(bdb));
660
+ printf("bucket number: %llu\n", (unsigned long long)tcbdbbnum(bdb));
661
+ if(bdb->hdb->cnt_writerec >= 0)
662
+ printf("used bucket number: %lld\n", (long long)tcbdbbnumused(bdb));
663
+ printf("alignment: %u\n", tcbdbalign(bdb));
664
+ printf("free block pool: %u\n", tcbdbfbpmax(bdb));
665
+ printf("inode number: %lld\n", (long long)tcbdbinode(bdb));
666
+ char date[48];
667
+ tcdatestrwww(tcbdbmtime(bdb), INT_MAX, date);
668
+ printf("modified time: %s\n", date);
669
+ uint8_t opts = tcbdbopts(bdb);
670
+ printf("options:");
671
+ if(opts & BDBTLARGE) printf(" large");
672
+ if(opts & BDBTDEFLATE) printf(" deflate");
673
+ if(opts & BDBTBZIP) printf(" bzip");
674
+ if(opts & BDBTTCBS) printf(" tcbs");
675
+ if(opts & BDBTEXCODEC) printf(" excodec");
676
+ printf("\n");
677
+ printf("record number: %llu\n", (unsigned long long)tcbdbrnum(bdb));
678
+ printf("file size: %llu\n", (unsigned long long)tcbdbfsiz(bdb));
679
+ if(!tcbdbclose(bdb)){
680
+ if(!err) printerr(bdb);
681
+ err = true;
682
+ }
683
+ tcbdbdel(bdb);
684
+ return err ? 1 : 0;
685
+ }
686
+
687
+
688
+ /* perform put command */
689
+ static int procput(const char *path, const char *kbuf, int ksiz, const char *vbuf, int vsiz,
690
+ TCCMP cmp, int omode, int dmode){
691
+ TCBDB *bdb = tcbdbnew();
692
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
693
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
694
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
695
+ if(!tcbdbopen(bdb, path, BDBOWRITER | omode)){
696
+ printerr(bdb);
697
+ tcbdbdel(bdb);
698
+ return 1;
699
+ }
700
+ bool err = false;
701
+ switch(dmode){
702
+ case -1:
703
+ if(!tcbdbputkeep(bdb, kbuf, ksiz, vbuf, vsiz)){
704
+ printerr(bdb);
705
+ err = true;
706
+ }
707
+ break;
708
+ case 1:
709
+ if(!tcbdbputcat(bdb, kbuf, ksiz, vbuf, vsiz)){
710
+ printerr(bdb);
711
+ err = true;
712
+ }
713
+ break;
714
+ case 2:
715
+ if(!tcbdbputdup(bdb, kbuf, ksiz, vbuf, vsiz)){
716
+ printerr(bdb);
717
+ err = true;
718
+ }
719
+ break;
720
+ case 3:
721
+ if(!tcbdbputdupback(bdb, kbuf, ksiz, vbuf, vsiz)){
722
+ printerr(bdb);
723
+ err = true;
724
+ }
725
+ break;
726
+ case 10:
727
+ if(tcbdbaddint(bdb, kbuf, ksiz, tcatoi(vbuf)) == INT_MIN){
728
+ printerr(bdb);
729
+ err = true;
730
+ }
731
+ break;
732
+ case 11:
733
+ if(isnan(tcbdbadddouble(bdb, kbuf, ksiz, tcatof(vbuf)))){
734
+ printerr(bdb);
735
+ err = true;
736
+ }
737
+ break;
738
+ default:
739
+ if(!tcbdbput(bdb, kbuf, ksiz, vbuf, vsiz)){
740
+ printerr(bdb);
741
+ err = true;
742
+ }
743
+ break;
744
+ }
745
+ if(!tcbdbclose(bdb)){
746
+ if(!err) printerr(bdb);
747
+ err = true;
748
+ }
749
+ tcbdbdel(bdb);
750
+ return err ? 1 : 0;
751
+ }
752
+
753
+
754
+ /* perform out command */
755
+ static int procout(const char *path, const char *kbuf, int ksiz, TCCMP cmp, int omode){
756
+ TCBDB *bdb = tcbdbnew();
757
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
758
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
759
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
760
+ if(!tcbdbopen(bdb, path, BDBOWRITER | omode)){
761
+ printerr(bdb);
762
+ tcbdbdel(bdb);
763
+ return 1;
764
+ }
765
+ bool err = false;
766
+ if(!tcbdbout(bdb, kbuf, ksiz)){
767
+ printerr(bdb);
768
+ err = true;
769
+ }
770
+ if(!tcbdbclose(bdb)){
771
+ if(!err) printerr(bdb);
772
+ err = true;
773
+ }
774
+ tcbdbdel(bdb);
775
+ return err ? 1 : 0;
776
+ }
777
+
778
+
779
+ /* perform get command */
780
+ static int procget(const char *path, const char *kbuf, int ksiz, TCCMP cmp, int omode,
781
+ bool px, bool pz){
782
+ TCBDB *bdb = tcbdbnew();
783
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
784
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
785
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
786
+ if(!tcbdbopen(bdb, path, BDBOREADER | omode)){
787
+ printerr(bdb);
788
+ tcbdbdel(bdb);
789
+ return 1;
790
+ }
791
+ bool err = false;
792
+ int vsiz;
793
+ char *vbuf = tcbdbget(bdb, kbuf, ksiz, &vsiz);
794
+ if(vbuf){
795
+ printdata(vbuf, vsiz, px);
796
+ if(!pz) putchar('\n');
797
+ tcfree(vbuf);
798
+ } else {
799
+ printerr(bdb);
800
+ err = true;
801
+ }
802
+ if(!tcbdbclose(bdb)){
803
+ if(!err) printerr(bdb);
804
+ err = true;
805
+ }
806
+ tcbdbdel(bdb);
807
+ return err ? 1 : 0;
808
+ }
809
+
810
+
811
+ /* perform list command */
812
+ static int proclist(const char *path, TCCMP cmp, int omode, int max, bool pv, bool px, bool bk,
813
+ const char *jstr, const char *bstr, const char *estr, const char *fmstr){
814
+ TCBDB *bdb = tcbdbnew();
815
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
816
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
817
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
818
+ if(!tcbdbopen(bdb, path, BDBOREADER | omode)){
819
+ printerr(bdb);
820
+ tcbdbdel(bdb);
821
+ return 1;
822
+ }
823
+ bool err = false;
824
+ if(bstr || fmstr){
825
+ TCLIST *keys = fmstr ? tcbdbfwmkeys2(bdb, fmstr, max) :
826
+ tcbdbrange(bdb, bstr, strlen(bstr), true, estr, strlen(estr), true, max);
827
+ int cnt = 0;
828
+ for(int i = 0; i < tclistnum(keys); i++){
829
+ int ksiz;
830
+ const char *kbuf = tclistval(keys, i, &ksiz);
831
+ if(pv){
832
+ TCLIST *vals = tcbdbget4(bdb, kbuf, ksiz);
833
+ if(vals){
834
+ for(int j = 0; j < tclistnum(vals); j++){
835
+ int vsiz;
836
+ const char *vbuf = tclistval(vals, j, &vsiz);
837
+ printdata(kbuf, ksiz, px);
838
+ putchar('\t');
839
+ printdata(vbuf, vsiz, px);
840
+ putchar('\n');
841
+ if(max >= 0 && ++cnt >= max) break;
842
+ }
843
+ tclistdel(vals);
844
+ }
845
+ } else {
846
+ int num = tcbdbvnum(bdb, kbuf, ksiz);
847
+ for(int j = 0; j < num; j++){
848
+ printdata(kbuf, ksiz, px);
849
+ putchar('\n');
850
+ if(max >= 0 && ++cnt >= max) break;
851
+ }
852
+ }
853
+ if(max >= 0 && cnt >= max) break;
854
+ }
855
+ tclistdel(keys);
856
+ } else {
857
+ BDBCUR *cur = tcbdbcurnew(bdb);
858
+ if(bk){
859
+ if(jstr){
860
+ if(!tcbdbcurjumpback(cur, jstr, strlen(jstr)) && tcbdbecode(bdb) != TCENOREC){
861
+ printerr(bdb);
862
+ err = true;
863
+ }
864
+ } else {
865
+ if(!tcbdbcurlast(cur) && tcbdbecode(bdb) != TCENOREC){
866
+ printerr(bdb);
867
+ err = true;
868
+ }
869
+ }
870
+ } else {
871
+ if(jstr){
872
+ if(!tcbdbcurjump(cur, jstr, strlen(jstr)) && tcbdbecode(bdb) != TCENOREC){
873
+ printerr(bdb);
874
+ err = true;
875
+ }
876
+ } else {
877
+ if(!tcbdbcurfirst(cur) && tcbdbecode(bdb) != TCENOREC){
878
+ printerr(bdb);
879
+ err = true;
880
+ }
881
+ }
882
+ }
883
+ TCXSTR *key = tcxstrnew();
884
+ TCXSTR *val = tcxstrnew();
885
+ int cnt = 0;
886
+ while(tcbdbcurrec(cur, key, val)){
887
+ printdata(tcxstrptr(key), tcxstrsize(key), px);
888
+ if(pv){
889
+ putchar('\t');
890
+ printdata(tcxstrptr(val), tcxstrsize(val), px);
891
+ }
892
+ putchar('\n');
893
+ if(bk){
894
+ if(!tcbdbcurprev(cur) && tcbdbecode(bdb) != TCENOREC){
895
+ printerr(bdb);
896
+ err = true;
897
+ }
898
+ } else {
899
+ if(!tcbdbcurnext(cur) && tcbdbecode(bdb) != TCENOREC){
900
+ printerr(bdb);
901
+ err = true;
902
+ }
903
+ }
904
+ if(max >= 0 && ++cnt >= max) break;
905
+ }
906
+ tcxstrdel(val);
907
+ tcxstrdel(key);
908
+ tcbdbcurdel(cur);
909
+ }
910
+ if(!tcbdbclose(bdb)){
911
+ if(!err) printerr(bdb);
912
+ err = true;
913
+ }
914
+ tcbdbdel(bdb);
915
+ return err ? 1 : 0;
916
+ }
917
+
918
+
919
+ /* perform optimize command */
920
+ static int procoptimize(const char *path, int lmemb, int nmemb,
921
+ int bnum, int apow, int fpow, TCCMP cmp, int opts, int omode, bool df){
922
+ TCBDB *bdb = tcbdbnew();
923
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
924
+ if(cmp && !tcbdbsetcmpfunc(bdb, cmp, NULL)) printerr(bdb);
925
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
926
+ if(!tcbdbopen(bdb, path, BDBOWRITER | omode)){
927
+ printerr(bdb);
928
+ tcbdbdel(bdb);
929
+ return 1;
930
+ }
931
+ bool err = false;
932
+ if(df){
933
+ if(!tcbdbdefrag(bdb, INT64_MAX)){
934
+ printerr(bdb);
935
+ err = true;
936
+ }
937
+ } else {
938
+ if(!tcbdboptimize(bdb, lmemb, nmemb, bnum, apow, fpow, opts)){
939
+ printerr(bdb);
940
+ err = true;
941
+ }
942
+ }
943
+ if(!tcbdbclose(bdb)){
944
+ if(!err) printerr(bdb);
945
+ err = true;
946
+ }
947
+ tcbdbdel(bdb);
948
+ return err ? 1 : 0;
949
+ }
950
+
951
+
952
+ /* perform importtsv command */
953
+ static int procimporttsv(const char *path, const char *file, int omode, bool sc){
954
+ FILE *ifp = file ? fopen(file, "rb") : stdin;
955
+ if(!ifp){
956
+ fprintf(stderr, "%s: could not open\n", file ? file : "(stdin)");
957
+ return 1;
958
+ }
959
+ TCBDB *bdb = tcbdbnew();
960
+ if(g_dbgfd >= 0) tcbdbsetdbgfd(bdb, g_dbgfd);
961
+ if(!tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(bdb);
962
+ if(!tcbdbopen(bdb, path, BDBOWRITER | BDBOCREAT | omode)){
963
+ printerr(bdb);
964
+ tcbdbdel(bdb);
965
+ if(ifp != stdin) fclose(ifp);
966
+ return 1;
967
+ }
968
+ bool err = false;
969
+ char *line;
970
+ int cnt = 0;
971
+ while(!err && (line = mygetline(ifp)) != NULL){
972
+ char *pv = strchr(line, '\t');
973
+ if(!pv){
974
+ tcfree(line);
975
+ continue;
976
+ }
977
+ *pv = '\0';
978
+ if(sc) tcstrutfnorm(line, TCUNSPACE | TCUNLOWER | TCUNNOACC | TCUNWIDTH);
979
+ if(!tcbdbputdup2(bdb, line, pv + 1)){
980
+ printerr(bdb);
981
+ err = true;
982
+ }
983
+ tcfree(line);
984
+ if(cnt > 0 && cnt % 100 == 0){
985
+ putchar('.');
986
+ fflush(stdout);
987
+ if(cnt % 5000 == 0) printf(" (%08d)\n", cnt);
988
+ }
989
+ cnt++;
990
+ }
991
+ printf(" (%08d)\n", cnt);
992
+ if(!tcbdbclose(bdb)){
993
+ if(!err) printerr(bdb);
994
+ err = true;
995
+ }
996
+ tcbdbdel(bdb);
997
+ if(ifp != stdin) fclose(ifp);
998
+ return err ? 1 : 0;
999
+ }
1000
+
1001
+
1002
+ /* perform version command */
1003
+ static int procversion(void){
1004
+ printf("Tokyo Cabinet version %s (%d:%s) for %s\n",
1005
+ tcversion, _TC_LIBVER, _TC_FORMATVER, TCSYSNAME);
1006
+ printf("Copyright (C) 2006-2009 Mikio Hirabayashi\n");
1007
+ return 0;
1008
+ }
1009
+
1010
+
1011
+
1012
+ // END OF FILE