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,1845 @@
1
+ /*************************************************************************************************
2
+ * The test cases of the abstract database API
3
+ * Copyright (C) 2006-2009 Mikio Hirabayashi
4
+ * This file is part of Tokyo Cabinet.
5
+ * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
6
+ * the GNU Lesser General Public License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License or any later version. Tokyo Cabinet is distributed in the hope
8
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10
+ * License for more details.
11
+ * You should have received a copy of the GNU Lesser General Public License along with Tokyo
12
+ * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
13
+ * Boston, MA 02111-1307 USA.
14
+ *************************************************************************************************/
15
+
16
+
17
+ #include <tcutil.h>
18
+ #include <tcadb.h>
19
+ #include "myconf.h"
20
+
21
+ #define MULDIVNUM 8 // division number of multiple database
22
+ #define RECBUFSIZ 48 // buffer for records
23
+
24
+
25
+ /* global variables */
26
+ const char *g_progname; // program name
27
+ unsigned int g_randseed; // random seed
28
+ ADBSKEL g_skeleton; // skeleton database
29
+
30
+
31
+ /* function prototypes */
32
+ int main(int argc, char **argv);
33
+ static void usage(void);
34
+ static void iprintf(const char *format, ...);
35
+ static void iputchar(int c);
36
+ static void eprint(TCADB *adb, int line, const char *func);
37
+ static void sysprint(void);
38
+ static int myrand(int range);
39
+ static void setskeltran(ADBSKEL *skel);
40
+ static void *pdprocfunccmp(const void *vbuf, int vsiz, int *sp, void *op);
41
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op);
42
+ static int runwrite(int argc, char **argv);
43
+ static int runread(int argc, char **argv);
44
+ static int runremove(int argc, char **argv);
45
+ static int runrcat(int argc, char **argv);
46
+ static int runmisc(int argc, char **argv);
47
+ static int runwicked(int argc, char **argv);
48
+ static int runcompare(int argc, char **argv);
49
+ static int procwrite(const char *name, int rnum);
50
+ static int procread(const char *name);
51
+ static int procremove(const char *name);
52
+ static int procrcat(const char *name, int rnum);
53
+ static int procmisc(const char *name, int rnum);
54
+ static int procwicked(const char *name, int rnum);
55
+ static int proccompare(const char *name, int tnum, int rnum);
56
+
57
+
58
+ /* main routine */
59
+ int main(int argc, char **argv){
60
+ g_progname = argv[0];
61
+ const char *ebuf = getenv("TCRNDSEED");
62
+ g_randseed = ebuf ? tcatoix(ebuf) : tctime() * 1000;
63
+ srand(g_randseed);
64
+ if(argc < 2) usage();
65
+ int rv = 0;
66
+ if(!strcmp(argv[1], "write")){
67
+ rv = runwrite(argc, argv);
68
+ } else if(!strcmp(argv[1], "read")){
69
+ rv = runread(argc, argv);
70
+ } else if(!strcmp(argv[1], "remove")){
71
+ rv = runremove(argc, argv);
72
+ } else if(!strcmp(argv[1], "rcat")){
73
+ rv = runrcat(argc, argv);
74
+ } else if(!strcmp(argv[1], "misc")){
75
+ rv = runmisc(argc, argv);
76
+ } else if(!strcmp(argv[1], "wicked")){
77
+ rv = runwicked(argc, argv);
78
+ } else if(!strcmp(argv[1], "compare")){
79
+ rv = runcompare(argc, argv);
80
+ } else {
81
+ usage();
82
+ }
83
+ if(rv != 0){
84
+ printf("FAILED: TCRNDSEED=%u PID=%d", g_randseed, (int)getpid());
85
+ for(int i = 0; i < argc; i++){
86
+ printf(" %s", argv[i]);
87
+ }
88
+ printf("\n\n");
89
+ }
90
+ return rv;
91
+ }
92
+
93
+
94
+ /* print the usage and exit */
95
+ static void usage(void){
96
+ fprintf(stderr, "%s: test cases of the abstract database API of Tokyo Cabinet\n", g_progname);
97
+ fprintf(stderr, "\n");
98
+ fprintf(stderr, "usage:\n");
99
+ fprintf(stderr, " %s write name rnum\n", g_progname);
100
+ fprintf(stderr, " %s read name\n", g_progname);
101
+ fprintf(stderr, " %s remove name\n", g_progname);
102
+ fprintf(stderr, " %s rcat name rnum\n", g_progname);
103
+ fprintf(stderr, " %s misc name rnum\n", g_progname);
104
+ fprintf(stderr, " %s wicked name rnum\n", g_progname);
105
+ fprintf(stderr, " %s compare name tnum rnum\n", g_progname);
106
+ fprintf(stderr, "\n");
107
+ exit(1);
108
+ }
109
+
110
+
111
+ /* print formatted information string and flush the buffer */
112
+ static void iprintf(const char *format, ...){
113
+ va_list ap;
114
+ va_start(ap, format);
115
+ vprintf(format, ap);
116
+ fflush(stdout);
117
+ va_end(ap);
118
+ }
119
+
120
+
121
+ /* print a character and flush the buffer */
122
+ static void iputchar(int c){
123
+ putchar(c);
124
+ fflush(stdout);
125
+ }
126
+
127
+
128
+ /* print error message of abstract database */
129
+ static void eprint(TCADB *adb, int line, const char *func){
130
+ const char *path = adb ? tcadbpath(adb) : NULL;
131
+ fprintf(stderr, "%s: %s: %d: %s: error\n", g_progname, path ? path : "-", line, func);
132
+ }
133
+
134
+
135
+ /* print system information */
136
+ static void sysprint(void){
137
+ TCMAP *info = tcsysinfo();
138
+ if(info){
139
+ tcmapiterinit(info);
140
+ const char *kbuf;
141
+ while((kbuf = tcmapiternext2(info)) != NULL){
142
+ iprintf("sys_%s: %s\n", kbuf, tcmapiterval2(kbuf));
143
+ }
144
+ tcmapdel(info);
145
+ }
146
+ }
147
+
148
+
149
+ /* get a random number */
150
+ static int myrand(int range){
151
+ if(range < 2) return 0;
152
+ int high = (unsigned int)rand() >> 4;
153
+ int low = range * (rand() / (RAND_MAX + 1.0));
154
+ low &= (unsigned int)INT_MAX >> 4;
155
+ return (high + low) % range;
156
+ }
157
+
158
+
159
+ /* set the transparent skeleton database */
160
+ static void setskeltran(ADBSKEL *skel){
161
+ memset(skel, 0, sizeof(*skel));
162
+ skel->opq = tcadbnew();
163
+ skel->del = (void (*)(void *))tcadbdel;
164
+ skel->open = (bool (*)(void *, const char *))tcadbopen;
165
+ skel->close = (bool (*)(void *))tcadbclose;
166
+ skel->put = (bool (*)(void *, const void *, int, const void *, int))tcadbput;
167
+ skel->putkeep = (bool (*)(void *, const void *, int, const void *, int))tcadbputkeep;
168
+ skel->putcat = (bool (*)(void *, const void *, int, const void *, int))tcadbputcat;
169
+ skel->out = (bool (*)(void *, const void *, int))tcadbout;
170
+ skel->get = (void *(*)(void *, const void *, int, int *))tcadbget;
171
+ skel->vsiz = (int (*)(void *, const void *, int))tcadbvsiz;
172
+ skel->iterinit = (bool (*)(void *))tcadbiterinit;
173
+ skel->iternext = (void *(*)(void *, int *))tcadbiternext;
174
+ skel->fwmkeys = (TCLIST *(*)(void *, const void *, int, int))tcadbfwmkeys;
175
+ skel->addint = (int (*)(void *, const void *, int, int))tcadbaddint;
176
+ skel->adddouble = (double (*)(void *, const void *, int, double))tcadbadddouble;
177
+ skel->sync = (bool (*)(void *))tcadbsync;
178
+ skel->optimize = (bool (*)(void *, const char *))tcadboptimize;
179
+ skel->vanish = (bool (*)(void *))tcadbvanish;
180
+ skel->copy = (bool (*)(void *, const char *))tcadbcopy;
181
+ skel->tranbegin = (bool (*)(void *))tcadbtranbegin;
182
+ skel->trancommit = (bool (*)(void *))tcadbtrancommit;
183
+ skel->tranabort = (bool (*)(void *))tcadbtranabort;
184
+ skel->path = (const char *(*)(void *))tcadbpath;
185
+ skel->rnum = (uint64_t (*)(void *))tcadbrnum;
186
+ skel->size = (uint64_t (*)(void *))tcadbsize;
187
+ skel->misc = (TCLIST *(*)(void *, const char *, const TCLIST *))tcadbmisc;
188
+ skel->putproc =
189
+ (bool (*)(void *, const void *, int, const void *, int, TCPDPROC, void *))tcadbputproc;
190
+ skel->foreach = (bool (*)(void *, TCITER, void *))tcadbforeach;
191
+ }
192
+
193
+
194
+ /* duplication callback function for comparison */
195
+ static void *pdprocfunccmp(const void *vbuf, int vsiz, int *sp, void *op){
196
+ switch(*(int *)op % 4){
197
+ case 1: return NULL;
198
+ case 2: return (void *)-1;
199
+ default: break;
200
+ }
201
+ *sp = vsiz;
202
+ return tcmemdup(vbuf, vsiz);
203
+ }
204
+
205
+
206
+ /* iterator function */
207
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op){
208
+ unsigned int sum = 0;
209
+ while(--ksiz >= 0){
210
+ sum += ((char *)kbuf)[ksiz];
211
+ }
212
+ while(--vsiz >= 0){
213
+ sum += ((char *)vbuf)[vsiz];
214
+ }
215
+ return myrand(100 + (sum & 0xff)) > 0;
216
+ }
217
+
218
+
219
+ /* parse arguments of write command */
220
+ static int runwrite(int argc, char **argv){
221
+ char *name = NULL;
222
+ char *rstr = NULL;
223
+ for(int i = 2; i < argc; i++){
224
+ if(!name && argv[i][0] == '-'){
225
+ usage();
226
+ } else if(!name){
227
+ name = argv[i];
228
+ } else if(!rstr){
229
+ rstr = argv[i];
230
+ } else {
231
+ usage();
232
+ }
233
+ }
234
+ if(!name || !rstr) usage();
235
+ int rnum = tcatoix(rstr);
236
+ if(rnum < 1) usage();
237
+ int rv = procwrite(name, rnum);
238
+ return rv;
239
+ }
240
+
241
+
242
+ /* parse arguments of read command */
243
+ static int runread(int argc, char **argv){
244
+ char *name = NULL;
245
+ for(int i = 2; i < argc; i++){
246
+ if(!name && argv[i][0] == '-'){
247
+ usage();
248
+ } else if(!name){
249
+ name = argv[i];
250
+ } else {
251
+ usage();
252
+ }
253
+ }
254
+ if(!name) usage();
255
+ int rv = procread(name);
256
+ return rv;
257
+ }
258
+
259
+
260
+ /* parse arguments of remove command */
261
+ static int runremove(int argc, char **argv){
262
+ char *name = NULL;
263
+ for(int i = 2; i < argc; i++){
264
+ if(!name && argv[i][0] == '-'){
265
+ usage();
266
+ } else if(!name){
267
+ name = argv[i];
268
+ } else {
269
+ usage();
270
+ }
271
+ }
272
+ if(!name) usage();
273
+ int rv = procremove(name);
274
+ return rv;
275
+ }
276
+
277
+
278
+ /* parse arguments of rcat command */
279
+ static int runrcat(int argc, char **argv){
280
+ char *name = NULL;
281
+ char *rstr = NULL;
282
+ for(int i = 2; i < argc; i++){
283
+ if(!name && argv[i][0] == '-'){
284
+ usage();
285
+ } else if(!name){
286
+ name = argv[i];
287
+ } else if(!rstr){
288
+ rstr = argv[i];
289
+ } else {
290
+ usage();
291
+ }
292
+ }
293
+ if(!name || !rstr) usage();
294
+ int rnum = tcatoix(rstr);
295
+ if(rnum < 1) usage();
296
+ int rv = procrcat(name, rnum);
297
+ return rv;
298
+ }
299
+
300
+
301
+ /* parse arguments of misc command */
302
+ static int runmisc(int argc, char **argv){
303
+ char *name = NULL;
304
+ char *rstr = NULL;
305
+ for(int i = 2; i < argc; i++){
306
+ if(!name && argv[i][0] == '-'){
307
+ usage();
308
+ } else if(!name){
309
+ name = argv[i];
310
+ } else if(!rstr){
311
+ rstr = argv[i];
312
+ } else {
313
+ usage();
314
+ }
315
+ }
316
+ if(!name || !rstr) usage();
317
+ int rnum = tcatoix(rstr);
318
+ if(rnum < 1) usage();
319
+ int rv = procmisc(name, rnum);
320
+ return rv;
321
+ }
322
+
323
+
324
+ /* parse arguments of wicked command */
325
+ static int runwicked(int argc, char **argv){
326
+ char *name = NULL;
327
+ char *rstr = NULL;
328
+ for(int i = 2; i < argc; i++){
329
+ if(!name && argv[i][0] == '-'){
330
+ usage();
331
+ } else if(!name){
332
+ name = argv[i];
333
+ } else if(!rstr){
334
+ rstr = argv[i];
335
+ } else {
336
+ usage();
337
+ }
338
+ }
339
+ if(!name || !rstr) usage();
340
+ int rnum = tcatoix(rstr);
341
+ if(rnum < 1) usage();
342
+ int rv = procwicked(name, rnum);
343
+ return rv;
344
+ }
345
+
346
+
347
+ /* parse arguments of compare command */
348
+ static int runcompare(int argc, char **argv){
349
+ char *name = NULL;
350
+ char *tstr = NULL;
351
+ char *rstr = NULL;
352
+ for(int i = 2; i < argc; i++){
353
+ if(!name && argv[i][0] == '-'){
354
+ usage();
355
+ } else if(!name){
356
+ name = argv[i];
357
+ } else if(!tstr){
358
+ tstr = argv[i];
359
+ } else if(!rstr){
360
+ rstr = argv[i];
361
+ } else {
362
+ usage();
363
+ }
364
+ }
365
+ if(!name || !tstr || !rstr) usage();
366
+ int tnum = tcatoix(tstr);
367
+ int rnum = tcatoix(rstr);
368
+ if(tnum < 1 || rnum < 1) usage();
369
+ int rv = proccompare(name, tnum, rnum);
370
+ return rv;
371
+ }
372
+
373
+
374
+ /* perform write command */
375
+ static int procwrite(const char *name, int rnum){
376
+ iprintf("<Writing Test>\n seed=%u name=%s rnum=%d\n\n", g_randseed, name, rnum);
377
+ bool err = false;
378
+ double stime = tctime();
379
+ TCADB *adb = tcadbnew();
380
+ ADBSKEL skel;
381
+ if(*name == '@'){
382
+ setskeltran(&skel);
383
+ if(!tcadbsetskel(adb, &skel)){
384
+ eprint(adb, __LINE__, "tcadbsetskel");
385
+ err = true;
386
+ skel.del(skel.opq);
387
+ }
388
+ name++;
389
+ } else if(*name == '%'){
390
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
391
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
392
+ err = true;
393
+ }
394
+ name++;
395
+ }
396
+ if(!tcadbopen(adb, name)){
397
+ eprint(adb, __LINE__, "tcadbopen");
398
+ err = true;
399
+ }
400
+ for(int i = 1; i <= rnum; i++){
401
+ char buf[RECBUFSIZ];
402
+ int len = sprintf(buf, "%08d", i);
403
+ if(!tcadbput(adb, buf, len, buf, len)){
404
+ eprint(adb, __LINE__, "tcadbput");
405
+ err = true;
406
+ break;
407
+ }
408
+ if(rnum > 250 && i % (rnum / 250) == 0){
409
+ iputchar('.');
410
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
411
+ }
412
+ }
413
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
414
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
415
+ sysprint();
416
+ if(!tcadbclose(adb)){
417
+ eprint(adb, __LINE__, "tcadbclose");
418
+ err = true;
419
+ }
420
+ tcadbdel(adb);
421
+ iprintf("time: %.3f\n", tctime() - stime);
422
+ iprintf("%s\n\n", err ? "error" : "ok");
423
+ return err ? 1 : 0;
424
+ }
425
+
426
+
427
+ /* perform read command */
428
+ static int procread(const char *name){
429
+ iprintf("<Reading Test>\n seed=%u name=%s\n\n", g_randseed, name);
430
+ bool err = false;
431
+ double stime = tctime();
432
+ TCADB *adb = tcadbnew();
433
+ ADBSKEL skel;
434
+ if(*name == '@'){
435
+ setskeltran(&skel);
436
+ if(!tcadbsetskel(adb, &skel)){
437
+ eprint(adb, __LINE__, "tcadbsetskel");
438
+ err = true;
439
+ skel.del(skel.opq);
440
+ }
441
+ name++;
442
+ } else if(*name == '%'){
443
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
444
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
445
+ err = true;
446
+ }
447
+ name++;
448
+ }
449
+ if(!tcadbopen(adb, name)){
450
+ eprint(adb, __LINE__, "tcadbopen");
451
+ err = true;
452
+ }
453
+ int rnum = tcadbrnum(adb);
454
+ for(int i = 1; i <= rnum; i++){
455
+ char kbuf[RECBUFSIZ];
456
+ int ksiz = sprintf(kbuf, "%08d", i);
457
+ int vsiz;
458
+ char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
459
+ if(!vbuf){
460
+ eprint(adb, __LINE__, "tcadbget");
461
+ err = true;
462
+ break;
463
+ }
464
+ tcfree(vbuf);
465
+ if(rnum > 250 && i % (rnum / 250) == 0){
466
+ iputchar('.');
467
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
468
+ }
469
+ }
470
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
471
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
472
+ sysprint();
473
+ if(!tcadbclose(adb)){
474
+ eprint(adb, __LINE__, "tcadbclose");
475
+ err = true;
476
+ }
477
+ tcadbdel(adb);
478
+ iprintf("time: %.3f\n", tctime() - stime);
479
+ iprintf("%s\n\n", err ? "error" : "ok");
480
+ return err ? 1 : 0;
481
+ }
482
+
483
+
484
+ /* perform remove command */
485
+ static int procremove(const char *name){
486
+ iprintf("<Removing Test>\n seed=%u name=%s\n\n", g_randseed, name);
487
+ bool err = false;
488
+ double stime = tctime();
489
+ TCADB *adb = tcadbnew();
490
+ ADBSKEL skel;
491
+ if(*name == '@'){
492
+ setskeltran(&skel);
493
+ if(!tcadbsetskel(adb, &skel)){
494
+ eprint(adb, __LINE__, "tcadbsetskel");
495
+ err = true;
496
+ skel.del(skel.opq);
497
+ }
498
+ name++;
499
+ } else if(*name == '%'){
500
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
501
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
502
+ err = true;
503
+ }
504
+ name++;
505
+ }
506
+ if(!tcadbopen(adb, name)){
507
+ eprint(adb, __LINE__, "tcadbopen");
508
+ err = true;
509
+ }
510
+ int rnum = tcadbrnum(adb);
511
+ for(int i = 1; i <= rnum; i++){
512
+ char kbuf[RECBUFSIZ];
513
+ int ksiz = sprintf(kbuf, "%08d", i);
514
+ if(!tcadbout(adb, kbuf, ksiz)){
515
+ eprint(adb, __LINE__, "tcadbout");
516
+ err = true;
517
+ break;
518
+ }
519
+ if(rnum > 250 && i % (rnum / 250) == 0){
520
+ iputchar('.');
521
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
522
+ }
523
+ }
524
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
525
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
526
+ sysprint();
527
+ if(!tcadbclose(adb)){
528
+ eprint(adb, __LINE__, "tcadbclose");
529
+ err = true;
530
+ }
531
+ tcadbdel(adb);
532
+ iprintf("time: %.3f\n", tctime() - stime);
533
+ iprintf("%s\n\n", err ? "error" : "ok");
534
+ return err ? 1 : 0;
535
+ }
536
+
537
+
538
+ /* perform rcat command */
539
+ static int procrcat(const char *name, int rnum){
540
+ iprintf("<Random Concatenating Test>\n seed=%u name=%s rnum=%d\n\n",
541
+ g_randseed, name, rnum);
542
+ int pnum = rnum / 5 + 1;
543
+ bool err = false;
544
+ double stime = tctime();
545
+ TCADB *adb = tcadbnew();
546
+ ADBSKEL skel;
547
+ if(*name == '@'){
548
+ setskeltran(&skel);
549
+ if(!tcadbsetskel(adb, &skel)){
550
+ eprint(adb, __LINE__, "tcadbsetskel");
551
+ err = true;
552
+ skel.del(skel.opq);
553
+ }
554
+ name++;
555
+ } else if(*name == '%'){
556
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
557
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
558
+ err = true;
559
+ }
560
+ name++;
561
+ }
562
+ if(!tcadbopen(adb, name)){
563
+ eprint(adb, __LINE__, "tcadbopen");
564
+ err = true;
565
+ }
566
+ for(int i = 1; i <= rnum; i++){
567
+ char kbuf[RECBUFSIZ];
568
+ int ksiz = sprintf(kbuf, "%d", myrand(pnum) + 1);
569
+ if(!tcadbputcat(adb, kbuf, ksiz, kbuf, ksiz)){
570
+ eprint(adb, __LINE__, "tcadbputcat");
571
+ err = true;
572
+ break;
573
+ }
574
+ if(rnum > 250 && i % (rnum / 250) == 0){
575
+ iputchar('.');
576
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
577
+ }
578
+ }
579
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
580
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
581
+ sysprint();
582
+ if(!tcadbclose(adb)){
583
+ eprint(adb, __LINE__, "tcadbclose");
584
+ err = true;
585
+ }
586
+ tcadbdel(adb);
587
+ iprintf("time: %.3f\n", tctime() - stime);
588
+ iprintf("%s\n\n", err ? "error" : "ok");
589
+ return err ? 1 : 0;
590
+ }
591
+
592
+
593
+ /* perform misc command */
594
+ static int procmisc(const char *name, int rnum){
595
+ iprintf("<Miscellaneous Test>\n seed=%u name=%s rnum=%d\n\n", g_randseed, name, rnum);
596
+ bool err = false;
597
+ double stime = tctime();
598
+ TCADB *adb = tcadbnew();
599
+ ADBSKEL skel;
600
+ if(*name == '@'){
601
+ setskeltran(&skel);
602
+ if(!tcadbsetskel(adb, &skel)){
603
+ eprint(adb, __LINE__, "tcadbsetskel");
604
+ err = true;
605
+ skel.del(skel.opq);
606
+ }
607
+ name++;
608
+ } else if(*name == '%'){
609
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
610
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
611
+ err = true;
612
+ }
613
+ name++;
614
+ }
615
+ if(!tcadbopen(adb, name)){
616
+ eprint(adb, __LINE__, "tcadbopen");
617
+ err = true;
618
+ }
619
+ iprintf("writing:\n");
620
+ for(int i = 1; i <= rnum; i++){
621
+ char buf[RECBUFSIZ];
622
+ int len = sprintf(buf, "%08d", i);
623
+ if(!tcadbputkeep(adb, buf, len, buf, len)){
624
+ eprint(adb, __LINE__, "tcadbputkeep");
625
+ err = true;
626
+ break;
627
+ }
628
+ if(rnum > 250 && i % (rnum / 250) == 0){
629
+ iputchar('.');
630
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
631
+ }
632
+ }
633
+ iprintf("reading:\n");
634
+ for(int i = 1; i <= rnum; i++){
635
+ char kbuf[RECBUFSIZ];
636
+ int ksiz = sprintf(kbuf, "%08d", i);
637
+ int vsiz;
638
+ char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
639
+ if(!vbuf){
640
+ eprint(adb, __LINE__, "tcadbget");
641
+ err = true;
642
+ break;
643
+ } else if(vsiz != ksiz || memcmp(vbuf, kbuf, vsiz)){
644
+ eprint(adb, __LINE__, "(validation)");
645
+ err = true;
646
+ tcfree(vbuf);
647
+ break;
648
+ }
649
+ tcfree(vbuf);
650
+ if(rnum > 250 && i % (rnum / 250) == 0){
651
+ iputchar('.');
652
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
653
+ }
654
+ }
655
+ if(tcadbrnum(adb) != rnum){
656
+ eprint(adb, __LINE__, "(validation)");
657
+ err = true;
658
+ }
659
+ iprintf("random writing:\n");
660
+ for(int i = 1; i <= rnum; i++){
661
+ char kbuf[RECBUFSIZ];
662
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum) + 1);
663
+ char vbuf[RECBUFSIZ];
664
+ int vsiz = myrand(RECBUFSIZ);
665
+ memset(vbuf, '*', vsiz);
666
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
667
+ eprint(adb, __LINE__, "tcadbput");
668
+ err = true;
669
+ break;
670
+ }
671
+ int rsiz;
672
+ char *rbuf = tcadbget(adb, kbuf, ksiz, &rsiz);
673
+ if(!rbuf){
674
+ eprint(adb, __LINE__, "tcadbget");
675
+ err = true;
676
+ break;
677
+ }
678
+ if(rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
679
+ eprint(adb, __LINE__, "(validation)");
680
+ err = true;
681
+ tcfree(rbuf);
682
+ break;
683
+ }
684
+ if(rnum > 250 && i % (rnum / 250) == 0){
685
+ iputchar('.');
686
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
687
+ }
688
+ tcfree(rbuf);
689
+ }
690
+ iprintf("word writing:\n");
691
+ const char *words[] = {
692
+ "a", "A", "bb", "BB", "ccc", "CCC", "dddd", "DDDD", "eeeee", "EEEEEE",
693
+ "mikio", "hirabayashi", "tokyo", "cabinet", "hyper", "estraier", "19780211", "birth day",
694
+ "one", "first", "two", "second", "three", "third", "four", "fourth", "five", "fifth",
695
+ "_[1]_", "uno", "_[2]_", "dos", "_[3]_", "tres", "_[4]_", "cuatro", "_[5]_", "cinco",
696
+ "[\xe5\xb9\xb3\xe6\x9e\x97\xe5\xb9\xb9\xe9\x9b\x84]", "[\xe9\xa6\xac\xe9\xb9\xbf]", NULL
697
+ };
698
+ for(int i = 0; words[i] != NULL; i += 2){
699
+ const char *kbuf = words[i];
700
+ int ksiz = strlen(kbuf);
701
+ const char *vbuf = words[i+1];
702
+ int vsiz = strlen(vbuf);
703
+ if(!tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz)){
704
+ eprint(adb, __LINE__, "tcadbputkeep");
705
+ err = true;
706
+ break;
707
+ }
708
+ if(rnum > 250) iputchar('.');
709
+ }
710
+ if(rnum > 250) iprintf(" (%08d)\n", (int)(sizeof(words) / sizeof(*words)));
711
+ iprintf("random erasing:\n");
712
+ for(int i = 1; i <= rnum; i++){
713
+ char kbuf[RECBUFSIZ];
714
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum));
715
+ tcadbout(adb, kbuf, ksiz);
716
+ if(rnum > 250 && i % (rnum / 250) == 0){
717
+ iputchar('.');
718
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
719
+ }
720
+ }
721
+ iprintf("writing:\n");
722
+ for(int i = 1; i <= rnum; i++){
723
+ char kbuf[RECBUFSIZ];
724
+ int ksiz = sprintf(kbuf, "[%d]", i);
725
+ char vbuf[RECBUFSIZ];
726
+ int vsiz = i % RECBUFSIZ;
727
+ memset(vbuf, '*', vsiz);
728
+ if(!tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz)){
729
+ eprint(adb, __LINE__, "tcadbputkeep");
730
+ err = true;
731
+ break;
732
+ }
733
+ if(vsiz < 1){
734
+ char tbuf[PATH_MAX];
735
+ for(int j = 0; j < PATH_MAX; j++){
736
+ tbuf[j] = myrand(0x100);
737
+ }
738
+ if(!tcadbput(adb, kbuf, ksiz, tbuf, PATH_MAX)){
739
+ eprint(adb, __LINE__, "tcadbput");
740
+ err = true;
741
+ break;
742
+ }
743
+ }
744
+ if(rnum > 250 && i % (rnum / 250) == 0){
745
+ iputchar('.');
746
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
747
+ }
748
+ }
749
+ iprintf("erasing:\n");
750
+ for(int i = 1; i <= rnum; i++){
751
+ if(i % 2 == 1){
752
+ char kbuf[RECBUFSIZ];
753
+ int ksiz = sprintf(kbuf, "[%d]", i);
754
+ if(!tcadbout(adb, kbuf, ksiz)){
755
+ eprint(adb, __LINE__, "tcadbout");
756
+ err = true;
757
+ break;
758
+ }
759
+ tcadbout(adb, kbuf, ksiz);
760
+ }
761
+ if(rnum > 250 && i % (rnum / 250) == 0){
762
+ iputchar('.');
763
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
764
+ }
765
+ }
766
+ iprintf("checking iterator:\n");
767
+ if(!tcadbiterinit(adb)){
768
+ eprint(adb, __LINE__, "tcadbiterinit");
769
+ err = true;
770
+ }
771
+ char *kbuf;
772
+ int ksiz;
773
+ int inum = 0;
774
+ for(int i = 1; (kbuf = tcadbiternext(adb, &ksiz)) != NULL; i++, inum++){
775
+ int vsiz;
776
+ char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
777
+ if(!vbuf){
778
+ eprint(adb, __LINE__, "tcadbget");
779
+ err = true;
780
+ tcfree(kbuf);
781
+ break;
782
+ }
783
+ tcfree(vbuf);
784
+ tcfree(kbuf);
785
+ if(rnum > 250 && i % (rnum / 250) == 0){
786
+ iputchar('.');
787
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
788
+ }
789
+ }
790
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
791
+ if(inum != tcadbrnum(adb)){
792
+ eprint(adb, __LINE__, "(validation)");
793
+ err = true;
794
+ }
795
+ iprintf("checking versatile functions:\n");
796
+ TCLIST *args = tclistnew();
797
+ for(int i = 1; i <= rnum; i++){
798
+ if(myrand(10) == 0){
799
+ const char *name;
800
+ switch(myrand(3)){
801
+ default: name = "putlist"; break;
802
+ case 1: name = "outlist"; break;
803
+ case 2: name = "getlist"; break;
804
+ }
805
+ tclistclear(args);
806
+ for(int j = myrand(4) * 2; j > 0; j--){
807
+ char abuf[RECBUFSIZ];
808
+ int asiz = sprintf(abuf, "%d", myrand(rnum) + 1);
809
+ tclistpush(args, abuf, asiz);
810
+ }
811
+ TCLIST *rv = tcadbmisc(adb, name, args);
812
+ if(rv){
813
+ tclistdel(rv);
814
+ } else {
815
+ eprint(adb, __LINE__, "tcadbmisc");
816
+ err = true;
817
+ break;
818
+ }
819
+ } else {
820
+ char kbuf[RECBUFSIZ];
821
+ int ksiz = sprintf(kbuf, "(%d)", i);
822
+ tclistpush(args, kbuf, ksiz);
823
+ }
824
+ if(rnum > 250 && i % (rnum / 250) == 0){
825
+ iputchar('.');
826
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
827
+ }
828
+ }
829
+ tclistdel(args);
830
+ args = tclistnew2(1);
831
+ if(myrand(10) == 0){
832
+ TCLIST *rv = tcadbmisc(adb, "sync", args);
833
+ if(rv){
834
+ tclistdel(rv);
835
+ } else {
836
+ eprint(adb, __LINE__, "tcadbmisc");
837
+ err = true;
838
+ }
839
+ }
840
+ if(myrand(10) == 0){
841
+ TCLIST *rv = tcadbmisc(adb, "optimize", args);
842
+ if(rv){
843
+ tclistdel(rv);
844
+ } else {
845
+ eprint(adb, __LINE__, "tcadbmisc");
846
+ err = true;
847
+ }
848
+ }
849
+ if(myrand(10) == 0){
850
+ TCLIST *rv = tcadbmisc(adb, "vanish", args);
851
+ if(rv){
852
+ tclistdel(rv);
853
+ } else {
854
+ eprint(adb, __LINE__, "tcadbmisc");
855
+ err = true;
856
+ }
857
+ }
858
+ tclistdel(args);
859
+ if(myrand(10) == 0 && !tcadbsync(adb)){
860
+ eprint(adb, __LINE__, "tcadbsync");
861
+ err = true;
862
+ }
863
+ if(myrand(10) == 0 && !tcadboptimize(adb, NULL)){
864
+ eprint(adb, __LINE__, "tcadboptimize");
865
+ err = true;
866
+ }
867
+ if(!tcadbvanish(adb)){
868
+ eprint(adb, __LINE__, "tcadbvanish");
869
+ err = true;
870
+ }
871
+ int omode = tcadbomode(adb);
872
+ if(omode == ADBOHDB || omode == ADBOBDB || omode == ADBOFDB){
873
+ TCMAP *map = tcmapnew();
874
+ iprintf("random writing:\n");
875
+ for(int i = 1; i <= rnum; i++){
876
+ char kbuf[RECBUFSIZ];
877
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum));
878
+ char vbuf[RECBUFSIZ];
879
+ int vsiz = sprintf(vbuf, "%d", myrand(rnum));
880
+ switch(myrand(4)){
881
+ case 0:
882
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
883
+ eprint(adb, __LINE__, "tcadbput");
884
+ err = true;
885
+ }
886
+ tcmapput(map, kbuf, ksiz, vbuf, vsiz);
887
+ break;
888
+ case 1:
889
+ tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz);
890
+ tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
891
+ break;
892
+ case 2:
893
+ tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz);
894
+ tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
895
+ break;
896
+ case 3:
897
+ tcadbout(adb, kbuf, ksiz);
898
+ tcmapout(map, kbuf, ksiz);
899
+ break;
900
+ }
901
+ if(rnum > 250 && i % (rnum / 250) == 0){
902
+ iputchar('.');
903
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
904
+ }
905
+ }
906
+ iprintf("checking transaction commit:\n");
907
+ if(!tcadbtranbegin(adb)){
908
+ eprint(adb, __LINE__, "tcadbtranbegin");
909
+ err = true;
910
+ }
911
+ for(int i = 1; i <= rnum; i++){
912
+ char kbuf[RECBUFSIZ];
913
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum));
914
+ char vbuf[RECBUFSIZ];
915
+ int vsiz = sprintf(vbuf, "[%d]", myrand(rnum));
916
+ switch(myrand(6)){
917
+ case 0:
918
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
919
+ eprint(adb, __LINE__, "tcadbput");
920
+ err = true;
921
+ }
922
+ tcmapput(map, kbuf, ksiz, vbuf, vsiz);
923
+ break;
924
+ case 1:
925
+ tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz);
926
+ tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
927
+ break;
928
+ case 2:
929
+ tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz);
930
+ tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
931
+ break;
932
+ case 3:
933
+ tcadbaddint(adb, kbuf, ksiz, 1);
934
+ tcmapaddint(map, kbuf, ksiz, 1);
935
+ break;
936
+ case 4:
937
+ tcadbadddouble(adb, kbuf, ksiz, 1.0);
938
+ tcmapadddouble(map, kbuf, ksiz, 1.0);
939
+ break;
940
+ case 5:
941
+ tcadbout(adb, kbuf, ksiz);
942
+ tcmapout(map, kbuf, ksiz);
943
+ break;
944
+ }
945
+ if(rnum > 250 && i % (rnum / 250) == 0){
946
+ iputchar('.');
947
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
948
+ }
949
+ }
950
+ if(!tcadbtrancommit(adb)){
951
+ eprint(adb, __LINE__, "tcadbtrancommit");
952
+ err = true;
953
+ }
954
+ iprintf("checking transaction abort:\n");
955
+ uint64_t ornum = tcadbrnum(adb);
956
+ uint64_t osize = tcadbsize(adb);
957
+ if(!tcadbtranbegin(adb)){
958
+ eprint(adb, __LINE__, "tcadbtranbegin");
959
+ err = true;
960
+ }
961
+ for(int i = 1; i <= rnum; i++){
962
+ char kbuf[RECBUFSIZ];
963
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum));
964
+ char vbuf[RECBUFSIZ];
965
+ int vsiz = sprintf(vbuf, "((%d))", myrand(rnum));
966
+ switch(myrand(6)){
967
+ case 0:
968
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
969
+ eprint(adb, __LINE__, "tcadbput");
970
+ err = true;
971
+ }
972
+ break;
973
+ case 1:
974
+ tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz);
975
+ break;
976
+ case 2:
977
+ tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz);
978
+ break;
979
+ case 3:
980
+ tcadbaddint(adb, kbuf, ksiz, 1);
981
+ break;
982
+ case 4:
983
+ tcadbadddouble(adb, kbuf, ksiz, 1.0);
984
+ break;
985
+ case 5:
986
+ tcadbout(adb, kbuf, ksiz);
987
+ break;
988
+ }
989
+ if(rnum > 250 && i % (rnum / 250) == 0){
990
+ iputchar('.');
991
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
992
+ }
993
+ }
994
+ if(!tcadbtranabort(adb)){
995
+ eprint(adb, __LINE__, "tcadbtranabort");
996
+ err = true;
997
+ }
998
+ iprintf("checking consistency:\n");
999
+ if(tcadbrnum(adb) != ornum || tcadbsize(adb) != osize || tcadbrnum(adb) != tcmaprnum(map)){
1000
+ eprint(adb, __LINE__, "(validation)");
1001
+ err = true;
1002
+ }
1003
+ inum = 0;
1004
+ tcmapiterinit(map);
1005
+ const char *tkbuf;
1006
+ int tksiz;
1007
+ for(int i = 1; (tkbuf = tcmapiternext(map, &tksiz)) != NULL; i++, inum++){
1008
+ int tvsiz;
1009
+ const char *tvbuf = tcmapiterval(tkbuf, &tvsiz);
1010
+ int rsiz;
1011
+ char *rbuf = tcadbget(adb, tkbuf, tksiz, &rsiz);
1012
+ if(!rbuf || rsiz != tvsiz || memcmp(rbuf, tvbuf, rsiz)){
1013
+ eprint(adb, __LINE__, "(validation)");
1014
+ err = true;
1015
+ tcfree(rbuf);
1016
+ break;
1017
+ }
1018
+ tcfree(rbuf);
1019
+ if(rnum > 250 && i % (rnum / 250) == 0){
1020
+ iputchar('.');
1021
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1022
+ }
1023
+ }
1024
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
1025
+ inum = 0;
1026
+ if(!tcadbiterinit(adb)){
1027
+ eprint(adb, __LINE__, "tcadbiterinit");
1028
+ err = true;
1029
+ }
1030
+ for(int i = 1; (kbuf = tcadbiternext(adb, &ksiz)) != NULL; i++, inum++){
1031
+ int vsiz;
1032
+ char *vbuf = tcadbget(adb, kbuf, ksiz, &vsiz);
1033
+ int rsiz;
1034
+ const char *rbuf = tcmapget(map, kbuf, ksiz, &rsiz);
1035
+ if(!rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1036
+ eprint(adb, __LINE__, "(validation)");
1037
+ err = true;
1038
+ tcfree(vbuf);
1039
+ tcfree(kbuf);
1040
+ break;
1041
+ }
1042
+ tcfree(vbuf);
1043
+ tcfree(kbuf);
1044
+ if(rnum > 250 && i % (rnum / 250) == 0){
1045
+ iputchar('.');
1046
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1047
+ }
1048
+ }
1049
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
1050
+ tcmapdel(map);
1051
+ if(!tcadbvanish(adb)){
1052
+ eprint(adb, __LINE__, "tcadbvanish");
1053
+ err = true;
1054
+ }
1055
+ }
1056
+ if(!tcadbput2(adb, "mikio", "hirabayashi")){
1057
+ eprint(adb, __LINE__, "tcadbput2");
1058
+ err = true;
1059
+ }
1060
+ for(int i = 0; i < 10; i++){
1061
+ char buf[RECBUFSIZ];
1062
+ int size = sprintf(buf, "%d", myrand(rnum));
1063
+ if(!tcadbput(adb, buf, size, buf, size)){
1064
+ eprint(adb, __LINE__, "tcadbput");
1065
+ err = true;
1066
+ }
1067
+ }
1068
+ for(int i = myrand(3) + 1; i < PATH_MAX; i = i * 2 + myrand(3)){
1069
+ char vbuf[i];
1070
+ memset(vbuf, '@', i - 1);
1071
+ vbuf[i-1] = '\0';
1072
+ if(!tcadbput2(adb, "mikio", vbuf)){
1073
+ eprint(adb, __LINE__, "tcadbput2");
1074
+ err = true;
1075
+ }
1076
+ }
1077
+ if(!tcadbforeach(adb, iterfunc, NULL)){
1078
+ eprint(adb, __LINE__, "tcadbforeach");
1079
+ err = true;
1080
+ }
1081
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
1082
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
1083
+ sysprint();
1084
+ if(!tcadbclose(adb)){
1085
+ eprint(adb, __LINE__, "tcadbclose");
1086
+ err = true;
1087
+ }
1088
+ tcadbdel(adb);
1089
+ iprintf("time: %.3f\n", tctime() - stime);
1090
+ iprintf("%s\n\n", err ? "error" : "ok");
1091
+ return err ? 1 : 0;
1092
+ }
1093
+
1094
+
1095
+ /* perform wicked command */
1096
+ static int procwicked(const char *name, int rnum){
1097
+ iprintf("<Wicked Writing Test>\n seed=%u name=%s rnum=%d\n\n", g_randseed, name, rnum);
1098
+ bool err = false;
1099
+ double stime = tctime();
1100
+ TCADB *adb = tcadbnew();
1101
+ ADBSKEL skel;
1102
+ if(*name == '@'){
1103
+ setskeltran(&skel);
1104
+ if(!tcadbsetskel(adb, &skel)){
1105
+ eprint(adb, __LINE__, "tcadbsetskel");
1106
+ err = true;
1107
+ skel.del(skel.opq);
1108
+ }
1109
+ name++;
1110
+ } else if(*name == '%'){
1111
+ if(!tcadbsetskelmulti(adb, MULDIVNUM)){
1112
+ eprint(adb, __LINE__, "tcadbsetskelmulti");
1113
+ err = true;
1114
+ }
1115
+ name++;
1116
+ }
1117
+ if(!tcadbopen(adb, name)){
1118
+ eprint(adb, __LINE__, "tcadbopen");
1119
+ err = true;
1120
+ }
1121
+ TCMAP *map = tcmapnew2(rnum / 5);
1122
+ for(int i = 1; i <= rnum && !err; i++){
1123
+ char kbuf[RECBUFSIZ];
1124
+ int ksiz = sprintf(kbuf, "%d", myrand(rnum) + 1);
1125
+ char vbuf[RECBUFSIZ];
1126
+ int vsiz = myrand(RECBUFSIZ);
1127
+ memset(vbuf, '*', vsiz);
1128
+ vbuf[vsiz] = '\0';
1129
+ char *rbuf;
1130
+ switch(myrand(16)){
1131
+ case 0:
1132
+ iputchar('0');
1133
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
1134
+ eprint(adb, __LINE__, "tcadbput");
1135
+ err = true;
1136
+ }
1137
+ tcmapput(map, kbuf, ksiz, vbuf, vsiz);
1138
+ break;
1139
+ case 1:
1140
+ iputchar('1');
1141
+ if(!tcadbput2(adb, kbuf, vbuf)){
1142
+ eprint(adb, __LINE__, "tcadbput2");
1143
+ err = true;
1144
+ }
1145
+ tcmapput2(map, kbuf, vbuf);
1146
+ break;
1147
+ case 2:
1148
+ iputchar('2');
1149
+ tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz);
1150
+ tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
1151
+ break;
1152
+ case 3:
1153
+ iputchar('3');
1154
+ tcadbputkeep2(adb, kbuf, vbuf);
1155
+ tcmapputkeep2(map, kbuf, vbuf);
1156
+ break;
1157
+ case 4:
1158
+ iputchar('4');
1159
+ if(!tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz)){
1160
+ eprint(adb, __LINE__, "tcadbputcat");
1161
+ err = true;
1162
+ }
1163
+ tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
1164
+ break;
1165
+ case 5:
1166
+ iputchar('5');
1167
+ if(!tcadbputcat2(adb, kbuf, vbuf)){
1168
+ eprint(adb, __LINE__, "tcadbputcat2");
1169
+ err = true;
1170
+ }
1171
+ tcmapputcat2(map, kbuf, vbuf);
1172
+ break;
1173
+ case 6:
1174
+ iputchar('6');
1175
+ if(myrand(10) == 0){
1176
+ tcadbout(adb, kbuf, ksiz);
1177
+ tcmapout(map, kbuf, ksiz);
1178
+ }
1179
+ break;
1180
+ case 7:
1181
+ iputchar('7');
1182
+ if(myrand(10) == 0){
1183
+ tcadbout2(adb, kbuf);
1184
+ tcmapout2(map, kbuf);
1185
+ }
1186
+ break;
1187
+ case 8:
1188
+ iputchar('8');
1189
+ if((rbuf = tcadbget(adb, kbuf, ksiz, &vsiz)) != NULL) tcfree(rbuf);
1190
+ break;
1191
+ case 9:
1192
+ iputchar('9');
1193
+ if((rbuf = tcadbget2(adb, kbuf)) != NULL) tcfree(rbuf);
1194
+ break;
1195
+ case 10:
1196
+ iputchar('A');
1197
+ tcadbvsiz(adb, kbuf, ksiz);
1198
+ break;
1199
+ case 11:
1200
+ iputchar('B');
1201
+ tcadbvsiz2(adb, kbuf);
1202
+ break;
1203
+ case 12:
1204
+ iputchar('E');
1205
+ if(myrand(rnum / 50) == 0){
1206
+ if(!tcadbiterinit(adb)){
1207
+ eprint(adb, __LINE__, "tcadbiterinit");
1208
+ err = true;
1209
+ }
1210
+ }
1211
+ for(int j = myrand(rnum) / 1000 + 1; j >= 0; j--){
1212
+ int iksiz;
1213
+ char *ikbuf = tcadbiternext(adb, &iksiz);
1214
+ if(ikbuf) tcfree(ikbuf);
1215
+ }
1216
+ break;
1217
+ default:
1218
+ iputchar('@');
1219
+ if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
1220
+ break;
1221
+ }
1222
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
1223
+ }
1224
+ if(rnum % 50 > 0) iprintf(" (%08d)\n", rnum);
1225
+ tcadbsync(adb);
1226
+ if(tcadbrnum(adb) != tcmaprnum(map)){
1227
+ eprint(adb, __LINE__, "(validation)");
1228
+ err = true;
1229
+ }
1230
+ for(int i = 1; i <= rnum && !err; i++){
1231
+ char kbuf[RECBUFSIZ];
1232
+ int ksiz = sprintf(kbuf, "%d", i - 1);
1233
+ int vsiz;
1234
+ const char *vbuf = tcmapget(map, kbuf, ksiz, &vsiz);
1235
+ int rsiz;
1236
+ char *rbuf = tcadbget(adb, kbuf, ksiz, &rsiz);
1237
+ if(vbuf){
1238
+ iputchar('.');
1239
+ if(!rbuf){
1240
+ eprint(adb, __LINE__, "tcadbget");
1241
+ err = true;
1242
+ } else if(rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1243
+ eprint(adb, __LINE__, "(validation)");
1244
+ err = true;
1245
+ }
1246
+ } else {
1247
+ iputchar('*');
1248
+ if(rbuf){
1249
+ eprint(adb, __LINE__, "(validation)");
1250
+ err = true;
1251
+ }
1252
+ }
1253
+ tcfree(rbuf);
1254
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
1255
+ }
1256
+ if(rnum % 50 > 0) iprintf(" (%08d)\n", rnum);
1257
+ tcmapiterinit(map);
1258
+ int ksiz;
1259
+ const char *kbuf;
1260
+ for(int i = 1; (kbuf = tcmapiternext(map, &ksiz)) != NULL; i++){
1261
+ iputchar('+');
1262
+ int vsiz;
1263
+ const char *vbuf = tcmapiterval(kbuf, &vsiz);
1264
+ int rsiz;
1265
+ char *rbuf = tcadbget(adb, kbuf, ksiz, &rsiz);
1266
+ if(!rbuf){
1267
+ eprint(adb, __LINE__, "tcadbget");
1268
+ err = true;
1269
+ } else if(rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1270
+ eprint(adb, __LINE__, "(validation)");
1271
+ err = true;
1272
+ }
1273
+ tcfree(rbuf);
1274
+ if(!tcadbout(adb, kbuf, ksiz)){
1275
+ eprint(adb, __LINE__, "tcadbout");
1276
+ err = true;
1277
+ }
1278
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
1279
+ }
1280
+ int mrnum = tcmaprnum(map);
1281
+ if(mrnum % 50 > 0) iprintf(" (%08d)\n", mrnum);
1282
+ if(tcadbrnum(adb) != 0){
1283
+ eprint(adb, __LINE__, "(validation)");
1284
+ err = true;
1285
+ }
1286
+ iprintf("record number: %llu\n", (unsigned long long)tcadbrnum(adb));
1287
+ iprintf("size: %llu\n", (unsigned long long)tcadbsize(adb));
1288
+ sysprint();
1289
+ tcmapdel(map);
1290
+ if(!tcadbclose(adb)){
1291
+ eprint(adb, __LINE__, "tcadbclose");
1292
+ err = true;
1293
+ }
1294
+ tcadbdel(adb);
1295
+ iprintf("time: %.3f\n", tctime() - stime);
1296
+ iprintf("%s\n\n", err ? "error" : "ok");
1297
+ return err ? 1 : 0;
1298
+ }
1299
+
1300
+
1301
+ /* perform compare command */
1302
+ static int proccompare(const char *name, int tnum, int rnum){
1303
+ iprintf("<Comparison Test>\n seed=%u name=%s tnum=%d rnum=%d\n\n",
1304
+ g_randseed, name, tnum, rnum);
1305
+ bool err = false;
1306
+ double stime = tctime();
1307
+ char path[PATH_MAX];
1308
+ TCMDB *mdb = tcmdbnew2(rnum / 2);
1309
+ TCNDB *ndb = tcndbnew();
1310
+ TCHDB *hdb = tchdbnew();
1311
+ tchdbsetdbgfd(hdb, UINT16_MAX);
1312
+ int hopts = 0;
1313
+ if(myrand(2) == 1) hopts |= HDBTLARGE;
1314
+ if(myrand(2) == 1) hopts |= HDBTBZIP;
1315
+ if(!tchdbtune(hdb, rnum / 2, -1, -1, hopts)){
1316
+ eprint(NULL, __LINE__, "tchdbtune");
1317
+ err = true;
1318
+ }
1319
+ if(!tchdbsetcache(hdb, rnum / 10)){
1320
+ eprint(NULL, __LINE__, "tchdbsetcache");
1321
+ err = true;
1322
+ }
1323
+ if(!tchdbsetxmsiz(hdb, 4096)){
1324
+ eprint(NULL, __LINE__, "tchdbsetxmsiz");
1325
+ err = true;
1326
+ }
1327
+ if(!tchdbsetdfunit(hdb, 8)){
1328
+ eprint(NULL, __LINE__, "tchdbsetdfunit");
1329
+ err = true;
1330
+ }
1331
+ sprintf(path, "%s.tch", name);
1332
+ int homode = HDBOWRITER | HDBOCREAT | HDBOTRUNC;
1333
+ if(myrand(100) == 1) homode |= HDBOTSYNC;
1334
+ if(!tchdbopen(hdb, path, homode)){
1335
+ eprint(NULL, __LINE__, "tchdbopen");
1336
+ err = true;
1337
+ }
1338
+ TCBDB *bdb = tcbdbnew();
1339
+ tcbdbsetdbgfd(bdb, UINT16_MAX);
1340
+ int bopts = 0;
1341
+ if(myrand(2) == 1) bopts |= BDBTLARGE;
1342
+ if(myrand(2) == 1) bopts |= BDBTBZIP;
1343
+ if(!tcbdbtune(bdb, 5, 5, rnum / 10, -1, -1, bopts)){
1344
+ eprint(NULL, __LINE__, "tcbdbtune");
1345
+ err = true;
1346
+ }
1347
+ if(!tcbdbsetxmsiz(bdb, 4096)){
1348
+ eprint(NULL, __LINE__, "tcbdbsetxmsiz");
1349
+ err = true;
1350
+ }
1351
+ if(!tcbdbsetdfunit(bdb, 8)){
1352
+ eprint(NULL, __LINE__, "tcbdbsetdfunit");
1353
+ err = true;
1354
+ }
1355
+ sprintf(path, "%s.tcb", name);
1356
+ int bomode = BDBOWRITER | BDBOCREAT | BDBOTRUNC;
1357
+ if(myrand(100) == 1) bomode |= BDBOTSYNC;
1358
+ if(!tcbdbopen(bdb, path, bomode)){
1359
+ eprint(NULL, __LINE__, "tcbdbopen");
1360
+ err = true;
1361
+ }
1362
+ BDBCUR *cur = tcbdbcurnew(bdb);
1363
+ TCADB *adb = tcadbnew();
1364
+ switch(myrand(4)){
1365
+ case 0:
1366
+ sprintf(path, "%s.adb.tch#mode=wct#bnum=%d", name, rnum);
1367
+ break;
1368
+ case 1:
1369
+ sprintf(path, "%s.adb.tcb#mode=wct#lmemb=256#nmemb=512", name);
1370
+ break;
1371
+ case 2:
1372
+ sprintf(path, "+");
1373
+ break;
1374
+ default:
1375
+ sprintf(path, "*");
1376
+ break;
1377
+ }
1378
+ if(!tcadbopen(adb, path)){
1379
+ eprint(NULL, __LINE__, "tcbdbopen");
1380
+ err = true;
1381
+ }
1382
+ for(int t = 1; !err && t <= tnum; t++){
1383
+ bool commit = myrand(2) == 0;
1384
+ iprintf("transaction %d (%s):\n", t, commit ? "commit" : "abort");
1385
+ if(!tchdbtranbegin(hdb)){
1386
+ eprint(NULL, __LINE__, "tchdbtranbegin");
1387
+ err = true;
1388
+ }
1389
+ if(!tcbdbtranbegin(bdb)){
1390
+ eprint(NULL, __LINE__, "tcbdbtranbegin");
1391
+ err = true;
1392
+ }
1393
+ if(myrand(tnum) == 0){
1394
+ bool all = myrand(2) == 0;
1395
+ for(int i = 1; !err && i <= rnum; i++){
1396
+ char kbuf[RECBUFSIZ];
1397
+ int ksiz = sprintf(kbuf, "%d", all ? i : myrand(i) + 1);
1398
+ if(!tchdbout(hdb, kbuf, ksiz) && tchdbecode(hdb) != TCENOREC){
1399
+ eprint(NULL, __LINE__, "tchdbout");
1400
+ err = true;
1401
+ }
1402
+ if(!tcbdbout(bdb, kbuf, ksiz) && tcbdbecode(bdb) != TCENOREC){
1403
+ eprint(NULL, __LINE__, "tcbdbout");
1404
+ err = true;
1405
+ }
1406
+ tcadbout(adb, kbuf, ksiz);
1407
+ if(tchdbout(hdb, kbuf, ksiz) || tchdbecode(hdb) != TCENOREC){
1408
+ eprint(NULL, __LINE__, "(validation)");
1409
+ err = true;
1410
+ }
1411
+ if(tcbdbout(bdb, kbuf, ksiz) || tcbdbecode(bdb) != TCENOREC){
1412
+ eprint(NULL, __LINE__, "(validation)");
1413
+ err = true;
1414
+ }
1415
+ if(tcadbout(adb, kbuf, ksiz)){
1416
+ eprint(NULL, __LINE__, "(validation)");
1417
+ err = true;
1418
+ }
1419
+ if(commit){
1420
+ tcmdbout(mdb, kbuf, ksiz);
1421
+ tcndbout(ndb, kbuf, ksiz);
1422
+ }
1423
+ if(rnum > 250 && i % (rnum / 250) == 0){
1424
+ iputchar('.');
1425
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1426
+ }
1427
+ }
1428
+ } else {
1429
+ if(myrand(tnum + 1) == 0){
1430
+ if(!tchdbcacheclear(hdb)){
1431
+ eprint(NULL, __LINE__, "tchdbcacheclear");
1432
+ err = true;
1433
+ }
1434
+ if(!tcbdbcacheclear(bdb)){
1435
+ eprint(NULL, __LINE__, "tcbdbcacheclear");
1436
+ err = true;
1437
+ }
1438
+ }
1439
+ int cldeno = tnum * (rnum / 2) + 1;
1440
+ int act = myrand(7);
1441
+ for(int i = 1; !err && i <= rnum; i++){
1442
+ if(myrand(cldeno) == 0){
1443
+ if(!tchdbcacheclear(hdb)){
1444
+ eprint(NULL, __LINE__, "tchdbcacheclear");
1445
+ err = true;
1446
+ }
1447
+ if(!tcbdbcacheclear(bdb)){
1448
+ eprint(NULL, __LINE__, "tcbdbcacheclear");
1449
+ err = true;
1450
+ }
1451
+ }
1452
+ if(myrand(10) == 0) act = myrand(7);
1453
+ char kbuf[RECBUFSIZ];
1454
+ int ksiz = sprintf(kbuf, "%d", myrand(i) + 1);
1455
+ char vbuf[RECBUFSIZ+256];
1456
+ int vsiz = sprintf(vbuf, "%64d:%d:%d", t, i, myrand(i));
1457
+ switch(act){
1458
+ case 0:
1459
+ if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
1460
+ eprint(NULL, __LINE__, "tchdbput");
1461
+ err = true;
1462
+ }
1463
+ if(!tcbdbput(bdb, kbuf, ksiz, vbuf, vsiz)){
1464
+ eprint(NULL, __LINE__, "tcbdbput");
1465
+ err = true;
1466
+ }
1467
+ if(!tcadbput(adb, kbuf, ksiz, vbuf, vsiz)){
1468
+ eprint(NULL, __LINE__, "tcadbput");
1469
+ err = true;
1470
+ }
1471
+ if(commit){
1472
+ tcmdbput(mdb, kbuf, ksiz, vbuf, vsiz);
1473
+ tcndbput(ndb, kbuf, ksiz, vbuf, vsiz);
1474
+ }
1475
+ break;
1476
+ case 1:
1477
+ if(!tchdbputkeep(hdb, kbuf, ksiz, vbuf, vsiz) && tchdbecode(hdb) != TCEKEEP){
1478
+ eprint(NULL, __LINE__, "tchdbputkeep");
1479
+ err = true;
1480
+ }
1481
+ if(!tcbdbputkeep(bdb, kbuf, ksiz, vbuf, vsiz) && tcbdbecode(bdb) != TCEKEEP){
1482
+ eprint(NULL, __LINE__, "tcbdbputkeep");
1483
+ err = true;
1484
+ }
1485
+ tcadbputkeep(adb, kbuf, ksiz, vbuf, vsiz);
1486
+ if(commit){
1487
+ tcmdbputkeep(mdb, kbuf, ksiz, vbuf, vsiz);
1488
+ tcndbputkeep(ndb, kbuf, ksiz, vbuf, vsiz);
1489
+ }
1490
+ break;
1491
+ case 2:
1492
+ if(!tchdbputcat(hdb, kbuf, ksiz, vbuf, vsiz)){
1493
+ eprint(NULL, __LINE__, "tchdbputcat");
1494
+ err = true;
1495
+ }
1496
+ if(!tcbdbputcat(bdb, kbuf, ksiz, vbuf, vsiz)){
1497
+ eprint(NULL, __LINE__, "tcbdbputcat");
1498
+ err = true;
1499
+ }
1500
+ if(!tcadbputcat(adb, kbuf, ksiz, vbuf, vsiz)){
1501
+ eprint(NULL, __LINE__, "tcadbputcat");
1502
+ err = true;
1503
+ }
1504
+ if(commit){
1505
+ tcmdbputcat(mdb, kbuf, ksiz, vbuf, vsiz);
1506
+ tcndbputcat(ndb, kbuf, ksiz, vbuf, vsiz);
1507
+ }
1508
+ break;
1509
+ case 3:
1510
+ if(tchdbaddint(hdb, kbuf, ksiz, 1) == INT_MIN && tchdbecode(hdb) != TCEKEEP){
1511
+ eprint(NULL, __LINE__, "tchdbaddint");
1512
+ err = true;
1513
+ }
1514
+ if(tcbdbaddint(bdb, kbuf, ksiz, 1) == INT_MIN && tcbdbecode(bdb) != TCEKEEP){
1515
+ eprint(NULL, __LINE__, "tchdbaddint");
1516
+ err = true;
1517
+ }
1518
+ tcadbaddint(adb, kbuf, ksiz, 1);
1519
+ if(commit){
1520
+ tcmdbaddint(mdb, kbuf, ksiz, 1);
1521
+ tcndbaddint(ndb, kbuf, ksiz, 1);
1522
+ }
1523
+ break;
1524
+ case 4:
1525
+ if(isnan(tchdbadddouble(hdb, kbuf, ksiz, 1.0)) && tchdbecode(hdb) != TCEKEEP){
1526
+ eprint(NULL, __LINE__, "tchdbadddouble");
1527
+ err = true;
1528
+ }
1529
+ if(isnan(tcbdbadddouble(bdb, kbuf, ksiz, 1.0)) && tcbdbecode(bdb) != TCEKEEP){
1530
+ eprint(NULL, __LINE__, "tchdbadddouble");
1531
+ err = true;
1532
+ }
1533
+ tcadbadddouble(adb, kbuf, ksiz, 1.0);
1534
+ if(commit){
1535
+ tcmdbadddouble(mdb, kbuf, ksiz, 1.0);
1536
+ tcndbadddouble(ndb, kbuf, ksiz, 1.0);
1537
+ }
1538
+ break;
1539
+ case 5:
1540
+ if(myrand(2) == 0){
1541
+ if(!tchdbputproc(hdb, kbuf, ksiz, vbuf, vsiz, pdprocfunccmp, &i) &&
1542
+ tchdbecode(hdb) != TCEKEEP){
1543
+ eprint(NULL, __LINE__, "tchdbputproc");
1544
+ err = true;
1545
+ }
1546
+ if(!tcbdbputproc(bdb, kbuf, ksiz, vbuf, vsiz, pdprocfunccmp, &i) &&
1547
+ tcbdbecode(bdb) != TCEKEEP){
1548
+ eprint(NULL, __LINE__, "tcbdbputproc");
1549
+ err = true;
1550
+ }
1551
+ tcadbputproc(adb, kbuf, ksiz, vbuf, vsiz, pdprocfunccmp, &i);
1552
+ if(commit){
1553
+ tcmdbputproc(mdb, kbuf, ksiz, vbuf, vsiz, pdprocfunccmp, &i);
1554
+ tcndbputproc(ndb, kbuf, ksiz, vbuf, vsiz, pdprocfunccmp, &i);
1555
+ }
1556
+ } else {
1557
+ if(!tchdbputproc(hdb, kbuf, ksiz, NULL, 0, pdprocfunccmp, &i) &&
1558
+ tchdbecode(hdb) != TCEKEEP && tchdbecode(hdb) != TCENOREC){
1559
+ eprint(NULL, __LINE__, "tchdbputproc");
1560
+ err = true;
1561
+ }
1562
+ if(!tcbdbputproc(bdb, kbuf, ksiz, NULL, 0, pdprocfunccmp, &i) &&
1563
+ tcbdbecode(bdb) != TCEKEEP && tchdbecode(hdb) != TCENOREC){
1564
+ eprint(NULL, __LINE__, "tcbdbputproc");
1565
+ err = true;
1566
+ }
1567
+ tcadbputproc(adb, kbuf, ksiz, NULL, 0, pdprocfunccmp, &i);
1568
+ if(commit){
1569
+ tcmdbputproc(mdb, kbuf, ksiz, NULL, 0, pdprocfunccmp, &i);
1570
+ tcndbputproc(ndb, kbuf, ksiz, NULL, 0, pdprocfunccmp, &i);
1571
+ }
1572
+ }
1573
+ break;
1574
+ default:
1575
+ if(myrand(20) == 0){
1576
+ if(!tcbdbcurjump(cur, kbuf, ksiz) && tcbdbecode(bdb) != TCENOREC){
1577
+ eprint(NULL, __LINE__, "tcbdbcurjump");
1578
+ err = true;
1579
+ }
1580
+ char *cbuf;
1581
+ int csiz;
1582
+ while((cbuf = tcbdbcurkey(cur, &csiz)) != NULL){
1583
+ if(!tchdbout(hdb, cbuf, csiz)){
1584
+ eprint(NULL, __LINE__, "tchdbout");
1585
+ err = true;
1586
+ }
1587
+ if(!tcbdbout(bdb, cbuf, csiz)){
1588
+ eprint(NULL, __LINE__, "tcbdbout");
1589
+ err = true;
1590
+ }
1591
+ tcadbout(adb, cbuf, csiz);
1592
+ if(commit){
1593
+ tcmdbout(mdb, cbuf, csiz);
1594
+ tcndbout(ndb, cbuf, csiz);
1595
+ }
1596
+ tcfree(cbuf);
1597
+ if(myrand(10) == 0) break;
1598
+ switch(myrand(3)){
1599
+ case 1:
1600
+ if(!tcbdbcurprev(cur) && tcbdbecode(bdb) != TCENOREC){
1601
+ eprint(NULL, __LINE__, "tcbdbcurprev");
1602
+ err = true;
1603
+ }
1604
+ break;
1605
+ case 2:
1606
+ if(!tcbdbcurnext(cur) && tcbdbecode(bdb) != TCENOREC){
1607
+ eprint(NULL, __LINE__, "tcbdbcurprev");
1608
+ err = true;
1609
+ }
1610
+ break;
1611
+ }
1612
+ }
1613
+ } else {
1614
+ if(!tchdbout(hdb, kbuf, ksiz) && tchdbecode(hdb) != TCENOREC){
1615
+ eprint(NULL, __LINE__, "tchdbout");
1616
+ err = true;
1617
+ }
1618
+ if(!tcbdbout(bdb, kbuf, ksiz) && tcbdbecode(bdb) != TCENOREC){
1619
+ eprint(NULL, __LINE__, "tcbdbout");
1620
+ err = true;
1621
+ }
1622
+ tcadbout(adb, kbuf, ksiz);
1623
+ if(commit){
1624
+ tcmdbout(mdb, kbuf, ksiz);
1625
+ tcndbout(ndb, kbuf, ksiz);
1626
+ }
1627
+ }
1628
+ break;
1629
+ }
1630
+ if(rnum > 250 && i % (rnum / 250) == 0){
1631
+ iputchar('.');
1632
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1633
+ }
1634
+ }
1635
+ }
1636
+ if(commit){
1637
+ if(!tchdbtrancommit(hdb)){
1638
+ eprint(NULL, __LINE__, "tchdbcommit");
1639
+ err = true;
1640
+ }
1641
+ if(!tcbdbtrancommit(bdb)){
1642
+ eprint(NULL, __LINE__, "tcbdbcommit");
1643
+ err = true;
1644
+ }
1645
+ } else {
1646
+ if(myrand(5) == 0){
1647
+ if(!tchdbclose(hdb)){
1648
+ eprint(NULL, __LINE__, "tchdbclose");
1649
+ err = true;
1650
+ }
1651
+ sprintf(path, "%s.tch", name);
1652
+ if(!tchdbopen(hdb, path, HDBOWRITER)){
1653
+ eprint(NULL, __LINE__, "tchdbopen");
1654
+ err = true;
1655
+ }
1656
+ if(!tcbdbclose(bdb)){
1657
+ eprint(NULL, __LINE__, "tcbdbclose");
1658
+ err = true;
1659
+ }
1660
+ sprintf(path, "%s.tcb", name);
1661
+ if(!tcbdbopen(bdb, path, BDBOWRITER)){
1662
+ eprint(NULL, __LINE__, "tcbdbopen");
1663
+ err = true;
1664
+ }
1665
+ } else {
1666
+ if(!tchdbtranabort(hdb)){
1667
+ eprint(NULL, __LINE__, "tchdbtranabort");
1668
+ err = true;
1669
+ }
1670
+ if(!tcbdbtranabort(bdb)){
1671
+ eprint(NULL, __LINE__, "tcbdbtranabort");
1672
+ err = true;
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ iprintf("checking consistency of range:\n");
1678
+ for(int i = 1; i <= rnum; i++){
1679
+ char kbuf[RECBUFSIZ];
1680
+ int ksiz = sprintf(kbuf, "%d", i);
1681
+ int vsiz;
1682
+ char *vbuf = tcmdbget(mdb, kbuf, ksiz, &vsiz);
1683
+ if(vbuf){
1684
+ int rsiz;
1685
+ char *rbuf = tcndbget(ndb, kbuf, ksiz, &rsiz);
1686
+ if(rbuf){
1687
+ tcfree(rbuf);
1688
+ } else {
1689
+ eprint(NULL, __LINE__, "tcndbget");
1690
+ err = true;
1691
+ }
1692
+ rbuf = tchdbget(hdb, kbuf, ksiz, &rsiz);
1693
+ if(rbuf){
1694
+ tcfree(rbuf);
1695
+ } else {
1696
+ eprint(NULL, __LINE__, "tchdbget");
1697
+ err = true;
1698
+ }
1699
+ rbuf = tcbdbget(bdb, kbuf, ksiz, &rsiz);
1700
+ if(rbuf){
1701
+ tcfree(rbuf);
1702
+ } else {
1703
+ eprint(NULL, __LINE__, "tcbdbget");
1704
+ err = true;
1705
+ }
1706
+ tcfree(vbuf);
1707
+ } else {
1708
+ int rsiz;
1709
+ char *rbuf = tcndbget(ndb, kbuf, ksiz, &rsiz);
1710
+ if(rbuf){
1711
+ eprint(NULL, __LINE__, "tcndbget");
1712
+ tcfree(rbuf);
1713
+ err = true;
1714
+ }
1715
+ rbuf = tchdbget(hdb, kbuf, ksiz, &rsiz);
1716
+ if(rbuf){
1717
+ eprint(NULL, __LINE__, "tchdbget");
1718
+ err = true;
1719
+ tcfree(rbuf);
1720
+ }
1721
+ rbuf = tcbdbget(bdb, kbuf, ksiz, &rsiz);
1722
+ if(rbuf){
1723
+ eprint(NULL, __LINE__, "tcbdbget");
1724
+ err = true;
1725
+ tcfree(rbuf);
1726
+ }
1727
+ }
1728
+ if(rnum > 250 && i % (rnum / 250) == 0){
1729
+ iputchar('.');
1730
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1731
+ }
1732
+ }
1733
+ iprintf("checking consistency on memory:\n");
1734
+ if(tchdbrnum(hdb) != tcbdbrnum(bdb)){
1735
+ eprint(NULL, __LINE__, "(validation)");
1736
+ err = true;
1737
+ }
1738
+ int inum = 0;
1739
+ tcmdbiterinit(mdb);
1740
+ char *kbuf;
1741
+ int ksiz;
1742
+ for(int i = 1; (kbuf = tcmdbiternext(mdb, &ksiz)) != NULL; i++, inum++){
1743
+ int vsiz;
1744
+ char *vbuf = tcmdbget(mdb, kbuf, ksiz, &vsiz);
1745
+ int rsiz;
1746
+ char *rbuf = tcndbget(ndb, kbuf, ksiz, &rsiz);
1747
+ if(!vbuf || !rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1748
+ eprint(NULL, __LINE__, "tcndbget");
1749
+ err = true;
1750
+ }
1751
+ tcfree(rbuf);
1752
+ rbuf = tchdbget(hdb, kbuf, ksiz, &rsiz);
1753
+ if(!rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1754
+ eprint(NULL, __LINE__, "tchdbget");
1755
+ err = true;
1756
+ }
1757
+ tcfree(rbuf);
1758
+ rbuf = tcbdbget(bdb, kbuf, ksiz, &rsiz);
1759
+ if(!rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1760
+ eprint(NULL, __LINE__, "tcbdbget");
1761
+ err = true;
1762
+ }
1763
+ tcfree(rbuf);
1764
+ tcfree(vbuf);
1765
+ tcfree(kbuf);
1766
+ if(rnum > 250 && i % (rnum / 250) == 0){
1767
+ iputchar('.');
1768
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1769
+ }
1770
+ }
1771
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
1772
+ iprintf("checking consistency of hash:\n");
1773
+ inum = 0;
1774
+ if(!tchdbiterinit(hdb)){
1775
+ eprint(NULL, __LINE__, "tchdbiterinit");
1776
+ err = true;
1777
+ }
1778
+ for(int i = 1; (kbuf = tchdbiternext(hdb, &ksiz)) != NULL; i++, inum++){
1779
+ int vsiz;
1780
+ char *vbuf = tchdbget(hdb, kbuf, ksiz, &vsiz);
1781
+ int rsiz;
1782
+ char *rbuf = tcmdbget(mdb, kbuf, ksiz, &rsiz);
1783
+ if(!vbuf || !rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1784
+ eprint(NULL, __LINE__, "(validation)");
1785
+ err = true;
1786
+ }
1787
+ tcfree(rbuf);
1788
+ tcfree(vbuf);
1789
+ tcfree(kbuf);
1790
+ if(rnum > 250 && i % (rnum / 250) == 0){
1791
+ iputchar('.');
1792
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1793
+ }
1794
+ }
1795
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
1796
+ iprintf("checking consistency of tree:\n");
1797
+ if(!tcbdbcurfirst(cur) && tcbdbecode(bdb) != TCENOREC){
1798
+ eprint(NULL, __LINE__, "tcbdbcurfirst");
1799
+ err = true;
1800
+ }
1801
+ for(int i = 1; (kbuf = tcbdbcurkey(cur, &ksiz)) != NULL; i++, inum++){
1802
+ int vsiz;
1803
+ char *vbuf = tcbdbget(bdb, kbuf, ksiz, &vsiz);
1804
+ int rsiz;
1805
+ char *rbuf = tcndbget(ndb, kbuf, ksiz, &rsiz);
1806
+ if(!vbuf || !rbuf || rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
1807
+ eprint(NULL, __LINE__, "(validation)");
1808
+ err = true;
1809
+ }
1810
+ tcfree(rbuf);
1811
+ tcfree(vbuf);
1812
+ tcfree(kbuf);
1813
+ if(rnum > 250 && i % (rnum / 250) == 0){
1814
+ iputchar('.');
1815
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1816
+ }
1817
+ tcbdbcurnext(cur);
1818
+ }
1819
+ if(rnum > 250) iprintf(" (%08d)\n", inum);
1820
+ if(!tcadbclose(adb)){
1821
+ eprint(NULL, __LINE__, "tcadbclose");
1822
+ err = true;
1823
+ }
1824
+ tcbdbcurdel(cur);
1825
+ if(!tcbdbclose(bdb)){
1826
+ eprint(NULL, __LINE__, "tcbdbclose");
1827
+ err = true;
1828
+ }
1829
+ if(!tchdbclose(hdb)){
1830
+ eprint(NULL, __LINE__, "tcbdbclose");
1831
+ err = true;
1832
+ }
1833
+ tcadbdel(adb);
1834
+ tcmdbdel(mdb);
1835
+ tcndbdel(ndb);
1836
+ tchdbdel(hdb);
1837
+ tcbdbdel(bdb);
1838
+ iprintf("time: %.3f\n", tctime() - stime);
1839
+ iprintf("%s\n\n", err ? "error" : "ok");
1840
+ return err ? 1 : 0;
1841
+ }
1842
+
1843
+
1844
+
1845
+ // END OF FILE