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,1220 @@
1
+ /*************************************************************************************************
2
+ * The test cases of the fixed-length database API
3
+ * Copyright (C) 2006-2009 Mikio Hirabayashi
4
+ * This file is part of Tokyo Cabinet.
5
+ * Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
6
+ * the GNU Lesser General Public License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License or any later version. Tokyo Cabinet is distributed in the hope
8
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10
+ * License for more details.
11
+ * You should have received a copy of the GNU Lesser General Public License along with Tokyo
12
+ * Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
13
+ * Boston, MA 02111-1307 USA.
14
+ *************************************************************************************************/
15
+
16
+
17
+ #include <tcutil.h>
18
+ #include <tcfdb.h>
19
+ #include "myconf.h"
20
+
21
+ #define RECBUFSIZ 48 // buffer for records
22
+ #define EXHEADSIZ 256 // expected header size
23
+
24
+ typedef struct { // type of structure for write thread
25
+ TCFDB *fdb;
26
+ int rnum;
27
+ bool rnd;
28
+ int id;
29
+ } TARGWRITE;
30
+
31
+ typedef struct { // type of structure for read thread
32
+ TCFDB *fdb;
33
+ int rnum;
34
+ bool wb;
35
+ bool rnd;
36
+ int id;
37
+ } TARGREAD;
38
+
39
+ typedef struct { // type of structure for remove thread
40
+ TCFDB *fdb;
41
+ int rnum;
42
+ bool rnd;
43
+ int id;
44
+ } TARGREMOVE;
45
+
46
+ typedef struct { // type of structure for wicked thread
47
+ TCFDB *fdb;
48
+ int rnum;
49
+ bool nc;
50
+ int id;
51
+ TCMAP *map;
52
+ } TARGWICKED;
53
+
54
+ typedef struct { // type of structure for typical thread
55
+ TCFDB *fdb;
56
+ int rnum;
57
+ bool nc;
58
+ int rratio;
59
+ int id;
60
+ } TARGTYPICAL;
61
+
62
+
63
+ /* global variables */
64
+ const char *g_progname; // program name
65
+ unsigned int g_randseed; // random seed
66
+ int g_dbgfd; // debugging output
67
+
68
+
69
+ /* function prototypes */
70
+ int main(int argc, char **argv);
71
+ static void usage(void);
72
+ static void iprintf(const char *format, ...);
73
+ static void iputchar(int c);
74
+ static void eprint(TCFDB *fdb, int line, const char *func);
75
+ static void mprint(TCFDB *fdb);
76
+ static void sysprint(void);
77
+ static int myrand(int range);
78
+ static int myrandnd(int range);
79
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op);
80
+ static int runwrite(int argc, char **argv);
81
+ static int runread(int argc, char **argv);
82
+ static int runremove(int argc, char **argv);
83
+ static int runwicked(int argc, char **argv);
84
+ static int runtypical(int argc, char **argv);
85
+ static int procwrite(const char *path, int tnum, int rnum, int width, int64_t limsiz,
86
+ int omode, bool rnd);
87
+ static int procread(const char *path, int tnum, int omode, bool wb, bool rnd);
88
+ static int procremove(const char *path, int tnum, int omode, bool rnd);
89
+ static int procwicked(const char *path, int tnum, int rnum, int omode, bool nc);
90
+ static int proctypical(const char *path, int tnum, int rnum, int width, int64_t limsiz,
91
+ int omode, bool nc, int rratio);
92
+ static void *threadwrite(void *targ);
93
+ static void *threadread(void *targ);
94
+ static void *threadremove(void *targ);
95
+ static void *threadwicked(void *targ);
96
+ static void *threadtypical(void *targ);
97
+
98
+
99
+ /* main routine */
100
+ int main(int argc, char **argv){
101
+ g_progname = argv[0];
102
+ const char *ebuf = getenv("TCRNDSEED");
103
+ g_randseed = ebuf ? tcatoix(ebuf) : tctime() * 1000;
104
+ srand(g_randseed);
105
+ ebuf = getenv("TCDBGFD");
106
+ g_dbgfd = ebuf ? tcatoix(ebuf) : UINT16_MAX;
107
+ if(argc < 2) usage();
108
+ int rv = 0;
109
+ if(!strcmp(argv[1], "write")){
110
+ rv = runwrite(argc, argv);
111
+ } else if(!strcmp(argv[1], "read")){
112
+ rv = runread(argc, argv);
113
+ } else if(!strcmp(argv[1], "remove")){
114
+ rv = runremove(argc, argv);
115
+ } else if(!strcmp(argv[1], "wicked")){
116
+ rv = runwicked(argc, argv);
117
+ } else if(!strcmp(argv[1], "typical")){
118
+ rv = runtypical(argc, argv);
119
+ } else {
120
+ usage();
121
+ }
122
+ if(rv != 0){
123
+ printf("FAILED: TCRNDSEED=%u PID=%d", g_randseed, (int)getpid());
124
+ for(int i = 0; i < argc; i++){
125
+ printf(" %s", argv[i]);
126
+ }
127
+ printf("\n\n");
128
+ }
129
+ return rv;
130
+ }
131
+
132
+
133
+ /* print the usage and exit */
134
+ static void usage(void){
135
+ fprintf(stderr, "%s: test cases of the fixed-length database API of Tokyo Cabinet\n",
136
+ g_progname);
137
+ fprintf(stderr, "\n");
138
+ fprintf(stderr, "usage:\n");
139
+ fprintf(stderr, " %s write [-nl|-nb] [-rnd] path tnum rnum [width [limsiz]]\n", g_progname);
140
+ fprintf(stderr, " %s read [-nl|-nb] [-wb] [-rnd] path tnum\n", g_progname);
141
+ fprintf(stderr, " %s remove [-nl|-nb] [-rnd] path tnum\n", g_progname);
142
+ fprintf(stderr, " %s wicked [-nl|-nb] [-nc] path tnum rnum\n", g_progname);
143
+ fprintf(stderr, " %s typical [-nl|-nb] [-nc] [-rr num] path tnum rnum [width [limsiz]]\n",
144
+ g_progname);
145
+ fprintf(stderr, "\n");
146
+ exit(1);
147
+ }
148
+
149
+
150
+ /* print formatted information string and flush the buffer */
151
+ static void iprintf(const char *format, ...){
152
+ va_list ap;
153
+ va_start(ap, format);
154
+ vprintf(format, ap);
155
+ fflush(stdout);
156
+ va_end(ap);
157
+ }
158
+
159
+
160
+ /* print a character and flush the buffer */
161
+ static void iputchar(int c){
162
+ putchar(c);
163
+ fflush(stdout);
164
+ }
165
+
166
+
167
+ /* print error message of fixed-length database */
168
+ static void eprint(TCFDB *fdb, int line, const char *func){
169
+ const char *path = tcfdbpath(fdb);
170
+ int ecode = tcfdbecode(fdb);
171
+ fprintf(stderr, "%s: %s: %d: %s: error: %d: %s\n",
172
+ g_progname, path ? path : "-", line, func, ecode, tcfdberrmsg(ecode));
173
+ }
174
+
175
+
176
+ /* print members of fixed-length database */
177
+ static void mprint(TCFDB *fdb){
178
+ if(fdb->cnt_writerec < 0) return;
179
+ iprintf("minimum ID number: %llu\n", (unsigned long long)tcfdbmin(fdb));
180
+ iprintf("maximum ID number: %llu\n", (unsigned long long)tcfdbmax(fdb));
181
+ iprintf("width of the value: %u\n", (unsigned int)tcfdbwidth(fdb));
182
+ iprintf("limit file size: %llu\n", (unsigned long long)tcfdblimsiz(fdb));
183
+ iprintf("limit ID number: %llu\n", (unsigned long long)tcfdblimid(fdb));
184
+ iprintf("cnt_writerec: %lld\n", (long long)fdb->cnt_writerec);
185
+ iprintf("cnt_readrec: %lld\n", (long long)fdb->cnt_readrec);
186
+ iprintf("cnt_truncfile: %lld\n", (long long)fdb->cnt_truncfile);
187
+ }
188
+
189
+
190
+ /* print system information */
191
+ static void sysprint(void){
192
+ TCMAP *info = tcsysinfo();
193
+ if(info){
194
+ tcmapiterinit(info);
195
+ const char *kbuf;
196
+ while((kbuf = tcmapiternext2(info)) != NULL){
197
+ iprintf("sys_%s: %s\n", kbuf, tcmapiterval2(kbuf));
198
+ }
199
+ tcmapdel(info);
200
+ }
201
+ }
202
+
203
+
204
+ /* get a random number */
205
+ static int myrand(int range){
206
+ if(range < 2) return 0;
207
+ int high = (unsigned int)rand() >> 4;
208
+ int low = range * (rand() / (RAND_MAX + 1.0));
209
+ low &= (unsigned int)INT_MAX >> 4;
210
+ return (high + low) % range;
211
+ }
212
+
213
+
214
+ /* get a random number based on normal distribution */
215
+ static int myrandnd(int range){
216
+ int num = (int)tcdrandnd(range >> 1, range / 10);
217
+ return (num < 0 || num >= range) ? 0 : num;
218
+ }
219
+
220
+
221
+ /* iterator function */
222
+ static bool iterfunc(const void *kbuf, int ksiz, const void *vbuf, int vsiz, void *op){
223
+ unsigned int sum = 0;
224
+ while(--ksiz >= 0){
225
+ sum += ((char *)kbuf)[ksiz];
226
+ }
227
+ while(--vsiz >= 0){
228
+ sum += ((char *)vbuf)[vsiz];
229
+ }
230
+ return myrand(100 + (sum & 0xff)) > 0;
231
+ }
232
+
233
+
234
+ /* parse arguments of write command */
235
+ static int runwrite(int argc, char **argv){
236
+ char *path = NULL;
237
+ char *tstr = NULL;
238
+ char *rstr = NULL;
239
+ char *wstr = NULL;
240
+ char *lstr = NULL;
241
+ int omode = 0;
242
+ bool rnd = false;
243
+ for(int i = 2; i < argc; i++){
244
+ if(!path && argv[i][0] == '-'){
245
+ if(!strcmp(argv[i], "-nl")){
246
+ omode |= FDBONOLCK;
247
+ } else if(!strcmp(argv[i], "-nb")){
248
+ omode |= FDBOLCKNB;
249
+ } else if(!strcmp(argv[i], "-rnd")){
250
+ rnd = true;
251
+ } else {
252
+ usage();
253
+ }
254
+ } else if(!path){
255
+ path = argv[i];
256
+ } else if(!tstr){
257
+ tstr = argv[i];
258
+ } else if(!rstr){
259
+ rstr = argv[i];
260
+ } else if(!wstr){
261
+ wstr = argv[i];
262
+ } else if(!lstr){
263
+ lstr = argv[i];
264
+ } else {
265
+ usage();
266
+ }
267
+ }
268
+ if(!path || !tstr || !rstr) usage();
269
+ int tnum = tcatoix(tstr);
270
+ int rnum = tcatoix(rstr);
271
+ if(tnum < 1 || rnum < 1) usage();
272
+ int width = wstr ? tcatoix(wstr) : -1;
273
+ int64_t limsiz = lstr ? tcatoix(lstr) : -1;
274
+ int rv = procwrite(path, tnum, rnum, width, limsiz, omode, rnd);
275
+ return rv;
276
+ }
277
+
278
+
279
+ /* parse arguments of read command */
280
+ static int runread(int argc, char **argv){
281
+ char *path = NULL;
282
+ char *tstr = NULL;
283
+ int omode = 0;
284
+ bool wb = false;
285
+ bool rnd = false;
286
+ for(int i = 2; i < argc; i++){
287
+ if(!path && argv[i][0] == '-'){
288
+ if(!strcmp(argv[i], "-nl")){
289
+ omode |= FDBONOLCK;
290
+ } else if(!strcmp(argv[i], "-nb")){
291
+ omode |= FDBOLCKNB;
292
+ } else if(!strcmp(argv[i], "-wb")){
293
+ wb = true;
294
+ } else if(!strcmp(argv[i], "-rnd")){
295
+ rnd = true;
296
+ } else {
297
+ usage();
298
+ }
299
+ } else if(!path){
300
+ path = argv[i];
301
+ } else if(!tstr){
302
+ tstr = argv[i];
303
+ } else {
304
+ usage();
305
+ }
306
+ }
307
+ if(!path || !tstr) usage();
308
+ int tnum = tcatoix(tstr);
309
+ if(tnum < 1) usage();
310
+ int rv = procread(path, tnum, omode, wb, rnd);
311
+ return rv;
312
+ }
313
+
314
+
315
+ /* parse arguments of remove command */
316
+ static int runremove(int argc, char **argv){
317
+ char *path = NULL;
318
+ char *tstr = NULL;
319
+ int omode = 0;
320
+ bool rnd = false;
321
+ for(int i = 2; i < argc; i++){
322
+ if(!path && argv[i][0] == '-'){
323
+ if(!strcmp(argv[i], "-nl")){
324
+ omode |= FDBONOLCK;
325
+ } else if(!strcmp(argv[i], "-nb")){
326
+ omode |= FDBOLCKNB;
327
+ } else if(!strcmp(argv[i], "-rnd")){
328
+ rnd = true;
329
+ } else {
330
+ usage();
331
+ }
332
+ } else if(!path){
333
+ path = argv[i];
334
+ } else if(!tstr){
335
+ tstr = argv[i];
336
+ } else {
337
+ usage();
338
+ }
339
+ }
340
+ if(!path || !tstr) usage();
341
+ int tnum = tcatoix(tstr);
342
+ if(tnum < 1) usage();
343
+ int rv = procremove(path, tnum, omode, rnd);
344
+ return rv;
345
+ }
346
+
347
+
348
+ /* parse arguments of wicked command */
349
+ static int runwicked(int argc, char **argv){
350
+ char *path = NULL;
351
+ char *tstr = NULL;
352
+ char *rstr = NULL;
353
+ int omode = 0;
354
+ bool nc = false;
355
+ for(int i = 2; i < argc; i++){
356
+ if(!path && argv[i][0] == '-'){
357
+ if(!strcmp(argv[i], "-nl")){
358
+ omode |= FDBONOLCK;
359
+ } else if(!strcmp(argv[i], "-nb")){
360
+ omode |= FDBOLCKNB;
361
+ } else if(!strcmp(argv[i], "-nc")){
362
+ nc = true;
363
+ } else {
364
+ usage();
365
+ }
366
+ } else if(!path){
367
+ path = argv[i];
368
+ } else if(!tstr){
369
+ tstr = argv[i];
370
+ } else if(!rstr){
371
+ rstr = argv[i];
372
+ } else {
373
+ usage();
374
+ }
375
+ }
376
+ if(!path || !tstr || !rstr) usage();
377
+ int tnum = tcatoix(tstr);
378
+ int rnum = tcatoix(rstr);
379
+ if(tnum < 1 || rnum < 1) usage();
380
+ int rv = procwicked(path, tnum, rnum, omode, nc);
381
+ return rv;
382
+ }
383
+
384
+
385
+ /* parse arguments of typical command */
386
+ static int runtypical(int argc, char **argv){
387
+ char *path = NULL;
388
+ char *tstr = NULL;
389
+ char *rstr = NULL;
390
+ char *wstr = NULL;
391
+ char *lstr = NULL;
392
+ int omode = 0;
393
+ int rratio = -1;
394
+ bool nc = false;
395
+ for(int i = 2; i < argc; i++){
396
+ if(!path && argv[i][0] == '-'){
397
+ if(!strcmp(argv[i], "-nl")){
398
+ omode |= FDBONOLCK;
399
+ } else if(!strcmp(argv[i], "-nb")){
400
+ omode |= FDBOLCKNB;
401
+ } else if(!strcmp(argv[i], "-nc")){
402
+ nc = true;
403
+ } else if(!strcmp(argv[i], "-rr")){
404
+ if(++i >= argc) usage();
405
+ rratio = tcatoix(argv[i]);
406
+ } else {
407
+ usage();
408
+ }
409
+ } else if(!path){
410
+ path = argv[i];
411
+ } else if(!tstr){
412
+ tstr = argv[i];
413
+ } else if(!rstr){
414
+ rstr = argv[i];
415
+ } else if(!wstr){
416
+ wstr = argv[i];
417
+ } else if(!lstr){
418
+ lstr = argv[i];
419
+ } else {
420
+ usage();
421
+ }
422
+ }
423
+ if(!path || !tstr || !rstr) usage();
424
+ int tnum = tcatoix(tstr);
425
+ int rnum = tcatoix(rstr);
426
+ if(tnum < 1 || rnum < 1) usage();
427
+ int width = wstr ? tcatoix(wstr) : -1;
428
+ int64_t limsiz = lstr ? tcatoix(lstr) : -1;
429
+ int rv = proctypical(path, tnum, rnum, width, limsiz, omode, nc, rratio);
430
+ return rv;
431
+ }
432
+
433
+
434
+ /* perform write command */
435
+ static int procwrite(const char *path, int tnum, int rnum, int width, int64_t limsiz,
436
+ int omode, bool rnd){
437
+ iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d width=%d limsiz=%lld"
438
+ " omode=%d rnd=%d\n\n",
439
+ g_randseed, path, tnum, rnum, width, (long long)limsiz, omode, rnd);
440
+ bool err = false;
441
+ double stime = tctime();
442
+ TCFDB *fdb = tcfdbnew();
443
+ if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
444
+ if(!tcfdbsetmutex(fdb)){
445
+ eprint(fdb, __LINE__, "tcfdbsetmutex");
446
+ err = true;
447
+ }
448
+ if(!tcfdbtune(fdb, width, limsiz)){
449
+ eprint(fdb, __LINE__, "tcfdbtune");
450
+ err = true;
451
+ }
452
+ if(!tcfdbopen(fdb, path, FDBOWRITER | FDBOCREAT | FDBOTRUNC | omode)){
453
+ eprint(fdb, __LINE__, "tcfdbopen");
454
+ err = true;
455
+ }
456
+ TARGWRITE targs[tnum];
457
+ pthread_t threads[tnum];
458
+ if(tnum == 1){
459
+ targs[0].fdb = fdb;
460
+ targs[0].rnum = rnum;
461
+ targs[0].rnd = rnd;
462
+ targs[0].id = 0;
463
+ if(threadwrite(targs) != NULL) err = true;
464
+ } else {
465
+ for(int i = 0; i < tnum; i++){
466
+ targs[i].fdb = fdb;
467
+ targs[i].rnum = rnum;
468
+ targs[i].rnd = rnd;
469
+ targs[i].id = i;
470
+ if(pthread_create(threads + i, NULL, threadwrite, targs + i) != 0){
471
+ eprint(fdb, __LINE__, "pthread_create");
472
+ targs[i].id = -1;
473
+ err = true;
474
+ }
475
+ }
476
+ for(int i = 0; i < tnum; i++){
477
+ if(targs[i].id == -1) continue;
478
+ void *rv;
479
+ if(pthread_join(threads[i], &rv) != 0){
480
+ eprint(fdb, __LINE__, "pthread_join");
481
+ err = true;
482
+ } else if(rv){
483
+ err = true;
484
+ }
485
+ }
486
+ }
487
+ iprintf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
488
+ iprintf("size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
489
+ mprint(fdb);
490
+ sysprint();
491
+ if(!tcfdbclose(fdb)){
492
+ eprint(fdb, __LINE__, "tcfdbclose");
493
+ err = true;
494
+ }
495
+ tcfdbdel(fdb);
496
+ iprintf("time: %.3f\n", tctime() - stime);
497
+ iprintf("%s\n\n", err ? "error" : "ok");
498
+ return err ? 1 : 0;
499
+ }
500
+
501
+
502
+ /* perform read command */
503
+ static int procread(const char *path, int tnum, int omode, bool wb, bool rnd){
504
+ iprintf("<Reading Test>\n seed=%u path=%s tnum=%d omode=%d wb=%d rnd=%d\n\n",
505
+ g_randseed, path, tnum, omode, wb, rnd);
506
+ bool err = false;
507
+ double stime = tctime();
508
+ TCFDB *fdb = tcfdbnew();
509
+ if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
510
+ if(!tcfdbsetmutex(fdb)){
511
+ eprint(fdb, __LINE__, "tcfdbsetmutex");
512
+ err = true;
513
+ }
514
+ if(!tcfdbopen(fdb, path, FDBOREADER | omode)){
515
+ eprint(fdb, __LINE__, "tcfdbopen");
516
+ err = true;
517
+ }
518
+ int rnum = tcfdbrnum(fdb) / tnum;
519
+ TARGREAD targs[tnum];
520
+ pthread_t threads[tnum];
521
+ if(tnum == 1){
522
+ targs[0].fdb = fdb;
523
+ targs[0].rnum = rnum;
524
+ targs[0].wb = wb;
525
+ targs[0].rnd = rnd;
526
+ targs[0].id = 0;
527
+ if(threadread(targs) != NULL) err = true;
528
+ } else {
529
+ for(int i = 0; i < tnum; i++){
530
+ targs[i].fdb = fdb;
531
+ targs[i].rnum = rnum;
532
+ targs[i].wb = wb;
533
+ targs[i].rnd = rnd;
534
+ targs[i].id = i;
535
+ if(pthread_create(threads + i, NULL, threadread, targs + i) != 0){
536
+ eprint(fdb, __LINE__, "pthread_create");
537
+ targs[i].id = -1;
538
+ err = true;
539
+ }
540
+ }
541
+ for(int i = 0; i < tnum; i++){
542
+ if(targs[i].id == -1) continue;
543
+ void *rv;
544
+ if(pthread_join(threads[i], &rv) != 0){
545
+ eprint(fdb, __LINE__, "pthread_join");
546
+ err = true;
547
+ } else if(rv){
548
+ err = true;
549
+ }
550
+ }
551
+ }
552
+ iprintf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
553
+ iprintf("size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
554
+ mprint(fdb);
555
+ sysprint();
556
+ if(!tcfdbclose(fdb)){
557
+ eprint(fdb, __LINE__, "tcfdbclose");
558
+ err = true;
559
+ }
560
+ tcfdbdel(fdb);
561
+ iprintf("time: %.3f\n", tctime() - stime);
562
+ iprintf("%s\n\n", err ? "error" : "ok");
563
+ return err ? 1 : 0;
564
+ }
565
+
566
+
567
+ /* perform remove command */
568
+ static int procremove(const char *path, int tnum, int omode, bool rnd){
569
+ iprintf("<Removing Test>\n seed=%u path=%s tnum=%d omode=%d rnd=%d\n\n",
570
+ g_randseed, path, tnum, omode, rnd);
571
+ bool err = false;
572
+ double stime = tctime();
573
+ TCFDB *fdb = tcfdbnew();
574
+ if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
575
+ if(!tcfdbsetmutex(fdb)){
576
+ eprint(fdb, __LINE__, "tcfdbsetmutex");
577
+ err = true;
578
+ }
579
+ if(!tcfdbopen(fdb, path, FDBOWRITER | omode)){
580
+ eprint(fdb, __LINE__, "tcfdbopen");
581
+ err = true;
582
+ }
583
+ int rnum = tcfdbrnum(fdb) / tnum;
584
+ TARGREMOVE targs[tnum];
585
+ pthread_t threads[tnum];
586
+ if(tnum == 1){
587
+ targs[0].fdb = fdb;
588
+ targs[0].rnum = rnum;
589
+ targs[0].rnd = rnd;
590
+ targs[0].id = 0;
591
+ if(threadremove(targs) != NULL) err = true;
592
+ } else {
593
+ for(int i = 0; i < tnum; i++){
594
+ targs[i].fdb = fdb;
595
+ targs[i].rnum = rnum;
596
+ targs[i].rnd = rnd;
597
+ targs[i].id = i;
598
+ if(pthread_create(threads + i, NULL, threadremove, targs + i) != 0){
599
+ eprint(fdb, __LINE__, "pthread_create");
600
+ targs[i].id = -1;
601
+ err = true;
602
+ }
603
+ }
604
+ for(int i = 0; i < tnum; i++){
605
+ if(targs[i].id == -1) continue;
606
+ void *rv;
607
+ if(pthread_join(threads[i], &rv) != 0){
608
+ eprint(fdb, __LINE__, "pthread_join");
609
+ err = true;
610
+ } else if(rv){
611
+ err = true;
612
+ }
613
+ }
614
+ }
615
+ iprintf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
616
+ iprintf("size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
617
+ mprint(fdb);
618
+ sysprint();
619
+ if(!tcfdbclose(fdb)){
620
+ eprint(fdb, __LINE__, "tcfdbclose");
621
+ err = true;
622
+ }
623
+ tcfdbdel(fdb);
624
+ iprintf("time: %.3f\n", tctime() - stime);
625
+ iprintf("%s\n\n", err ? "error" : "ok");
626
+ return err ? 1 : 0;
627
+ }
628
+
629
+
630
+ /* perform wicked command */
631
+ static int procwicked(const char *path, int tnum, int rnum, int omode, bool nc){
632
+ iprintf("<Writing Test>\n seed=%u path=%s tnum=%d rnum=%d omode=%d nc=%d\n\n",
633
+ g_randseed, path, tnum, rnum, omode, nc);
634
+ bool err = false;
635
+ double stime = tctime();
636
+ TCFDB *fdb = tcfdbnew();
637
+ if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
638
+ if(!tcfdbsetmutex(fdb)){
639
+ eprint(fdb, __LINE__, "tcfdbsetmutex");
640
+ err = true;
641
+ }
642
+ if(!tcfdbtune(fdb, RECBUFSIZ * 2, EXHEADSIZ + (RECBUFSIZ * 2 + sizeof(int)) * rnum * tnum)){
643
+ eprint(fdb, __LINE__, "tcfdbtune");
644
+ err = true;
645
+ }
646
+ if(!tcfdbopen(fdb, path, FDBOWRITER | FDBOCREAT | FDBOTRUNC | omode)){
647
+ eprint(fdb, __LINE__, "tcfdbopen");
648
+ err = true;
649
+ }
650
+ if(!tcfdbiterinit(fdb)){
651
+ eprint(fdb, __LINE__, "tcfdbiterinit");
652
+ err = true;
653
+ }
654
+ TARGWICKED targs[tnum];
655
+ pthread_t threads[tnum];
656
+ TCMAP *map = tcmapnew();
657
+ if(tnum == 1){
658
+ targs[0].fdb = fdb;
659
+ targs[0].rnum = rnum;
660
+ targs[0].nc = nc;
661
+ targs[0].id = 0;
662
+ targs[0].map = map;
663
+ if(threadwicked(targs) != NULL) err = true;
664
+ } else {
665
+ for(int i = 0; i < tnum; i++){
666
+ targs[i].fdb = fdb;
667
+ targs[i].rnum = rnum;
668
+ targs[i].nc = nc;
669
+ targs[i].id = i;
670
+ targs[i].map = map;
671
+ if(pthread_create(threads + i, NULL, threadwicked, targs + i) != 0){
672
+ eprint(fdb, __LINE__, "pthread_create");
673
+ targs[i].id = -1;
674
+ err = true;
675
+ }
676
+ }
677
+ for(int i = 0; i < tnum; i++){
678
+ if(targs[i].id == -1) continue;
679
+ void *rv;
680
+ if(pthread_join(threads[i], &rv) != 0){
681
+ eprint(fdb, __LINE__, "pthread_join");
682
+ err = true;
683
+ } else if(rv){
684
+ err = true;
685
+ }
686
+ }
687
+ }
688
+ if(!nc){
689
+ if(!tcfdbsync(fdb)){
690
+ eprint(fdb, __LINE__, "tcfdbsync");
691
+ err = true;
692
+ }
693
+ if(tcfdbrnum(fdb) != tcmaprnum(map)){
694
+ eprint(fdb, __LINE__, "(validation)");
695
+ err = true;
696
+ }
697
+ int end = rnum * tnum;
698
+ for(int i = 1; i <= end && !err; i++){
699
+ char kbuf[RECBUFSIZ];
700
+ int ksiz = sprintf(kbuf, "%d", i);
701
+ int vsiz;
702
+ const char *vbuf = tcmapget(map, kbuf, ksiz, &vsiz);
703
+ int rsiz;
704
+ char *rbuf = tcfdbget2(fdb, kbuf, ksiz, &rsiz);
705
+ if(vbuf){
706
+ iputchar('.');
707
+ if(vsiz > tcfdbwidth(fdb)) vsiz = tcfdbwidth(fdb);
708
+ if(!rbuf){
709
+ eprint(fdb, __LINE__, "tcfdbget");
710
+ err = true;
711
+ } else if(rsiz != vsiz || memcmp(rbuf, vbuf, rsiz)){
712
+ eprint(fdb, __LINE__, "(validation)");
713
+ err = true;
714
+ }
715
+ } else {
716
+ iputchar('*');
717
+ if(rbuf || tcfdbecode(fdb) != TCENOREC){
718
+ eprint(fdb, __LINE__, "(validation)");
719
+ err = true;
720
+ }
721
+ }
722
+ tcfree(rbuf);
723
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
724
+ }
725
+ if(rnum % 50 > 0) iprintf(" (%08d)\n", rnum);
726
+ }
727
+ tcmapdel(map);
728
+ iprintf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
729
+ iprintf("size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
730
+ mprint(fdb);
731
+ sysprint();
732
+ if(!tcfdbclose(fdb)){
733
+ eprint(fdb, __LINE__, "tcfdbclose");
734
+ err = true;
735
+ }
736
+ tcfdbdel(fdb);
737
+ iprintf("time: %.3f\n", tctime() - stime);
738
+ iprintf("%s\n\n", err ? "error" : "ok");
739
+ return err ? 1 : 0;
740
+ }
741
+
742
+
743
+ /* perform typical command */
744
+ static int proctypical(const char *path, int tnum, int rnum, int width, int64_t limsiz,
745
+ int omode, bool nc, int rratio){
746
+ iprintf("<Typical Access Test>\n seed=%u path=%s tnum=%d rnum=%d width=%d limsiz=%lld"
747
+ " omode=%d nc=%d rratio=%d\n\n",
748
+ g_randseed, path, tnum, rnum, width, (long long)limsiz, omode, nc, rratio);
749
+ bool err = false;
750
+ double stime = tctime();
751
+ TCFDB *fdb = tcfdbnew();
752
+ if(g_dbgfd >= 0) tcfdbsetdbgfd(fdb, g_dbgfd);
753
+ if(!tcfdbsetmutex(fdb)){
754
+ eprint(fdb, __LINE__, "tcfdbsetmutex");
755
+ err = true;
756
+ }
757
+ if(!tcfdbtune(fdb, width, limsiz)){
758
+ eprint(fdb, __LINE__, "tcfdbtune");
759
+ err = true;
760
+ }
761
+ if(!tcfdbopen(fdb, path, FDBOWRITER | FDBOCREAT | FDBOTRUNC | omode)){
762
+ eprint(fdb, __LINE__, "tcfdbopen");
763
+ err = true;
764
+ }
765
+ TARGTYPICAL targs[tnum];
766
+ pthread_t threads[tnum];
767
+ if(tnum == 1){
768
+ targs[0].fdb = fdb;
769
+ targs[0].rnum = rnum;
770
+ targs[0].nc = nc;
771
+ targs[0].rratio = rratio;
772
+ targs[0].id = 0;
773
+ if(threadtypical(targs) != NULL) err = true;
774
+ } else {
775
+ for(int i = 0; i < tnum; i++){
776
+ targs[i].fdb = fdb;
777
+ targs[i].rnum = rnum;
778
+ targs[i].nc = nc;
779
+ targs[i].rratio= rratio;
780
+ targs[i].id = i;
781
+ if(pthread_create(threads + i, NULL, threadtypical, targs + i) != 0){
782
+ eprint(fdb, __LINE__, "pthread_create");
783
+ targs[i].id = -1;
784
+ err = true;
785
+ }
786
+ }
787
+ for(int i = 0; i < tnum; i++){
788
+ if(targs[i].id == -1) continue;
789
+ void *rv;
790
+ if(pthread_join(threads[i], &rv) != 0){
791
+ eprint(fdb, __LINE__, "pthread_join");
792
+ err = true;
793
+ } else if(rv){
794
+ err = true;
795
+ }
796
+ }
797
+ }
798
+ iprintf("record number: %llu\n", (unsigned long long)tcfdbrnum(fdb));
799
+ iprintf("size: %llu\n", (unsigned long long)tcfdbfsiz(fdb));
800
+ mprint(fdb);
801
+ sysprint();
802
+ if(!tcfdbclose(fdb)){
803
+ eprint(fdb, __LINE__, "tcfdbclose");
804
+ err = true;
805
+ }
806
+ tcfdbdel(fdb);
807
+ iprintf("time: %.3f\n", tctime() - stime);
808
+ iprintf("%s\n\n", err ? "error" : "ok");
809
+ return err ? 1 : 0;
810
+ }
811
+
812
+
813
+ /* thread the write function */
814
+ static void *threadwrite(void *targ){
815
+ TCFDB *fdb = ((TARGWRITE *)targ)->fdb;
816
+ int rnum = ((TARGWRITE *)targ)->rnum;
817
+ bool rnd = ((TARGWRITE *)targ)->rnd;
818
+ int id = ((TARGWRITE *)targ)->id;
819
+ bool err = false;
820
+ int base = id * rnum;
821
+ for(int i = 1; i <= rnum; i++){
822
+ char buf[RECBUFSIZ];
823
+ int len = sprintf(buf, "%08d", base + (rnd ? myrand(i) + 1 : i));
824
+ if(!tcfdbput2(fdb, buf, len, buf, len)){
825
+ eprint(fdb, __LINE__, "tcfdbput2");
826
+ err = true;
827
+ break;
828
+ }
829
+ if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
830
+ iputchar('.');
831
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
832
+ }
833
+ }
834
+ return err ? "error" : NULL;
835
+ }
836
+
837
+
838
+ /* thread the read function */
839
+ static void *threadread(void *targ){
840
+ TCFDB *fdb = ((TARGREAD *)targ)->fdb;
841
+ int rnum = ((TARGREAD *)targ)->rnum;
842
+ bool wb = ((TARGREAD *)targ)->wb;
843
+ bool rnd = ((TARGREAD *)targ)->rnd;
844
+ int id = ((TARGREAD *)targ)->id;
845
+ bool err = false;
846
+ int base = id * rnum;
847
+ for(int i = 1; i <= rnum && !err; i++){
848
+ uint64_t kid = base + (rnd ? myrandnd(i) + 1 : i);
849
+ int vsiz;
850
+ if(wb){
851
+ char vbuf[RECBUFSIZ];
852
+ int vsiz = tcfdbget4(fdb, kid, vbuf, RECBUFSIZ);
853
+ if(vsiz < 0 && (!rnd || tcfdbecode(fdb) != TCENOREC)){
854
+ eprint(fdb, __LINE__, "tcfdbget4");
855
+ err = true;
856
+ }
857
+ } else {
858
+ char *vbuf = tcfdbget(fdb, kid, &vsiz);
859
+ if(!vbuf && (!rnd || tcfdbecode(fdb) != TCENOREC)){
860
+ eprint(fdb, __LINE__, "tcfdbget");
861
+ err = true;
862
+ }
863
+ tcfree(vbuf);
864
+ }
865
+ if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
866
+ iputchar('.');
867
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
868
+ }
869
+ }
870
+ return err ? "error" : NULL;
871
+ }
872
+
873
+
874
+ /* thread the remove function */
875
+ static void *threadremove(void *targ){
876
+ TCFDB *fdb = ((TARGREMOVE *)targ)->fdb;
877
+ int rnum = ((TARGREMOVE *)targ)->rnum;
878
+ bool rnd = ((TARGREMOVE *)targ)->rnd;
879
+ int id = ((TARGREMOVE *)targ)->id;
880
+ bool err = false;
881
+ int base = id * rnum;
882
+ for(int i = 1; i <= rnum; i++){
883
+ char kbuf[RECBUFSIZ];
884
+ int ksiz = sprintf(kbuf, "%08d", base + (rnd ? myrand(i + 1) + 1 : i));
885
+ if(!tcfdbout2(fdb, kbuf, ksiz) && (!rnd || tcfdbecode(fdb) != TCENOREC)){
886
+ eprint(fdb, __LINE__, "tcfdbout2");
887
+ err = true;
888
+ break;
889
+ }
890
+ if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
891
+ iputchar('.');
892
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
893
+ }
894
+ }
895
+ return err ? "error" : NULL;
896
+ }
897
+
898
+
899
+ /* thread the wicked function */
900
+ static void *threadwicked(void *targ){
901
+ TCFDB *fdb = ((TARGWICKED *)targ)->fdb;
902
+ int rnum = ((TARGWICKED *)targ)->rnum;
903
+ bool nc = ((TARGWICKED *)targ)->nc;
904
+ int id = ((TARGWICKED *)targ)->id;
905
+ TCMAP *map = ((TARGWICKED *)targ)->map;
906
+ bool err = false;
907
+ for(int i = 1; i <= rnum && !err; i++){
908
+ uint64_t kid = myrand(rnum * (id + 1)) + 1;
909
+ char kbuf[RECBUFSIZ];
910
+ int ksiz = sprintf(kbuf, "%llu", (unsigned long long)kid);
911
+ char vbuf[RECBUFSIZ];
912
+ int vsiz = myrand(RECBUFSIZ);
913
+ memset(vbuf, '*', vsiz);
914
+ vbuf[vsiz] = '\0';
915
+ char *rbuf;
916
+ if(!nc) tcglobalmutexlock();
917
+ switch(myrand(16)){
918
+ case 0:
919
+ if(id == 0) iputchar('0');
920
+ if(!tcfdbput2(fdb, kbuf, ksiz, vbuf, vsiz)){
921
+ eprint(fdb, __LINE__, "tcfdbput2");
922
+ err = true;
923
+ }
924
+ if(!nc) tcmapput(map, kbuf, ksiz, vbuf, vsiz);
925
+ break;
926
+ case 1:
927
+ if(id == 0) iputchar('1');
928
+ if(!tcfdbput3(fdb, kbuf, vbuf)){
929
+ eprint(fdb, __LINE__, "tcfdbput3");
930
+ err = true;
931
+ }
932
+ if(!nc) tcmapput2(map, kbuf, vbuf);
933
+ break;
934
+ case 2:
935
+ if(id == 0) iputchar('2');
936
+ if(!tcfdbputkeep2(fdb, kbuf, ksiz, vbuf, vsiz) && tcfdbecode(fdb) != TCEKEEP){
937
+ eprint(fdb, __LINE__, "tcfdbputkeep2");
938
+ err = true;
939
+ }
940
+ if(!nc) tcmapputkeep(map, kbuf, ksiz, vbuf, vsiz);
941
+ break;
942
+ case 3:
943
+ if(id == 0) iputchar('3');
944
+ if(!tcfdbputkeep3(fdb, kbuf, vbuf) && tcfdbecode(fdb) != TCEKEEP){
945
+ eprint(fdb, __LINE__, "tcfdbputkeep3");
946
+ err = true;
947
+ }
948
+ if(!nc) tcmapputkeep2(map, kbuf, vbuf);
949
+ break;
950
+ case 4:
951
+ if(id == 0) iputchar('4');
952
+ if(!tcfdbputcat2(fdb, kbuf, ksiz, vbuf, vsiz)){
953
+ eprint(fdb, __LINE__, "tcfdbputcat2");
954
+ err = true;
955
+ }
956
+ if(!nc) tcmapputcat(map, kbuf, ksiz, vbuf, vsiz);
957
+ break;
958
+ case 5:
959
+ if(id == 0) iputchar('5');
960
+ if(!tcfdbputcat3(fdb, kbuf, vbuf)){
961
+ eprint(fdb, __LINE__, "tcfdbputcat3");
962
+ err = true;
963
+ }
964
+ if(!nc) tcmapputcat2(map, kbuf, vbuf);
965
+ break;
966
+ case 6:
967
+ if(id == 0) iputchar('6');
968
+ if(myrand(2) == 0){
969
+ if(!tcfdbout2(fdb, kbuf, ksiz) && tcfdbecode(fdb) != TCENOREC){
970
+ eprint(fdb, __LINE__, "tcfdbout2");
971
+ err = true;
972
+ }
973
+ if(!nc) tcmapout(map, kbuf, ksiz);
974
+ }
975
+ break;
976
+ case 7:
977
+ if(id == 0) iputchar('7');
978
+ if(myrand(2) == 0){
979
+ if(!tcfdbout3(fdb, kbuf) && tcfdbecode(fdb) != TCENOREC){
980
+ eprint(fdb, __LINE__, "tcfdbout3");
981
+ err = true;
982
+ }
983
+ if(!nc) tcmapout2(map, kbuf);
984
+ }
985
+ break;
986
+ case 8:
987
+ if(id == 0) iputchar('8');
988
+ if(!(rbuf = tcfdbget2(fdb, kbuf, ksiz, &vsiz))){
989
+ if(tcfdbecode(fdb) != TCENOREC){
990
+ eprint(fdb, __LINE__, "tcfdbget2");
991
+ err = true;
992
+ }
993
+ rbuf = tcsprintf("[%d]", myrand(i + 1));
994
+ vsiz = strlen(rbuf);
995
+ }
996
+ vsiz += myrand(vsiz);
997
+ if(myrand(3) == 0) vsiz += PATH_MAX;
998
+ rbuf = tcrealloc(rbuf, vsiz + 1);
999
+ for(int j = 0; j < vsiz; j++){
1000
+ rbuf[j] = myrand(0x100);
1001
+ }
1002
+ if(!tcfdbput2(fdb, kbuf, ksiz, rbuf, vsiz)){
1003
+ eprint(fdb, __LINE__, "tcfdbput2");
1004
+ err = true;
1005
+ }
1006
+ if(!nc) tcmapput(map, kbuf, ksiz, rbuf, vsiz);
1007
+ tcfree(rbuf);
1008
+ break;
1009
+ case 9:
1010
+ if(id == 0) iputchar('9');
1011
+ if(!(rbuf = tcfdbget2(fdb, kbuf, ksiz, &vsiz)) && tcfdbecode(fdb) != TCENOREC){
1012
+ eprint(fdb, __LINE__, "tcfdbget2");
1013
+ err = true;
1014
+ }
1015
+ tcfree(rbuf);
1016
+ break;
1017
+ case 10:
1018
+ if(id == 0) iputchar('A');
1019
+ if(!(rbuf = tcfdbget3(fdb, kbuf)) && tcfdbecode(fdb) != TCENOREC){
1020
+ eprint(fdb, __LINE__, "tcfdbge3");
1021
+ err = true;
1022
+ }
1023
+ tcfree(rbuf);
1024
+ break;
1025
+ case 11:
1026
+ if(id == 0) iputchar('B');
1027
+ if(myrand(1) == 0) vsiz = 1;
1028
+ if((vsiz = tcfdbget4(fdb, kid, vbuf, vsiz)) < 0 && tcfdbecode(fdb) != TCENOREC){
1029
+ eprint(fdb, __LINE__, "tcfdbget4");
1030
+ err = true;
1031
+ }
1032
+ break;
1033
+ case 14:
1034
+ if(id == 0) iputchar('E');
1035
+ if(myrand(rnum / 50) == 0){
1036
+ if(!tcfdbiterinit(fdb)){
1037
+ eprint(fdb, __LINE__, "tcfdbiterinit");
1038
+ err = true;
1039
+ }
1040
+ }
1041
+ for(int j = myrand(rnum) / 1000 + 1; j >= 0; j--){
1042
+ if(tcfdbiternext(fdb) < 1){
1043
+ int ecode = tcfdbecode(fdb);
1044
+ if(ecode != TCEINVALID && ecode != TCENOREC){
1045
+ eprint(fdb, __LINE__, "tcfdbiternext");
1046
+ err = true;
1047
+ }
1048
+ }
1049
+ }
1050
+ break;
1051
+ default:
1052
+ if(id == 0) iputchar('@');
1053
+ if(tcfdbtranbegin(fdb)){
1054
+ if(myrand(2) == 0){
1055
+ if(!tcfdbput2(fdb, kbuf, ksiz, vbuf, vsiz)){
1056
+ eprint(fdb, __LINE__, "tcfdbput");
1057
+ err = true;
1058
+ }
1059
+ if(!nc) tcmapput(map, kbuf, ksiz, vbuf, vsiz);
1060
+ } else {
1061
+ if(!tcfdbout2(fdb, kbuf, ksiz) && tcfdbecode(fdb) != TCENOREC){
1062
+ eprint(fdb, __LINE__, "tcfdbout");
1063
+ err = true;
1064
+ }
1065
+ if(!nc) tcmapout(map, kbuf, ksiz);
1066
+ }
1067
+ if(nc && myrand(2) == 0){
1068
+ if(!tcfdbtranabort(fdb)){
1069
+ eprint(fdb, __LINE__, "tcfdbtranabort");
1070
+ err = true;
1071
+ }
1072
+ } else {
1073
+ if(!tcfdbtrancommit(fdb)){
1074
+ eprint(fdb, __LINE__, "tcfdbtrancommit");
1075
+ err = true;
1076
+ }
1077
+ }
1078
+ } else {
1079
+ eprint(fdb, __LINE__, "tcfdbtranbegin");
1080
+ err = true;
1081
+ }
1082
+ if(myrand(1000) == 0){
1083
+ if(!tcfdbforeach(fdb, iterfunc, NULL)){
1084
+ eprint(fdb, __LINE__, "tcfdbforeach");
1085
+ err = true;
1086
+ }
1087
+ }
1088
+ if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
1089
+ break;
1090
+ }
1091
+ if(!nc) tcglobalmutexunlock();
1092
+ if(id == 0){
1093
+ if(i % 50 == 0) iprintf(" (%08d)\n", i);
1094
+ if(id == 0 && i == rnum / 4){
1095
+ if(!tcfdboptimize(fdb, RECBUFSIZ, -1) && tcfdbecode(fdb) != TCEINVALID){
1096
+ eprint(fdb, __LINE__, "tcfdboptimize");
1097
+ err = true;
1098
+ }
1099
+ if(!tcfdbiterinit(fdb)){
1100
+ eprint(fdb, __LINE__, "tcfdbiterinit");
1101
+ err = true;
1102
+ }
1103
+ }
1104
+ }
1105
+ }
1106
+ return err ? "error" : NULL;
1107
+ }
1108
+
1109
+
1110
+ /* thread the typical function */
1111
+ static void *threadtypical(void *targ){
1112
+ TCFDB *fdb = ((TARGTYPICAL *)targ)->fdb;
1113
+ int rnum = ((TARGTYPICAL *)targ)->rnum;
1114
+ bool nc = ((TARGTYPICAL *)targ)->nc;
1115
+ int rratio = ((TARGTYPICAL *)targ)->rratio;
1116
+ int id = ((TARGTYPICAL *)targ)->id;
1117
+ bool err = false;
1118
+ TCMAP *map = (!nc && id == 0) ? tcmapnew2(rnum + 1) : NULL;
1119
+ int base = id * rnum;
1120
+ int mrange = tclmax(50 + rratio, 100);
1121
+ int width = tcfdbwidth(fdb);
1122
+ for(int i = 1; !err && i <= rnum; i++){
1123
+ char buf[RECBUFSIZ];
1124
+ int len = sprintf(buf, "%08d", base + myrandnd(i) + 1);
1125
+ int rnd = myrand(mrange);
1126
+ if(rnd < 10){
1127
+ if(!tcfdbput2(fdb, buf, len, buf, len)){
1128
+ eprint(fdb, __LINE__, "tcfdbput2");
1129
+ err = true;
1130
+ }
1131
+ if(map) tcmapput(map, buf, len, buf, len);
1132
+ } else if(rnd < 15){
1133
+ if(!tcfdbputkeep2(fdb, buf, len, buf, len) && tcfdbecode(fdb) != TCEKEEP){
1134
+ eprint(fdb, __LINE__, "tcfdbputkeep2");
1135
+ err = true;
1136
+ }
1137
+ if(map) tcmapputkeep(map, buf, len, buf, len);
1138
+ } else if(rnd < 20){
1139
+ if(!tcfdbputcat2(fdb, buf, len, buf, len)){
1140
+ eprint(fdb, __LINE__, "tcfdbputcat2");
1141
+ err = true;
1142
+ }
1143
+ if(map) tcmapputcat(map, buf, len, buf, len);
1144
+ } else if(rnd < 25){
1145
+ if(!tcfdbout2(fdb, buf, len) && tcfdbecode(fdb) && tcfdbecode(fdb) != TCENOREC){
1146
+ eprint(fdb, __LINE__, "tcfdbout");
1147
+ err = true;
1148
+ }
1149
+ if(map) tcmapout(map, buf, len);
1150
+ } else if(rnd < 26){
1151
+ if(myrand(10) == 0 && !tcfdbiterinit(fdb) && tcfdbecode(fdb) != TCENOREC){
1152
+ eprint(fdb, __LINE__, "tcfdbiterinit");
1153
+ err = true;
1154
+ }
1155
+ for(int j = 0; !err && j < 10; j++){
1156
+ if(tcfdbiternext(fdb) < 1 &&
1157
+ tcfdbecode(fdb) != TCEINVALID && tcfdbecode(fdb) != TCENOREC){
1158
+ eprint(fdb, __LINE__, "tcfdbiternext");
1159
+ err = true;
1160
+ }
1161
+ }
1162
+ } else {
1163
+ int vsiz;
1164
+ char *vbuf = tcfdbget2(fdb, buf, len, &vsiz);
1165
+ if(vbuf){
1166
+ if(map){
1167
+ int msiz = 0;
1168
+ const char *mbuf = tcmapget(map, buf, len, &msiz);
1169
+ if(msiz > width) msiz = width;
1170
+ if(!mbuf || msiz != vsiz || memcmp(mbuf, vbuf, vsiz)){
1171
+ eprint(fdb, __LINE__, "(validation)");
1172
+ err = true;
1173
+ }
1174
+ }
1175
+ tcfree(vbuf);
1176
+ } else {
1177
+ if(tcfdbecode(fdb) != TCENOREC){
1178
+ eprint(fdb, __LINE__, "tcfdbget");
1179
+ err = true;
1180
+ }
1181
+ if(map && tcmapget(map, buf, len, &vsiz)){
1182
+ eprint(fdb, __LINE__, "(validation)");
1183
+ err = true;
1184
+ }
1185
+ }
1186
+ }
1187
+ if(id == 0 && rnum > 250 && i % (rnum / 250) == 0){
1188
+ iputchar('.');
1189
+ if(i == rnum || i % (rnum / 10) == 0) iprintf(" (%08d)\n", i);
1190
+ }
1191
+ }
1192
+ if(map){
1193
+ tcmapiterinit(map);
1194
+ int ksiz;
1195
+ const char *kbuf;
1196
+ while(!err && (kbuf = tcmapiternext(map, &ksiz)) != NULL){
1197
+ int vsiz;
1198
+ char *vbuf = tcfdbget2(fdb, kbuf, ksiz, &vsiz);
1199
+ if(vbuf){
1200
+ int msiz = 0;
1201
+ const char *mbuf = tcmapget(map, kbuf, ksiz, &msiz);
1202
+ if(msiz > width) msiz = width;
1203
+ if(!mbuf || msiz != vsiz || memcmp(mbuf, vbuf, vsiz)){
1204
+ eprint(fdb, __LINE__, "(validation)");
1205
+ err = true;
1206
+ }
1207
+ tcfree(vbuf);
1208
+ } else {
1209
+ eprint(fdb, __LINE__, "(validation)");
1210
+ err = true;
1211
+ }
1212
+ }
1213
+ tcmapdel(map);
1214
+ }
1215
+ return err ? "error" : NULL;
1216
+ }
1217
+
1218
+
1219
+
1220
+ // END OF FILE