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,858 @@
1
+ /*************************************************************************************************
2
+ * The fixed-length database API of Tokyo Cabinet
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
+ #ifndef _TCFDB_H /* duplication check */
18
+ #define _TCFDB_H
19
+
20
+ #if defined(__cplusplus)
21
+ #define __TCFDB_CLINKAGEBEGIN extern "C" {
22
+ #define __TCFDB_CLINKAGEEND }
23
+ #else
24
+ #define __TCFDB_CLINKAGEBEGIN
25
+ #define __TCFDB_CLINKAGEEND
26
+ #endif
27
+ __TCFDB_CLINKAGEBEGIN
28
+
29
+
30
+ #include <tcutil.h>
31
+
32
+
33
+
34
+ /*************************************************************************************************
35
+ * API
36
+ *************************************************************************************************/
37
+
38
+
39
+ typedef struct { /* type of structure for a fixed-length database */
40
+ void *mmtx; /* mutex for method */
41
+ void *amtx; /* mutex for attribute */
42
+ void *rmtxs; /* mutexes for records */
43
+ void *tmtx; /* mutex for transaction */
44
+ void *wmtx; /* mutex for write ahead logging */
45
+ void *eckey; /* key for thread specific error code */
46
+ char *rpath; /* real path for locking */
47
+ uint8_t type; /* database type */
48
+ uint8_t flags; /* additional flags */
49
+ uint32_t width; /* width of the value of each record */
50
+ uint64_t limsiz; /* limit size of the file */
51
+ int wsiz; /* size of the width region */
52
+ int rsiz; /* size of each record */
53
+ uint64_t limid; /* limit ID number */
54
+ char *path; /* path of the database file */
55
+ int fd; /* file descriptor of the database file */
56
+ uint32_t omode; /* open mode */
57
+ uint64_t rnum; /* number of the records */
58
+ uint64_t fsiz; /* size of the database file */
59
+ uint64_t min; /* minimum ID number */
60
+ uint64_t max; /* maximum ID number */
61
+ uint64_t iter; /* ID number of the iterator */
62
+ char *map; /* pointer to the mapped memory */
63
+ unsigned char *array; /* pointer to the array region */
64
+ int ecode; /* last happened error code */
65
+ bool fatal; /* whether a fatal error occured */
66
+ uint64_t inode; /* inode number */
67
+ time_t mtime; /* modification time */
68
+ bool tran; /* whether in the transaction */
69
+ int walfd; /* file descriptor of write ahead logging */
70
+ uint64_t walend; /* end offset of write ahead logging */
71
+ int dbgfd; /* file descriptor for debugging */
72
+ int64_t cnt_writerec; /* tesing counter for record write times */
73
+ int64_t cnt_readrec; /* tesing counter for record read times */
74
+ int64_t cnt_truncfile; /* tesing counter for file truncate times */
75
+ } TCFDB;
76
+
77
+ enum { /* enumeration for additional flags */
78
+ FDBFOPEN = 1 << 0, /* whether opened */
79
+ FDBFFATAL = 1 << 1 /* whetehr with fatal error */
80
+ };
81
+
82
+ enum { /* enumeration for open modes */
83
+ FDBOREADER = 1 << 0, /* open as a reader */
84
+ FDBOWRITER = 1 << 1, /* open as a writer */
85
+ FDBOCREAT = 1 << 2, /* writer creating */
86
+ FDBOTRUNC = 1 << 3, /* writer truncating */
87
+ FDBONOLCK = 1 << 4, /* open without locking */
88
+ FDBOLCKNB = 1 << 5, /* lock without blocking */
89
+ FDBOTSYNC = 1 << 6 /* synchronize every transaction */
90
+ };
91
+
92
+ enum { /* enumeration for ID constants */
93
+ FDBIDMIN = -1, /* minimum number */
94
+ FDBIDPREV = -2, /* less by one than the minimum */
95
+ FDBIDMAX = -3, /* maximum number */
96
+ FDBIDNEXT = -4 /* greater by one than the miximum */
97
+ };
98
+
99
+
100
+ /* Get the message string corresponding to an error code.
101
+ `ecode' specifies the error code.
102
+ The return value is the message string of the error code. */
103
+ const char *tcfdberrmsg(int ecode);
104
+
105
+
106
+ /* Create a fixed-length database object.
107
+ The return value is the new fixed-length database object. */
108
+ TCFDB *tcfdbnew(void);
109
+
110
+
111
+ /* Delete a fixed-length database object.
112
+ `fdb' specifies the fixed-length database object.
113
+ If the database is not closed, it is closed implicitly. Note that the deleted object and its
114
+ derivatives can not be used anymore. */
115
+ void tcfdbdel(TCFDB *fdb);
116
+
117
+
118
+ /* Get the last happened error code of a fixed-length database object.
119
+ `fdb' specifies the fixed-length database object.
120
+ The return value is the last happened error code.
121
+ The following error codes are defined: `TCESUCCESS' for success, `TCETHREAD' for threading
122
+ error, `TCEINVALID' for invalid operation, `TCENOFILE' for file not found, `TCENOPERM' for no
123
+ permission, `TCEMETA' for invalid meta data, `TCERHEAD' for invalid record header, `TCEOPEN'
124
+ for open error, `TCECLOSE' for close error, `TCETRUNC' for trunc error, `TCESYNC' for sync
125
+ error, `TCESTAT' for stat error, `TCESEEK' for seek error, `TCEREAD' for read error,
126
+ `TCEWRITE' for write error, `TCEMMAP' for mmap error, `TCELOCK' for lock error, `TCEUNLINK'
127
+ for unlink error, `TCERENAME' for rename error, `TCEMKDIR' for mkdir error, `TCERMDIR' for
128
+ rmdir error, `TCEKEEP' for existing record, `TCENOREC' for no record found, and `TCEMISC' for
129
+ miscellaneous error. */
130
+ int tcfdbecode(TCFDB *fdb);
131
+
132
+
133
+ /* Set mutual exclusion control of a fixed-length database object for threading.
134
+ `fdb' specifies the fixed-length database object which is not opened.
135
+ If successful, the return value is true, else, it is false.
136
+ Note that the mutual exclusion control is needed if the object is shared by plural threads and
137
+ this function should be called before the database is opened. */
138
+ bool tcfdbsetmutex(TCFDB *fdb);
139
+
140
+
141
+ /* Set the tuning parameters of a fixed-length database object.
142
+ `fdb' specifies the fixed-length database object which is not opened.
143
+ `width' specifies the width of the value of each record. If it is not more than 0, the
144
+ default value is specified. The default value is 255.
145
+ `limsiz' specifies the limit size of the database file. If it is not more than 0, the default
146
+ value is specified. The default value is 268435456.
147
+ If successful, the return value is true, else, it is false.
148
+ Note that the tuning parameters should be set before the database is opened. */
149
+ bool tcfdbtune(TCFDB *fdb, int32_t width, int64_t limsiz);
150
+
151
+
152
+ /* Open a database file and connect a fixed-length database object.
153
+ `fdb' specifies the fixed-length database object which is not opened.
154
+ `path' specifies the path of the database file.
155
+ `omode' specifies the connection mode: `FDBOWRITER' as a writer, `FDBOREADER' as a reader.
156
+ If the mode is `FDBOWRITER', the following may be added by bitwise-or: `FDBOCREAT', which
157
+ means it creates a new database if not exist, `FDBOTRUNC', which means it creates a new
158
+ database regardless if one exists, `FDBOTSYNC', which means every transaction synchronizes
159
+ updated contents with the device. Both of `FDBOREADER' and `FDBOWRITER' can be added to by
160
+ bitwise-or: `FDBONOLCK', which means it opens the database file without file locking, or
161
+ `FDBOLCKNB', which means locking is performed without blocking.
162
+ If successful, the return value is true, else, it is false. */
163
+ bool tcfdbopen(TCFDB *fdb, const char *path, int omode);
164
+
165
+
166
+ /* Close a fixed-length database object.
167
+ `fdb' specifies the fixed-length database object.
168
+ If successful, the return value is true, else, it is false.
169
+ Update of a database is assured to be written when the database is closed. If a writer opens
170
+ a database but does not close it appropriately, the database will be broken. */
171
+ bool tcfdbclose(TCFDB *fdb);
172
+
173
+
174
+ /* Store a record into a fixed-length database object.
175
+ `fdb' specifies the fixed-length database object connected as a writer.
176
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
177
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
178
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
179
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
180
+ the maximum ID number of existing records is specified.
181
+ `vbuf' specifies the pointer to the region of the value.
182
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
183
+ than the width tuning parameter of the database, the size is cut down to the width.
184
+ If successful, the return value is true, else, it is false.
185
+ If a record with the same key exists in the database, it is overwritten. */
186
+ bool tcfdbput(TCFDB *fdb, int64_t id, const void *vbuf, int vsiz);
187
+
188
+
189
+ /* Store a record with a decimal key into a fixed-length database object.
190
+ `fdb' specifies the fixed-length database object connected as a writer.
191
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
192
+ it is "min", the minimum ID number of existing records is specified. If it is "prev", the
193
+ number less by one than the minimum ID number of existing records is specified. If it is
194
+ "max", the maximum ID number of existing records is specified. If it is "next", the number
195
+ greater by one than the maximum ID number of existing records is specified.
196
+ `ksiz' specifies the size of the region of the key.
197
+ `vbuf' specifies the pointer to the region of the value.
198
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
199
+ than the width tuning parameter of the database, the size is cut down to the width.
200
+ If successful, the return value is true, else, it is false.
201
+ If a record with the same key exists in the database, it is overwritten. */
202
+ bool tcfdbput2(TCFDB *fdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
203
+
204
+
205
+ /* Store a string record with a decimal key into a fixed-length database object.
206
+ `fdb' specifies the fixed-length database object connected as a writer.
207
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
208
+ the minimum ID number of existing records is specified. If it is "prev", the number less by
209
+ one than the minimum ID number of existing records is specified. If it is "max", the maximum
210
+ ID number of existing records is specified. If it is "next", the number greater by one than
211
+ the maximum ID number of existing records is specified.
212
+ `vstr' specifies the string of the value.
213
+ If successful, the return value is true, else, it is false.
214
+ If a record with the same key exists in the database, it is overwritten. */
215
+ bool tcfdbput3(TCFDB *fdb, const char *kstr, const void *vstr);
216
+
217
+
218
+ /* Store a new record into a fixed-length database object.
219
+ `fdb' specifies the fixed-length database object connected as a writer.
220
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
221
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
222
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
223
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
224
+ the maximum ID number of existing records is specified.
225
+ `vbuf' specifies the pointer to the region of the value.
226
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
227
+ than the width tuning parameter of the database, the size is cut down to the width.
228
+ If successful, the return value is true, else, it is false.
229
+ If a record with the same key exists in the database, this function has no effect. */
230
+ bool tcfdbputkeep(TCFDB *fdb, int64_t id, const void *vbuf, int vsiz);
231
+
232
+
233
+ /* Store a new record with a decimal key into a fixed-length database object.
234
+ `fdb' specifies the fixed-length database object connected as a writer.
235
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
236
+ it is "min", the minimum ID number of existing records is specified. If it is "prev", the
237
+ number less by one than the minimum ID number of existing records is specified. If it is
238
+ "max", the maximum ID number of existing records is specified. If it is "next", the number
239
+ greater by one than the maximum ID number of existing records is specified.
240
+ `ksiz' specifies the size of the region of the key.
241
+ `vbuf' specifies the pointer to the region of the value.
242
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
243
+ than the width tuning parameter of the database, the size is cut down to the width.
244
+ If successful, the return value is true, else, it is false.
245
+ If a record with the same key exists in the database, this function has no effect. */
246
+ bool tcfdbputkeep2(TCFDB *fdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
247
+
248
+
249
+ /* Store a new string record with a decimal key into a fixed-length database object.
250
+ `fdb' specifies the fixed-length database object connected as a writer.
251
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
252
+ the minimum ID number of existing records is specified. If it is "prev", the number less by
253
+ one than the minimum ID number of existing records is specified. If it is "max", the maximum
254
+ ID number of existing records is specified. If it is "next", the number greater by one than
255
+ the maximum ID number of existing records is specified.
256
+ `vstr' specifies the string of the value.
257
+ If successful, the return value is true, else, it is false.
258
+ If a record with the same key exists in the database, this function has no effect. */
259
+ bool tcfdbputkeep3(TCFDB *fdb, const char *kstr, const void *vstr);
260
+
261
+
262
+ /* Concatenate a value at the end of the existing record in a fixed-length database object.
263
+ `fdb' specifies the fixed-length database object connected as a writer.
264
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
265
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
266
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
267
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
268
+ the maximum ID number of existing records is specified.
269
+ `vbuf' specifies the pointer to the region of the value.
270
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
271
+ than the width tuning parameter of the database, the size is cut down to the width.
272
+ If successful, the return value is true, else, it is false.
273
+ If there is no corresponding record, a new record is created. */
274
+ bool tcfdbputcat(TCFDB *fdb, int64_t id, const void *vbuf, int vsiz);
275
+
276
+
277
+ /* Concatenate a value with a decimal key in a fixed-length database object.
278
+ `fdb' specifies the fixed-length database object connected as a writer.
279
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
280
+ it is "min", the minimum ID number of existing records is specified. If it is "prev", the
281
+ number less by one than the minimum ID number of existing records is specified. If it is
282
+ "max", the maximum ID number of existing records is specified. If it is "next", the number
283
+ greater by one than the maximum ID number of existing records is specified.
284
+ `ksiz' specifies the size of the region of the key.
285
+ `vbuf' specifies the pointer to the region of the value.
286
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
287
+ than the width tuning parameter of the database, the size is cut down to the width.
288
+ If successful, the return value is true, else, it is false.
289
+ If there is no corresponding record, a new record is created. */
290
+ bool tcfdbputcat2(TCFDB *fdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);
291
+
292
+
293
+ /* Concatenate a string value with a decimal key in a fixed-length database object.
294
+ `fdb' specifies the fixed-length database object connected as a writer.
295
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
296
+ the minimum ID number of existing records is specified. If it is "prev", the number less by
297
+ one than the minimum ID number of existing records is specified. If it is "max", the maximum
298
+ ID number of existing records is specified. If it is "next", the number greater by one than
299
+ the maximum ID number of existing records is specified.
300
+ `vstr' specifies the string of the value.
301
+ If successful, the return value is true, else, it is false.
302
+ If there is no corresponding record, a new record is created. */
303
+ bool tcfdbputcat3(TCFDB *fdb, const char *kstr, const void *vstr);
304
+
305
+
306
+ /* Remove a record of a fixed-length database object.
307
+ `fdb' specifies the fixed-length database object connected as a writer.
308
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
309
+ number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of
310
+ existing records is specified.
311
+ If successful, the return value is true, else, it is false. */
312
+ bool tcfdbout(TCFDB *fdb, int64_t id);
313
+
314
+
315
+ /* Remove a record with a decimal key of a fixed-length database object.
316
+ `fdb' specifies the fixed-length database object connected as a writer.
317
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
318
+ it is "min", the minimum ID number of existing records is specified. If it is "max", the
319
+ maximum ID number of existing records is specified.
320
+ `ksiz' specifies the size of the region of the key.
321
+ If successful, the return value is true, else, it is false. */
322
+ bool tcfdbout2(TCFDB *fdb, const void *kbuf, int ksiz);
323
+
324
+
325
+ /* Remove a string record with a decimal key of a fixed-length database object.
326
+ `fdb' specifies the fixed-length database object connected as a writer.
327
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
328
+ the minimum ID number of existing records is specified. If it is "max", the maximum ID number
329
+ of existing records is specified.
330
+ If successful, the return value is true, else, it is false. */
331
+ bool tcfdbout3(TCFDB *fdb, const char *kstr);
332
+
333
+
334
+ /* Retrieve a record in a fixed-length database object.
335
+ `fdb' specifies the fixed-length database object.
336
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
337
+ number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of
338
+ existing records is specified.
339
+ `sp' specifies the pointer to the variable into which the size of the region of the return
340
+ value is assigned.
341
+ If successful, the return value is the pointer to the region of the value of the corresponding
342
+ record. `NULL' is returned if no record corresponds.
343
+ Because an additional zero code is appended at the end of the region of the return value,
344
+ the return value can be treated as a character string. Because the region of the return
345
+ value is allocated with the `malloc' call, it should be released with the `free' call when
346
+ it is no longer in use. */
347
+ void *tcfdbget(TCFDB *fdb, int64_t id, int *sp);
348
+
349
+
350
+ /* Retrieve a record with a decimal key in a fixed-length database object.
351
+ `fdb' specifies the fixed-length database object.
352
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
353
+ it is "min", the minimum ID number of existing records is specified. If it is "max", the
354
+ maximum ID number of existing records is specified.
355
+ `ksiz' specifies the size of the region of the key.
356
+ `sp' specifies the pointer to the variable into which the size of the region of the return
357
+ value is assigned.
358
+ If successful, the return value is the pointer to the region of the value of the corresponding
359
+ record. `NULL' is returned if no record corresponds.
360
+ Because an additional zero code is appended at the end of the region of the return value,
361
+ the return value can be treated as a character string. Because the region of the return
362
+ value is allocated with the `malloc' call, it should be released with the `free' call when
363
+ it is no longer in use. */
364
+ void *tcfdbget2(TCFDB *fdb, const void *kbuf, int ksiz, int *sp);
365
+
366
+
367
+ /* Retrieve a string record with a decimal key in a fixed-length database object.
368
+ `fdb' specifies the fixed-length database object.
369
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
370
+ the minimum ID number of existing records is specified. If it is "max", the maximum ID number
371
+ of existing records is specified.
372
+ If successful, the return value is the string of the value of the corresponding record.
373
+ `NULL' is returned if no record corresponds.
374
+ Because an additional zero code is appended at the end of the region of the return value,
375
+ the return value can be treated as a character string. Because the region of the return
376
+ value is allocated with the `malloc' call, it should be released with the `free' call when
377
+ it is no longer in use. */
378
+ char *tcfdbget3(TCFDB *fdb, const char *kstr);
379
+
380
+
381
+ /* Retrieve a record in a fixed-length database object and write the value into a buffer.
382
+ `fdb' specifies the fixed-length database object.
383
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
384
+ number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of
385
+ existing records is specified.
386
+ `vbuf' specifies the pointer to the buffer into which the value of the corresponding record is
387
+ written.
388
+ `max' specifies the size of the buffer.
389
+ If successful, the return value is the size of the written data, else, it is -1. -1 is
390
+ returned if no record corresponds to the specified key.
391
+ Note that an additional zero code is not appended at the end of the region of the writing
392
+ buffer. */
393
+ int tcfdbget4(TCFDB *fdb, int64_t id, void *vbuf, int max);
394
+
395
+
396
+ /* Get the size of the value of a record in a fixed-length database object.
397
+ `fdb' specifies the fixed-length database object.
398
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
399
+ number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of
400
+ existing records is specified.
401
+ If successful, the return value is the size of the value of the corresponding record, else,
402
+ it is -1. */
403
+ int tcfdbvsiz(TCFDB *fdb, int64_t id);
404
+
405
+
406
+ /* Get the size of the value with a decimal key in a fixed-length database object.
407
+ `fdb' specifies the fixed-length database object.
408
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
409
+ it is "min", the minimum ID number of existing records is specified. If it is "max", the
410
+ maximum ID number of existing records is specified.
411
+ `ksiz' specifies the size of the region of the key.
412
+ If successful, the return value is the size of the value of the corresponding record, else,
413
+ it is -1. */
414
+ int tcfdbvsiz2(TCFDB *fdb, const void *kbuf, int ksiz);
415
+
416
+
417
+ /* Get the size of the string value with a decimal key in a fixed-length database object.
418
+ `fdb' specifies the fixed-length database object.
419
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
420
+ the minimum ID number of existing records is specified. If it is "max", the maximum ID number
421
+ of existing records is specified.
422
+ If successful, the return value is the size of the value of the corresponding record, else,
423
+ it is -1. */
424
+ int tcfdbvsiz3(TCFDB *fdb, const char *kstr);
425
+
426
+
427
+ /* Initialize the iterator of a fixed-length database object.
428
+ `fdb' specifies the fixed-length database object.
429
+ If successful, the return value is true, else, it is false.
430
+ The iterator is used in order to access the key of every record stored in a database. */
431
+ bool tcfdbiterinit(TCFDB *fdb);
432
+
433
+
434
+ /* Get the next ID number of the iterator of a fixed-length database object.
435
+ `fdb' specifies the fixed-length database object.
436
+ If successful, the return value is the next ID number of the iterator, else, it is 0. 0 is
437
+ returned when no record is to be get out of the iterator.
438
+ It is possible to access every record by iteration of calling this function. It is allowed to
439
+ update or remove records whose keys are fetched while the iteration. The order of this
440
+ traversal access method is ascending of the ID number. */
441
+ uint64_t tcfdbiternext(TCFDB *fdb);
442
+
443
+
444
+ /* Get the next decimay key of the iterator of a fixed-length database object.
445
+ `fdb' specifies the fixed-length database object.
446
+ `sp' specifies the pointer to the variable into which the size of the region of the return
447
+ value is assigned.
448
+ If successful, the return value is the pointer to the region of the next decimal key, else, it
449
+ is `NULL'. `NULL' is returned when no record is to be get out of the iterator.
450
+ Because an additional zero code is appended at the end of the region of the return value, the
451
+ return value can be treated as a character string. Because the region of the return value is
452
+ allocated with the `malloc' call, it should be released with the `free' call when it is no
453
+ longer in use. It is possible to access every record by iteration of calling this function.
454
+ It is allowed to update or remove records whose keys are fetched while the iteration. The
455
+ order of this traversal access method is ascending of the ID number. */
456
+ void *tcfdbiternext2(TCFDB *fdb, int *sp);
457
+
458
+
459
+ /* Get the next decimay key string of the iterator of a fixed-length database object.
460
+ `fdb' specifies the fixed-length database object.
461
+ If successful, the return value is the string of the next decimal key, else, it is `NULL'.
462
+ `NULL' is returned when no record is to be get out of the iterator.
463
+ Because the region of the return value is allocated with the `malloc' call, it should be
464
+ released with the `free' call when it is no longer in use. It is possible to access every
465
+ record by iteration of calling this function. It is allowed to update or remove records whose
466
+ keys are fetched while the iteration. The order of this traversal access method is ascending
467
+ of the ID number. */
468
+ char *tcfdbiternext3(TCFDB *fdb);
469
+
470
+
471
+ /* Get range matching ID numbers in a fixed-length database object.
472
+ `fdb' specifies the fixed-length database object.
473
+ `lower' specifies the lower limit of the range. If it is `FDBIDMIN', the minimum ID is
474
+ specified.
475
+ `upper' specifies the upper limit of the range. If it is `FDBIDMAX', the maximum ID is
476
+ specified.
477
+ `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is
478
+ specified.
479
+ `np' specifies the pointer to the variable into which the number of elements of the return
480
+ value is assigned.
481
+ If successful, the return value is the pointer to an array of ID numbers of the corresponding
482
+ records. `NULL' is returned on failure. This function does never fail. It returns an empty
483
+ array even if no key corresponds.
484
+ Because the region of the return value is allocated with the `malloc' call, it should be
485
+ released with the `free' call when it is no longer in use. */
486
+ uint64_t *tcfdbrange(TCFDB *fdb, int64_t lower, int64_t upper, int max, int *np);
487
+
488
+
489
+ /* Get range matching decimal keys in a fixed-length database object.
490
+ `fdb' specifies the fixed-length database object.
491
+ `lbuf' specifies the pointer to the region of the lower key. If it is "min", the minimum ID
492
+ number of existing records is specified.
493
+ `lsiz' specifies the size of the region of the lower key.
494
+ `ubuf' specifies the pointer to the region of the upper key. If it is "max", the maximum ID
495
+ number of existing records is specified.
496
+ `usiz' specifies the size of the region of the upper key.
497
+ `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is
498
+ specified.
499
+ The return value is a list object of the corresponding decimal keys. This function does never
500
+ fail. It returns an empty list even if no key corresponds.
501
+ Because the object of the return value is created with the function `tclistnew', it should be
502
+ deleted with the function `tclistdel' when it is no longer in use. Note that this function
503
+ may be very slow because every key in the database is scanned. */
504
+ TCLIST *tcfdbrange2(TCFDB *fdb, const void *lbuf, int lsiz, const void *ubuf, int usiz, int max);
505
+
506
+
507
+ /* Get range matching decimal keys with strings in a fixed-length database object.
508
+ `fdb' specifies the fixed-length database object.
509
+ `lstr' specifies the string of the lower key. If it is "min", the minimum ID number of
510
+ existing records is specified.
511
+ `ustr' specifies the string of the upper key. If it is "max", the maximum ID number of
512
+ existing records is specified.
513
+ `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is
514
+ specified.
515
+ The return value is a list object of the corresponding decimal keys. This function does never
516
+ fail. It returns an empty list even if no key corresponds.
517
+ Because the object of the return value is created with the function `tclistnew', it should be
518
+ deleted with the function `tclistdel' when it is no longer in use. Note that this function
519
+ may be very slow because every key in the database is scanned. */
520
+ TCLIST *tcfdbrange3(TCFDB *fdb, const char *lstr, const char *ustr, int max);
521
+
522
+
523
+ /* Get keys with an interval notation in a fixed-length database object.
524
+ `fdb' specifies the fixed-length database object.
525
+ `ibuf' specifies the pointer to the region of the interval notation.
526
+ `isiz' specifies the size of the region of the interval notation.
527
+ `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is
528
+ specified.
529
+ The return value is a list object of the corresponding decimal keys. This function does never
530
+ fail. It returns an empty list even if no key corresponds.
531
+ Because the object of the return value is created with the function `tclistnew', it should be
532
+ deleted with the function `tclistdel' when it is no longer in use. Note that this function
533
+ may be very slow because every key in the database is scanned. */
534
+ TCLIST *tcfdbrange4(TCFDB *fdb, const void *ibuf, int isiz, int max);
535
+
536
+
537
+ /* Get keys with an interval notation string in a fixed-length database object.
538
+ `fdb' specifies the fixed-length database object.
539
+ `istr' specifies the pointer to the region of the interval notation string.
540
+ `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is
541
+ specified.
542
+ The return value is a list object of the corresponding decimal keys. This function does never
543
+ fail. It returns an empty list even if no key corresponds.
544
+ Because the object of the return value is created with the function `tclistnew', it should be
545
+ deleted with the function `tclistdel' when it is no longer in use. Note that this function
546
+ may be very slow because every key in the database is scanned. */
547
+ TCLIST *tcfdbrange5(TCFDB *fdb, const void *istr, int max);
548
+
549
+
550
+ /* Add an integer to a record in a fixed-length database object.
551
+ `fdb' specifies the fixed-length database object connected as a writer.
552
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
553
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
554
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
555
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
556
+ the maximum ID number of existing records is specified.
557
+ `num' specifies the additional value.
558
+ If successful, the return value is the summation value, else, it is `INT_MIN'.
559
+ If the corresponding record exists, the value is treated as an integer and is added to. If no
560
+ record corresponds, a new record of the additional value is stored. */
561
+ int tcfdbaddint(TCFDB *fdb, int64_t id, int num);
562
+
563
+
564
+ /* Add a real number to a record in a fixed-length database object.
565
+ `fdb' specifies the fixed-length database object connected as a writer.
566
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
567
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
568
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
569
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
570
+ the maximum ID number of existing records is specified.
571
+ `num' specifies the additional value.
572
+ If successful, the return value is the summation value, else, it is Not-a-Number.
573
+ If the corresponding record exists, the value is treated as a real number and is added to. If
574
+ no record corresponds, a new record of the additional value is stored. */
575
+ double tcfdbadddouble(TCFDB *fdb, int64_t id, double num);
576
+
577
+
578
+ /* Synchronize updated contents of a fixed-length database object with the file and the device.
579
+ `fdb' specifies the fixed-length database object connected as a writer.
580
+ If successful, the return value is true, else, it is false.
581
+ This function is useful when another process connects to the same database file. */
582
+ bool tcfdbsync(TCFDB *fdb);
583
+
584
+
585
+ /* Optimize the file of a fixed-length database object.
586
+ `fdb' specifies the fixed-length database object connected as a writer.
587
+ `width' specifies the width of the value of each record. If it is not more than 0, the current
588
+ setting is not changed.
589
+ `limsiz' specifies the limit size of the database file. If it is not more than 0, the current
590
+ setting is not changed.
591
+ If successful, the return value is true, else, it is false. */
592
+ bool tcfdboptimize(TCFDB *fdb, int32_t width, int64_t limsiz);
593
+
594
+
595
+ /* Remove all records of a fixed-length database object.
596
+ `fdb' specifies the fixed-length database object connected as a writer.
597
+ If successful, the return value is true, else, it is false. */
598
+ bool tcfdbvanish(TCFDB *fdb);
599
+
600
+
601
+ /* Copy the database file of a fixed-length database object.
602
+ `fdb' specifies the fixed-length database object.
603
+ `path' specifies the path of the destination file. If it begins with `@', the trailing
604
+ substring is executed as a command line.
605
+ If successful, the return value is true, else, it is false. False is returned if the executed
606
+ command returns non-zero code.
607
+ The database file is assured to be kept synchronized and not modified while the copying or
608
+ executing operation is in progress. So, this function is useful to create a backup file of
609
+ the database file. */
610
+ bool tcfdbcopy(TCFDB *fdb, const char *path);
611
+
612
+
613
+ /* Begin the transaction of a fixed-length database object.
614
+ `fdb' specifies the fixed-length database object connected as a writer.
615
+ If successful, the return value is true, else, it is false.
616
+ The database is locked by the thread while the transaction so that only one transaction can be
617
+ activated with a database object at the same time. Thus, the serializable isolation level is
618
+ assumed if every database operation is performed in the transaction. All updated regions are
619
+ kept track of by write ahead logging while the transaction. If the database is closed during
620
+ transaction, the transaction is aborted implicitly. */
621
+ bool tcfdbtranbegin(TCFDB *fdb);
622
+
623
+
624
+ /* Commit the transaction of a fixed-length database object.
625
+ `fdb' specifies the fixed-length database object connected as a writer.
626
+ If successful, the return value is true, else, it is false.
627
+ Update in the transaction is fixed when it is committed successfully. */
628
+ bool tcfdbtrancommit(TCFDB *fdb);
629
+
630
+
631
+ /* Abort the transaction of a fixed-length database object.
632
+ `fdb' specifies the fixed-length database object connected as a writer.
633
+ If successful, the return value is true, else, it is false.
634
+ Update in the transaction is discarded when it is aborted. The state of the database is
635
+ rollbacked to before transaction. */
636
+ bool tcfdbtranabort(TCFDB *fdb);
637
+
638
+
639
+ /* Get the file path of a fixed-length database object.
640
+ `fdb' specifies the fixed-length database object.
641
+ The return value is the path of the database file or `NULL' if the object does not connect to
642
+ any database file. */
643
+ const char *tcfdbpath(TCFDB *fdb);
644
+
645
+
646
+ /* Get the number of records of a fixed-length database object.
647
+ `fdb' specifies the fixed-length database object.
648
+ The return value is the number of records or 0 if the object does not connect to any database
649
+ file. */
650
+ uint64_t tcfdbrnum(TCFDB *fdb);
651
+
652
+
653
+ /* Get the size of the database file of a fixed-length database object.
654
+ `fdb' specifies the fixed-length database object.
655
+ The return value is the size of the database file or 0 if the object does not connect to any
656
+ database file. */
657
+ uint64_t tcfdbfsiz(TCFDB *fdb);
658
+
659
+
660
+
661
+ /*************************************************************************************************
662
+ * features for experts
663
+ *************************************************************************************************/
664
+
665
+
666
+ /* Set the error code of a fixed-length database object.
667
+ `fdb' specifies the fixed-length database object.
668
+ `ecode' specifies the error code.
669
+ `file' specifies the file name of the code.
670
+ `line' specifies the line number of the code.
671
+ `func' specifies the function name of the code. */
672
+ void tcfdbsetecode(TCFDB *fdb, int ecode, const char *filename, int line, const char *func);
673
+
674
+
675
+ /* Set the file descriptor for debugging output.
676
+ `fdb' specifies the fixed-length database object.
677
+ `fd' specifies the file descriptor for debugging output. */
678
+ void tcfdbsetdbgfd(TCFDB *fdb, int fd);
679
+
680
+
681
+ /* Get the file descriptor for debugging output.
682
+ `fdb' specifies the fixed-length database object.
683
+ The return value is the file descriptor for debugging output. */
684
+ int tcfdbdbgfd(TCFDB *fdb);
685
+
686
+
687
+ /* Check whether mutual exclusion control is set to a fixed-length database object.
688
+ `fdb' specifies the fixed-length database object.
689
+ If mutual exclusion control is set, it is true, else it is false. */
690
+ bool tcfdbhasmutex(TCFDB *fdb);
691
+
692
+
693
+ /* Synchronize updating contents on memory of a fixed-length database object.
694
+ `fdb' specifies the fixed-length database object connected as a writer.
695
+ `phys' specifies whether to synchronize physically.
696
+ If successful, the return value is true, else, it is false. */
697
+ bool tcfdbmemsync(TCFDB *fdb, bool phys);
698
+
699
+
700
+ /* Get the minimum ID number of records of a fixed-length database object.
701
+ `fdb' specifies the fixed-length database object.
702
+ The return value is the minimum ID number of records or 0 if the object does not connect to
703
+ any database file. */
704
+ uint64_t tcfdbmin(TCFDB *fdb);
705
+
706
+
707
+ /* Get the maximum ID number of records of a fixed-length database object.
708
+ `fdb' specifies the fixed-length database object.
709
+ The return value is the maximum ID number of records or 0 if the object does not connect to
710
+ any database file. */
711
+ uint64_t tcfdbmax(TCFDB *fdb);
712
+
713
+
714
+ /* Get the width of the value of each record of a fixed-length database object.
715
+ `fdb' specifies the fixed-length database object.
716
+ The return value is the width of the value of each record or 0 if the object does not connect
717
+ to any database file. */
718
+ uint32_t tcfdbwidth(TCFDB *fdb);
719
+
720
+
721
+ /* Get the limit file size of a fixed-length database object.
722
+ `fdb' specifies the fixed-length database object.
723
+ The return value is the limit file size or 0 if the object does not connect to any database
724
+ file. */
725
+ uint64_t tcfdblimsiz(TCFDB *fdb);
726
+
727
+
728
+ /* Get the limit ID number of a fixed-length database object.
729
+ `fdb' specifies the fixed-length database object.
730
+ The return value is the limit ID number or 0 if the object does not connect to any database
731
+ file. */
732
+ uint64_t tcfdblimid(TCFDB *fdb);
733
+
734
+
735
+ /* Get the inode number of the database file of a fixed-length database object.
736
+ `fdb' specifies the fixed-length database object.
737
+ The return value is the inode number of the database file or 0 if the object does not connect
738
+ to any database file. */
739
+ uint64_t tcfdbinode(TCFDB *fdb);
740
+
741
+
742
+ /* Get the modification time of the database file of a fixed-length database object.
743
+ `fdb' specifies the fixed-length database object.
744
+ The return value is the inode number of the database file or 0 if the object does not connect
745
+ to any database file. */
746
+ time_t tcfdbmtime(TCFDB *fdb);
747
+
748
+
749
+ /* Get the connection mode of a fixed-length database object.
750
+ `fdb' specifies the fixed-length database object.
751
+ The return value is the connection mode. */
752
+ int tcfdbomode(TCFDB *fdb);
753
+
754
+
755
+ /* Get the database type of a fixed-length database object.
756
+ `fdb' specifies the fixed-length database object.
757
+ The return value is the database type. */
758
+ uint8_t tcfdbtype(TCFDB *fdb);
759
+
760
+
761
+ /* Get the additional flags of a fixed-length database object.
762
+ `fdb' specifies the fixed-length database object.
763
+ The return value is the additional flags. */
764
+ uint8_t tcfdbflags(TCFDB *fdb);
765
+
766
+
767
+ /* Get the pointer to the opaque field of a fixed-length database object.
768
+ `fdb' specifies the fixed-length database object.
769
+ The return value is the pointer to the opaque field whose size is 128 bytes. */
770
+ char *tcfdbopaque(TCFDB *fdb);
771
+
772
+
773
+ /* Store a record into a fixed-length database object with a duplication handler.
774
+ `fdb' specifies the fixed-length database object connected as a writer.
775
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
776
+ number of existing records is specified. If it is `FDBIDPREV', the number less by one than
777
+ the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID
778
+ number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than
779
+ the maximum ID number of existing records is specified.
780
+ `vbuf' specifies the pointer to the region of the value. `NULL' means that record addition is
781
+ ommited if there is no corresponding record.
782
+ `vsiz' specifies the size of the region of the value. If the size of the value is greater
783
+ than the width tuning parameter of the database, the size is cut down to the width.
784
+ `proc' specifies the pointer to the callback function to process duplication. It receives
785
+ four parameters. The first parameter is the pointer to the region of the value. The second
786
+ parameter is the size of the region of the value. The third parameter is the pointer to the
787
+ variable into which the size of the region of the return value is assigned. The fourth
788
+ parameter is the pointer to the optional opaque object. It returns the pointer to the result
789
+ object allocated with `malloc'. It is released by the caller. If it is `NULL', the record is
790
+ not modified. If it is `(void *)-1', the record is removed.
791
+ `op' specifies an arbitrary pointer to be given as a parameter of the callback function. If
792
+ it is not needed, `NULL' can be specified.
793
+ If successful, the return value is true, else, it is false.
794
+ Note that the callback function can not perform any database operation because the function
795
+ is called in the critical section guarded by the same locks of database operations. */
796
+ bool tcfdbputproc(TCFDB *fdb, int64_t id, const void *vbuf, int vsiz, TCPDPROC proc, void *op);
797
+
798
+
799
+ /* Move the iterator to the record corresponding a key of a fixed-length database object.
800
+ `fdb' specifies the fixed-length database object.
801
+ `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID
802
+ number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of
803
+ existing records is specified.
804
+ If successful, the return value is true, else, it is false. False is returned if there is
805
+ no record corresponding the condition. */
806
+ bool tcfdbiterinit2(TCFDB *fdb, int64_t id);
807
+
808
+
809
+ /* Move the iterator to the decimal record of a fixed-length database object.
810
+ `fdb' specifies the fixed-length database object.
811
+ `kbuf' specifies the pointer to the region of the decimal key. It should be more than 0. If
812
+ it is "min", the minimum ID number of existing records is specified. If it is "max", the
813
+ maximum ID number of existing records is specified.
814
+ `ksiz' specifies the size of the region of the key.
815
+ If successful, the return value is true, else, it is false. False is returned if there is
816
+ no record corresponding the condition. */
817
+ bool tcfdbiterinit3(TCFDB *fdb, const void *kbuf, int ksiz);
818
+
819
+
820
+ /* Move the iterator to the decimal string record of a fixed-length database object.
821
+ `fdb' specifies the fixed-length database object.
822
+ `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min",
823
+ the minimum ID number of existing records is specified. If it is "max", the maximum ID number
824
+ of existing records is specified.
825
+ If successful, the return value is true, else, it is false. False is returned if there is
826
+ no record corresponding the condition. */
827
+ bool tcfdbiterinit4(TCFDB *fdb, const char *kstr);
828
+
829
+
830
+ /* Process each record atomically of a fixed-length database object.
831
+ `fdb' specifies the fixed-length database object.
832
+ `iter' specifies the pointer to the iterator function called for each record. It receives
833
+ five parameters. The first parameter is the pointer to the region of the key. The second
834
+ parameter is the size of the region of the key. The third parameter is the pointer to the
835
+ region of the value. The fourth parameter is the size of the region of the value. The fifth
836
+ parameter is the pointer to the optional opaque object. It returns true to continue iteration
837
+ or false to stop iteration.
838
+ `op' specifies an arbitrary pointer to be given as a parameter of the iterator function. If
839
+ it is not needed, `NULL' can be specified.
840
+ If successful, the return value is true, else, it is false.
841
+ Note that the callback function can not perform any database operation because the function
842
+ is called in the critical section guarded by the same locks of database operations. */
843
+ bool tcfdbforeach(TCFDB *fdb, TCITER iter, void *op);
844
+
845
+
846
+ /* Generate the ID number from arbitrary binary data.
847
+ `kbuf' specifies the pointer to the region of the key.
848
+ `ksiz' specifies the size of the region of the key.
849
+ The return value is the ID number. */
850
+ int64_t tcfdbkeytoid(const char *kbuf, int ksiz);
851
+
852
+
853
+
854
+ __TCFDB_CLINKAGEEND
855
+ #endif /* duplication check */
856
+
857
+
858
+ /* END OF FILE */