droonga-engine 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. data/.dir-locals.el +3 -0
  2. data/.gitignore +6 -0
  3. data/.travis.yml +15 -0
  4. data/.yardopts +7 -0
  5. data/Gemfile +66 -0
  6. data/LICENSE.txt +14 -0
  7. data/README.md +17 -0
  8. data/Rakefile +64 -0
  9. data/benchmark/benchmark.rb +123 -0
  10. data/benchmark/utils.rb +246 -0
  11. data/benchmark/watch/benchmark-notify.rb +143 -0
  12. data/benchmark/watch/benchmark-notify.sh +20 -0
  13. data/benchmark/watch/benchmark-publish.rb +120 -0
  14. data/benchmark/watch/benchmark-scan.rb +213 -0
  15. data/bin/droonga-catalog-generate +103 -0
  16. data/bin/droonga-engine +20 -0
  17. data/bin/droonga-engine-service +20 -0
  18. data/doc/text/news.md +106 -0
  19. data/droonga-engine.gemspec +52 -0
  20. data/lib/droonga/adapter.rb +48 -0
  21. data/lib/droonga/adapter_runner.rb +104 -0
  22. data/lib/droonga/catalog/base.rb +41 -0
  23. data/lib/droonga/catalog/collection_volume.rb +106 -0
  24. data/lib/droonga/catalog/dataset.rb +69 -0
  25. data/lib/droonga/catalog/errors.rb +113 -0
  26. data/lib/droonga/catalog/schema.rb +186 -0
  27. data/lib/droonga/catalog/single_volume.rb +28 -0
  28. data/lib/droonga/catalog/slice.rb +41 -0
  29. data/lib/droonga/catalog/version1.rb +427 -0
  30. data/lib/droonga/catalog/version2.rb +96 -0
  31. data/lib/droonga/catalog/version2_validator.rb +63 -0
  32. data/lib/droonga/catalog/volume.rb +33 -0
  33. data/lib/droonga/catalog/volume_collection.rb +56 -0
  34. data/lib/droonga/catalog_generator.rb +156 -0
  35. data/lib/droonga/catalog_loader.rb +56 -0
  36. data/lib/droonga/catalog_observer.rb +83 -0
  37. data/lib/droonga/collector.rb +38 -0
  38. data/lib/droonga/collector_message.rb +71 -0
  39. data/lib/droonga/collector_runner.rb +64 -0
  40. data/lib/droonga/collectors/and.rb +26 -0
  41. data/lib/droonga/collectors/or.rb +26 -0
  42. data/lib/droonga/collectors/sum.rb +26 -0
  43. data/lib/droonga/collectors.rb +18 -0
  44. data/lib/droonga/dispatcher.rb +326 -0
  45. data/lib/droonga/distributed_command_planner.rb +179 -0
  46. data/lib/droonga/distributor.rb +87 -0
  47. data/lib/droonga/engine/command/droonga_engine.rb +441 -0
  48. data/lib/droonga/engine/version.rb +20 -0
  49. data/lib/droonga/engine.rb +80 -0
  50. data/lib/droonga/engine_state.rb +79 -0
  51. data/lib/droonga/error.rb +73 -0
  52. data/lib/droonga/error_messages.rb +33 -0
  53. data/lib/droonga/event_loop.rb +46 -0
  54. data/lib/droonga/farm.rb +58 -0
  55. data/lib/droonga/fluent_message_receiver.rb +191 -0
  56. data/lib/droonga/fluent_message_sender.rb +140 -0
  57. data/lib/droonga/forwarder.rb +119 -0
  58. data/lib/droonga/handler.rb +49 -0
  59. data/lib/droonga/handler_message.rb +61 -0
  60. data/lib/droonga/handler_messenger.rb +119 -0
  61. data/lib/droonga/handler_runner.rb +125 -0
  62. data/lib/droonga/input_message.rb +51 -0
  63. data/lib/droonga/job_protocol.rb +20 -0
  64. data/lib/droonga/job_pusher.rb +179 -0
  65. data/lib/droonga/job_receiver.rb +70 -0
  66. data/lib/droonga/loggable.rb +29 -0
  67. data/lib/droonga/logger.rb +142 -0
  68. data/lib/droonga/message_matcher.rb +109 -0
  69. data/lib/droonga/output_message.rb +55 -0
  70. data/lib/droonga/planner.rb +47 -0
  71. data/lib/droonga/pluggable.rb +31 -0
  72. data/lib/droonga/plugin/metadata/adapter_input_message.rb +39 -0
  73. data/lib/droonga/plugin/metadata/adapter_output_message.rb +39 -0
  74. data/lib/droonga/plugin/metadata/collector_message.rb +39 -0
  75. data/lib/droonga/plugin/metadata/handler_action.rb +39 -0
  76. data/lib/droonga/plugin/metadata/input_message.rb +54 -0
  77. data/lib/droonga/plugin.rb +43 -0
  78. data/lib/droonga/plugin_loader.rb +63 -0
  79. data/lib/droonga/plugin_registry.rb +66 -0
  80. data/lib/droonga/plugins/basic.rb +54 -0
  81. data/lib/droonga/plugins/crud.rb +145 -0
  82. data/lib/droonga/plugins/dump.rb +97 -0
  83. data/lib/droonga/plugins/error.rb +51 -0
  84. data/lib/droonga/plugins/groonga/column_create.rb +123 -0
  85. data/lib/droonga/plugins/groonga/column_list.rb +124 -0
  86. data/lib/droonga/plugins/groonga/column_remove.rb +65 -0
  87. data/lib/droonga/plugins/groonga/column_rename.rb +67 -0
  88. data/lib/droonga/plugins/groonga/delete.rb +117 -0
  89. data/lib/droonga/plugins/groonga/generic_command.rb +105 -0
  90. data/lib/droonga/plugins/groonga/generic_response.rb +43 -0
  91. data/lib/droonga/plugins/groonga/select.rb +236 -0
  92. data/lib/droonga/plugins/groonga/table_create.rb +111 -0
  93. data/lib/droonga/plugins/groonga/table_list.rb +120 -0
  94. data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
  95. data/lib/droonga/plugins/groonga.rb +37 -0
  96. data/lib/droonga/plugins/search/distributed_search_planner.rb +407 -0
  97. data/lib/droonga/plugins/search.rb +146 -0
  98. data/lib/droonga/plugins/watch.rb +178 -0
  99. data/lib/droonga/processor.rb +63 -0
  100. data/lib/droonga/reducer.rb +169 -0
  101. data/lib/droonga/replier.rb +49 -0
  102. data/lib/droonga/schema_applier.rb +167 -0
  103. data/lib/droonga/searcher/mecab_filter.rb +67 -0
  104. data/lib/droonga/searcher.rb +733 -0
  105. data/lib/droonga/server.rb +45 -0
  106. data/lib/droonga/session.rb +99 -0
  107. data/lib/droonga/single_step.rb +68 -0
  108. data/lib/droonga/single_step_definition.rb +54 -0
  109. data/lib/droonga/slice.rb +122 -0
  110. data/lib/droonga/status_code.rb +25 -0
  111. data/lib/droonga/step_runner.rb +64 -0
  112. data/lib/droonga/sweeper.rb +42 -0
  113. data/lib/droonga/test/stub_handler.rb +37 -0
  114. data/lib/droonga/test/stub_handler_message.rb +35 -0
  115. data/lib/droonga/test/stub_handler_messenger.rb +34 -0
  116. data/lib/droonga/test/stub_planner.rb +31 -0
  117. data/lib/droonga/test.rb +21 -0
  118. data/lib/droonga/watch_schema.rb +92 -0
  119. data/lib/droonga/watcher.rb +257 -0
  120. data/lib/droonga/worker.rb +61 -0
  121. data/sample/cluster/catalog.json +42 -0
  122. data/sample/mecab_filter/data.grn +7 -0
  123. data/sample/mecab_filter/ddl.grn +7 -0
  124. data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
  125. data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
  126. data/test/command/config/default/catalog.json +85 -0
  127. data/test/command/config/default/fluentd.conf +11 -0
  128. data/test/command/config/version1/catalog.json +68 -0
  129. data/test/command/config/version1/fluentd.conf +11 -0
  130. data/test/command/fixture/documents.jsons +208 -0
  131. data/test/command/fixture/event.jsons +41 -0
  132. data/test/command/fixture/user-table-array.jsons +38 -0
  133. data/test/command/fixture/user-table.jsons +47 -0
  134. data/test/command/run-test.rb +34 -0
  135. data/test/command/suite/add/dimension/column.catalog.json +28 -0
  136. data/test/command/suite/add/dimension/column.expected +41 -0
  137. data/test/command/suite/add/dimension/column.test +51 -0
  138. data/test/command/suite/add/dimension/integer.catalog.json +19 -0
  139. data/test/command/suite/add/dimension/integer.expected +41 -0
  140. data/test/command/suite/add/dimension/integer.test +51 -0
  141. data/test/command/suite/add/error/invalid-integer.expected +46 -0
  142. data/test/command/suite/add/error/invalid-integer.test +12 -0
  143. data/test/command/suite/add/error/invalid-time.expected +46 -0
  144. data/test/command/suite/add/error/invalid-time.test +12 -0
  145. data/test/command/suite/add/error/missing-key.expected +25 -0
  146. data/test/command/suite/add/error/missing-key.test +16 -0
  147. data/test/command/suite/add/error/missing-table.expected +25 -0
  148. data/test/command/suite/add/error/missing-table.test +16 -0
  149. data/test/command/suite/add/error/unknown-column.expected +46 -0
  150. data/test/command/suite/add/error/unknown-column.test +12 -0
  151. data/test/command/suite/add/error/unknown-table.expected +25 -0
  152. data/test/command/suite/add/error/unknown-table.test +17 -0
  153. data/test/command/suite/add/minimum.expected +6 -0
  154. data/test/command/suite/add/minimum.test +11 -0
  155. data/test/command/suite/add/with-values.expected +6 -0
  156. data/test/command/suite/add/with-values.test +17 -0
  157. data/test/command/suite/add/without-key.expected +6 -0
  158. data/test/command/suite/add/without-key.test +16 -0
  159. data/test/command/suite/groonga/column_create/scalar.expected +26 -0
  160. data/test/command/suite/groonga/column_create/scalar.test +17 -0
  161. data/test/command/suite/groonga/column_create/unknown-table.expected +14 -0
  162. data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
  163. data/test/command/suite/groonga/column_create/vector.expected +26 -0
  164. data/test/command/suite/groonga/column_create/vector.test +18 -0
  165. data/test/command/suite/groonga/column_list/success.expected +86 -0
  166. data/test/command/suite/groonga/column_list/success.test +24 -0
  167. data/test/command/suite/groonga/column_list/unknown-table.expected +13 -0
  168. data/test/command/suite/groonga/column_list/unknown-table.test +7 -0
  169. data/test/command/suite/groonga/column_remove/success.expected +39 -0
  170. data/test/command/suite/groonga/column_remove/success.test +25 -0
  171. data/test/command/suite/groonga/column_remove/unknown-column.expected +27 -0
  172. data/test/command/suite/groonga/column_remove/unknown-column.test +16 -0
  173. data/test/command/suite/groonga/column_remove/unknown-table.expected +14 -0
  174. data/test/command/suite/groonga/column_remove/unknown-table.test +7 -0
  175. data/test/command/suite/groonga/column_rename/success.expected +39 -0
  176. data/test/command/suite/groonga/column_rename/success.test +26 -0
  177. data/test/command/suite/groonga/column_rename/unknown-column.expected +27 -0
  178. data/test/command/suite/groonga/column_rename/unknown-column.test +16 -0
  179. data/test/command/suite/groonga/column_rename/unknown-table.expected +14 -0
  180. data/test/command/suite/groonga/column_rename/unknown-table.test +7 -0
  181. data/test/command/suite/groonga/delete/duplicated-identifiers.expected +27 -0
  182. data/test/command/suite/groonga/delete/duplicated-identifiers.test +17 -0
  183. data/test/command/suite/groonga/delete/filter.expected +19 -0
  184. data/test/command/suite/groonga/delete/filter.test +19 -0
  185. data/test/command/suite/groonga/delete/invalid-filter.expected +14 -0
  186. data/test/command/suite/groonga/delete/invalid-filter.test +9 -0
  187. data/test/command/suite/groonga/delete/no-identifier.expected +27 -0
  188. data/test/command/suite/groonga/delete/no-identifier.test +15 -0
  189. data/test/command/suite/groonga/delete/success.expected +19 -0
  190. data/test/command/suite/groonga/delete/success.test +19 -0
  191. data/test/command/suite/groonga/delete/unknown-table.expected +14 -0
  192. data/test/command/suite/groonga/delete/unknown-table.test +7 -0
  193. data/test/command/suite/groonga/select/minimum.expected +22 -0
  194. data/test/command/suite/groonga/select/minimum.test +8 -0
  195. data/test/command/suite/groonga/table_create/array.expected +14 -0
  196. data/test/command/suite/groonga/table_create/array.test +8 -0
  197. data/test/command/suite/groonga/table_create/hash.expected +13 -0
  198. data/test/command/suite/groonga/table_create/hash.test +8 -0
  199. data/test/command/suite/groonga/table_list/success.expected +71 -0
  200. data/test/command/suite/groonga/table_list/success.test +15 -0
  201. data/test/command/suite/groonga/table_remove/success.expected +13 -0
  202. data/test/command/suite/groonga/table_remove/success.test +8 -0
  203. data/test/command/suite/groonga/table_remove/unknown-table.expected +14 -0
  204. data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
  205. data/test/command/suite/message/error/missing-dataset.expected +9 -0
  206. data/test/command/suite/message/error/missing-dataset.test +5 -0
  207. data/test/command/suite/message/error/unknown-dataset.expected +9 -0
  208. data/test/command/suite/message/error/unknown-dataset.test +6 -0
  209. data/test/command/suite/message/error/unknown-type.expected +9 -0
  210. data/test/command/suite/message/error/unknown-type.test +6 -0
  211. data/test/command/suite/search/adjusters/multiple.catalog.json +38 -0
  212. data/test/command/suite/search/adjusters/multiple.expected +19 -0
  213. data/test/command/suite/search/adjusters/multiple.test +75 -0
  214. data/test/command/suite/search/adjusters/one.catalog.json +38 -0
  215. data/test/command/suite/search/adjusters/one.expected +19 -0
  216. data/test/command/suite/search/adjusters/one.test +66 -0
  217. data/test/command/suite/search/attributes/array.expected +21 -0
  218. data/test/command/suite/search/attributes/array.test +28 -0
  219. data/test/command/suite/search/attributes/hash.expected +30 -0
  220. data/test/command/suite/search/attributes/hash.test +36 -0
  221. data/test/command/suite/search/complex.expected +48 -0
  222. data/test/command/suite/search/complex.test +23 -0
  223. data/test/command/suite/search/condition/nested.expected +15 -0
  224. data/test/command/suite/search/condition/nested.test +27 -0
  225. data/test/command/suite/search/condition/query/nonexistent_column.catalog.json +37 -0
  226. data/test/command/suite/search/condition/query/nonexistent_column.expected +48 -0
  227. data/test/command/suite/search/condition/query/nonexistent_column.test +33 -0
  228. data/test/command/suite/search/condition/query/syntax_error.catalog.json +36 -0
  229. data/test/command/suite/search/condition/query/syntax_error.expected +48 -0
  230. data/test/command/suite/search/condition/query/syntax_error.test +33 -0
  231. data/test/command/suite/search/condition/query.expected +24 -0
  232. data/test/command/suite/search/condition/query.test +23 -0
  233. data/test/command/suite/search/condition/script.expected +24 -0
  234. data/test/command/suite/search/condition/script.test +26 -0
  235. data/test/command/suite/search/error/cyclic-source.expected +14 -0
  236. data/test/command/suite/search/error/cyclic-source.test +12 -0
  237. data/test/command/suite/search/error/deeply-cyclic-source.expected +17 -0
  238. data/test/command/suite/search/error/deeply-cyclic-source.test +15 -0
  239. data/test/command/suite/search/error/missing-source-parameter.expected +13 -0
  240. data/test/command/suite/search/error/missing-source-parameter.test +11 -0
  241. data/test/command/suite/search/error/no-query.expected +9 -0
  242. data/test/command/suite/search/error/no-query.test +7 -0
  243. data/test/command/suite/search/error/unknown-source.expected +52 -0
  244. data/test/command/suite/search/error/unknown-source.test +12 -0
  245. data/test/command/suite/search/group/count.expected +10 -0
  246. data/test/command/suite/search/group/count.test +18 -0
  247. data/test/command/suite/search/group/limit.expected +15 -0
  248. data/test/command/suite/search/group/limit.test +20 -0
  249. data/test/command/suite/search/group/string.expected +32 -0
  250. data/test/command/suite/search/group/string.test +40 -0
  251. data/test/command/suite/search/group/subrecord/with-sort.catalog.json +33 -0
  252. data/test/command/suite/search/group/subrecord/with-sort.expected +30 -0
  253. data/test/command/suite/search/group/subrecord/with-sort.test +81 -0
  254. data/test/command/suite/search/multiple/chained.expected +41 -0
  255. data/test/command/suite/search/multiple/chained.test +39 -0
  256. data/test/command/suite/search/multiple/parallel.expected +35 -0
  257. data/test/command/suite/search/multiple/parallel.test +35 -0
  258. data/test/command/suite/search/output/attributes/invalid.catalog.json +13 -0
  259. data/test/command/suite/search/output/attributes/invalid.expected +44 -0
  260. data/test/command/suite/search/output/attributes/invalid.test +28 -0
  261. data/test/command/suite/search/range/only-output.expected +24 -0
  262. data/test/command/suite/search/range/only-output.test +23 -0
  263. data/test/command/suite/search/range/only-sort.expected +24 -0
  264. data/test/command/suite/search/range/only-sort.test +26 -0
  265. data/test/command/suite/search/range/sort-and-output.expected +21 -0
  266. data/test/command/suite/search/range/sort-and-output.test +27 -0
  267. data/test/command/suite/search/range/too-large-output-offset.expected +12 -0
  268. data/test/command/suite/search/range/too-large-output-offset.test +23 -0
  269. data/test/command/suite/search/range/too-large-sort-offset.expected +12 -0
  270. data/test/command/suite/search/range/too-large-sort-offset.test +26 -0
  271. data/test/command/suite/search/response/elapsed_time.catalog.json +13 -0
  272. data/test/command/suite/search/response/elapsed_time.expected +11 -0
  273. data/test/command/suite/search/response/elapsed_time.test +26 -0
  274. data/test/command/suite/search/response/records/value/time.expected +20 -0
  275. data/test/command/suite/search/response/records/value/time.test +22 -0
  276. data/test/command/suite/search/simple.expected +48 -0
  277. data/test/command/suite/search/simple.test +22 -0
  278. data/test/command/suite/search/sort/default-offset-limit.expected +39 -0
  279. data/test/command/suite/search/sort/default-offset-limit.test +24 -0
  280. data/test/command/suite/search/sort/invisible-column.expected +24 -0
  281. data/test/command/suite/search/sort/invisible-column.test +26 -0
  282. data/test/command/suite/watch/subscribe.expected +6 -0
  283. data/test/command/suite/watch/subscribe.test +9 -0
  284. data/test/command/suite/watch/unsubscribe.expected +6 -0
  285. data/test/command/suite/watch/unsubscribe.test +9 -0
  286. data/test/performance/run-test.rb +56 -0
  287. data/test/performance/watch/catalog.json +33 -0
  288. data/test/performance/watch/feed.json +9 -0
  289. data/test/performance/watch/fluentd.conf +11 -0
  290. data/test/performance/watch/subscribe.json +3 -0
  291. data/test/unit/catalog/test_collection_volume.rb +103 -0
  292. data/test/unit/catalog/test_dataset.rb +104 -0
  293. data/test/unit/catalog/test_schema.rb +226 -0
  294. data/test/unit/catalog/test_single_volume.rb +31 -0
  295. data/test/unit/catalog/test_slice.rb +92 -0
  296. data/test/unit/catalog/test_version1.rb +361 -0
  297. data/test/unit/catalog/test_version2.rb +124 -0
  298. data/test/unit/catalog/test_version2_validator.rb +66 -0
  299. data/test/unit/catalog/test_volume_collection.rb +50 -0
  300. data/test/unit/fixtures/array.grn +18 -0
  301. data/test/unit/fixtures/catalog/version1.json +40 -0
  302. data/test/unit/fixtures/catalog/version2.json +62 -0
  303. data/test/unit/fixtures/document.grn +34 -0
  304. data/test/unit/fixtures/reference/array.grn +11 -0
  305. data/test/unit/fixtures/reference/hash.grn +7 -0
  306. data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
  307. data/test/unit/helper/fixture.rb +28 -0
  308. data/test/unit/helper/plugin_helper.rb +38 -0
  309. data/test/unit/helper/sandbox.rb +86 -0
  310. data/test/unit/helper/stub_worker.rb +27 -0
  311. data/test/unit/helper/watch_helper.rb +23 -0
  312. data/test/unit/helper.rb +28 -0
  313. data/test/unit/plugins/crud/test_add.rb +190 -0
  314. data/test/unit/plugins/groonga/select/test_adapter_input.rb +510 -0
  315. data/test/unit/plugins/groonga/select/test_adapter_output.rb +201 -0
  316. data/test/unit/plugins/groonga/test_column_create.rb +171 -0
  317. data/test/unit/plugins/groonga/test_column_list.rb +170 -0
  318. data/test/unit/plugins/groonga/test_column_remove.rb +98 -0
  319. data/test/unit/plugins/groonga/test_column_rename.rb +105 -0
  320. data/test/unit/plugins/groonga/test_delete.rb +127 -0
  321. data/test/unit/plugins/groonga/test_table_create.rb +147 -0
  322. data/test/unit/plugins/groonga/test_table_list.rb +184 -0
  323. data/test/unit/plugins/groonga/test_table_remove.rb +61 -0
  324. data/test/unit/plugins/search/planner/test_basic.rb +120 -0
  325. data/test/unit/plugins/search/planner/test_group_by.rb +573 -0
  326. data/test/unit/plugins/search/planner/test_output.rb +388 -0
  327. data/test/unit/plugins/search/planner/test_sort_by.rb +938 -0
  328. data/test/unit/plugins/search/test_collector.rb +806 -0
  329. data/test/unit/plugins/search/test_handler.rb +930 -0
  330. data/test/unit/plugins/search/test_planner.rb +174 -0
  331. data/test/unit/plugins/test_basic.rb +510 -0
  332. data/test/unit/plugins/test_groonga.rb +70 -0
  333. data/test/unit/plugins/test_watch.rb +211 -0
  334. data/test/unit/run-test.rb +56 -0
  335. data/test/unit/test_catalog_generator.rb +93 -0
  336. data/test/unit/test_message_matcher.rb +160 -0
  337. data/test/unit/test_schema_applier.rb +59 -0
  338. data/test/unit/test_sweeper.rb +95 -0
  339. data/test/unit/test_watch_schema.rb +57 -0
  340. data/test/unit/test_watcher.rb +336 -0
  341. metadata +759 -0
data/.dir-locals.el ADDED
@@ -0,0 +1,3 @@
1
+ ((js-mode . ((indent-tabs-mode . nil)
2
+ (js-indent-level . 2)
3
+ (show-trailing-whitespace . t))))
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /Gemfile.lock
2
+ /test/command/tmp
3
+ /doc/
4
+ /.yardoc/
5
+ /pkg/
6
+ /sample/cluster/0*
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ notifications:
2
+ recipients:
3
+ - groonga-commit@lists.sourceforge.jp
4
+ env:
5
+ - DEFAULT_TEST_TASK=test:unit
6
+ - DEFAULT_TEST_TASK=test:command:default
7
+ - DEFAULT_TEST_TASK=test:command:version1
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1
12
+ # - ruby-head
13
+ before_install:
14
+ # - GROONGA_MASTER=yes curl --silent --location https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
15
+ - curl --silent --location https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --output-dir doc/reference/en
2
+ --markup markdown
3
+ --markup-provider kramdown
4
+ lib/**/*.rb
5
+ -
6
+ LICENSE.txt
7
+ doc/text/**/*.*
data/Gemfile ADDED
@@ -0,0 +1,66 @@
1
+ # Copyright (C) 2013 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ source "https://rubygems.org"
17
+
18
+ gemspec
19
+
20
+ parent_dir = File.join(File.dirname(__FILE__), "..")
21
+ local_rroonga_path = File.join(parent_dir, "rroonga")
22
+ local_groonga_command_path = File.join(parent_dir, "groonga-command")
23
+ local_groonga_command_parser_path = File.join(parent_dir,
24
+ "groonga-command-parser")
25
+ if File.exist?(local_rroonga_path)
26
+ gem "rroonga", :path => local_rroonga_path
27
+ gem "groonga-command", :path => local_groonga_command_path
28
+ gem "groonga-command-parser", :path => local_groonga_command_parser_path
29
+ elsif ENV["TRAVIS"] == "true"
30
+ require_unreleased_gems = true
31
+ if require_unreleased_gems
32
+ gem "rroonga", :git => "git://github.com/ranguba/rroonga.git"
33
+ gem "groonga-command",
34
+ :git => "git://github.com/groonga/groonga-command.git"
35
+ gem "groonga-command-parser",
36
+ :git => "git://github.com/groonga/groonga-command-parser.git"
37
+ end
38
+ end
39
+
40
+ droonga_client_dir = File.join(parent_dir, "droonga-client-ruby")
41
+ if File.exist?(droonga_client_dir)
42
+ gem "droonga-client", :path => droonga_client_dir
43
+ else
44
+ gem "droonga-client", :github => "droonga/droonga-client-ruby"
45
+ end
46
+
47
+ drntest_dir = File.join(parent_dir, "drntest")
48
+ if File.exist?(drntest_dir)
49
+ gem "drntest", :path => drntest_dir
50
+ else
51
+ gem "drntest", :github => "droonga/drntest"
52
+ end
53
+
54
+ drnbench_dir = File.join(parent_dir, "drnbench")
55
+ if File.exist?(drnbench_dir)
56
+ gem "drnbench", :path => drnbench_dir
57
+ else
58
+ gem "drnbench", :github => "droonga/drnbench"
59
+ end
60
+
61
+ grn2drn_dir = File.join(parent_dir, "grn2drn")
62
+ if File.exist?(grn2drn_dir)
63
+ gem "grn2drn", :path => grn2drn_dir
64
+ else
65
+ gem "grn2drn", :github => "droonga/grn2drn"
66
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (C) 2013 Droonga Project
2
+
3
+ This library is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU Lesser General Public
5
+ License version 2.1 as published by the Free Software Foundation.
6
+
7
+ This library is distributed in the hope that it will be useful,
8
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ Lesser General Public License for more details.
11
+
12
+ You should have received a copy of the GNU Lesser General Public
13
+ License along with this library; if not, write to the Free Software
14
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Droonga engine
2
+
3
+ ## What's "Droonga"?
4
+
5
+ Droonga is a scalable data processing engine, named from "Distributed
6
+ Groonga". Droonga can execute distributed fulltext search.
7
+
8
+ ## Usage
9
+
10
+ See [droonga.org](http://droonga.org/). You can find overview, install
11
+ manual, reference manual and tutorial at the site.
12
+
13
+ ## Copyright
14
+
15
+ * Copyright (c) 2013-2014 Droonga Project
16
+ * License
17
+ * GNU Lesser General Public License version 2.1
data/Rakefile ADDED
@@ -0,0 +1,64 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2013-2014 Droonga Project
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "bundler/gem_helper"
19
+ require "packnga"
20
+
21
+ base_dir = File.join(File.dirname(__FILE__))
22
+
23
+ helper = Bundler::GemHelper.new(base_dir)
24
+ helper.install
25
+ spec = helper.gemspec
26
+
27
+ Packnga::DocumentTask.new(spec) do |task|
28
+ task.original_language = "en"
29
+ task.translate_languages = ["ja"]
30
+ end
31
+
32
+ def run_command_test(*options)
33
+ ruby(File.join(File.dirname(__FILE__), "test", "command", "run-test.rb",),
34
+ *options)
35
+ end
36
+
37
+ namespace :test do
38
+ desc "Run unit test"
39
+ task :unit do
40
+ ruby(File.join(File.dirname(__FILE__), "test", "unit", "run-test.rb"))
41
+ end
42
+
43
+ namespace :command do
44
+ desc "Run command test: default"
45
+ task :default do
46
+ run_command_test
47
+ end
48
+
49
+ desc "Run command test: version1"
50
+ task :version1 do
51
+ run_command_test("--config", "version1")
52
+ end
53
+ end
54
+ end
55
+
56
+ desc "Run test"
57
+ task :test => [
58
+ "test:unit",
59
+ "test:command:default",
60
+ "test:command:version1",
61
+ ]
62
+
63
+ test_task = ENV["DEFAULT_TEST_TASK"] || "test"
64
+ task :default => test_task
@@ -0,0 +1,123 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 Droonga Project
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "droonga/client"
19
+
20
+ module Droonga
21
+ class Benchmark
22
+ class Terms
23
+ class << self
24
+ def generate
25
+ new.to_enum(:each)
26
+ end
27
+ end
28
+
29
+ FIRST_INITIAL_LETTER = "㐀"
30
+ SUFFIX = "あいうえおかきくけこ"
31
+ def each
32
+ initial_letter = FIRST_INITIAL_LETTER
33
+ while true do
34
+ yield "#{initial_letter}#{SUFFIX}"
35
+ initial_letter.succ!
36
+ end
37
+ end
38
+ end
39
+
40
+ TERMS_STEP = 1000
41
+
42
+ N_TARGETS = 1000
43
+ TARGET_PADDING = "パディング"
44
+ TARGET_TITLE_SIZE = 100
45
+ TARGET_BODY_SIZE = 1000
46
+
47
+ def initialize(params)
48
+ @params = params
49
+ @terms = Terms.generate
50
+ @client = Droonga::Client.new(tag: @params[:tag], port: @params[:port])
51
+ end
52
+
53
+ def run
54
+ prepare_watching_subscribers(TERMS_STEP)
55
+ populate_feeds(0.1)
56
+ start_at = Time.now
57
+ @feeds.each do |feed|
58
+ @client.send(feed)
59
+ end
60
+ end_at = Time.now
61
+ end
62
+
63
+ def prepare_watching_subscribers(step)
64
+ step.times do
65
+ term = @terms.next
66
+ add_subscriber(term)
67
+ @watching_terms << term
68
+ end
69
+ end
70
+
71
+ def add_subscriber(term)
72
+ subscribe_envelope = envelope_to_subscribe(term)
73
+ @client.connection.send_receive(subscribe_envelope)
74
+ end
75
+
76
+ def envelope_to_subscribe(term, route=nil)
77
+ message = {
78
+ "id" => Time.now.to_f.to_s,
79
+ "date" => Time.now,
80
+ "statusCode" => 200,
81
+ "type" => "watch.subscribe",
82
+ "body" => {
83
+ "condition" => term,
84
+ "subscriber" => term,
85
+ },
86
+ }
87
+ unless route.nil?
88
+ message["body"]["route"] = route
89
+ end
90
+ message
91
+ end
92
+
93
+ def populate_feeds(incidence)
94
+ @feeds = []
95
+
96
+ n_matched_targets = (N_TARGETS.to_f * incidence).to_i
97
+ n_unmatched_targets = (N_TARGETS - n_matched_targets)
98
+
99
+ n_matched_targets.times do
100
+ @feeds << envelope_to_feed(@watching_terms.sample(1))
101
+ end
102
+
103
+ n_unmatched_targets.times do
104
+ @feeds << envelope_to_feed(@terms.next)
105
+ end
106
+ end
107
+
108
+ def envelope_to_feed(term)
109
+ {
110
+ "id" => Time.now.to_f.to_s,
111
+ "date" => Time.now,
112
+ "statusCode" => 200,
113
+ "type" => "watch.feed",
114
+ "body" => {
115
+ "targets" => {
116
+ "title" => TARGET_PADDING * (TARGET_TITLE_SIZE / TARGET_PADDING.size),
117
+ "body" => term + (TARGET_PADDING * (TARGET_BODY_SIZE / TARGET_PADDING.size)),
118
+ },
119
+ },
120
+ }
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,246 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 Droonga Project
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "json"
19
+ require "thread"
20
+ require "droonga/watch_schema"
21
+
22
+ module DroongaBenchmark
23
+ WATCH_DATASET = "Watch"
24
+
25
+ class WatchDatabase
26
+ attr_reader :context
27
+
28
+ def initialize
29
+ @database_dir = "/tmp/watch-benchmark"
30
+ @database_path = "#{@database_dir}/db"
31
+ FileUtils.rm_rf(@database_dir)
32
+ FileUtils.mkdir_p(@database_dir)
33
+
34
+ Groonga::Database.create(:path => @database_path)
35
+
36
+ @context = Groonga::Context.new
37
+ @context.open_database(@database_path)
38
+ schema = Droonga::WatchSchema.new(@context)
39
+ schema.ensure_created
40
+ end
41
+
42
+ =begin
43
+ def subscribe_to(keywords)
44
+ @context.send("load --table Query")
45
+ @context.send("[")
46
+ keywords.each do |keyword|
47
+ @context.send("{'_key':'#{keyword}'," +
48
+ "'keywords':['#{keyword}']},")
49
+ end
50
+ @context.send("]")
51
+
52
+ @context.send("load --table Subscriber")
53
+ @context.send("[")
54
+ keywords.each do |keyword|
55
+ @context.send("{'_key':'subscriber for #{keyword}'," +
56
+ "'subscriptions':['#{keyword}']," +
57
+ "'route':'0.0.0.0:0/benchamrk'},")
58
+ end
59
+ @context.send("]")
60
+ end
61
+ =end
62
+
63
+ def subscribe_to(keywords)
64
+ queries = []
65
+ subscribers = []
66
+ keywords.each do |keyword|
67
+ queries << {:_key => keyword,
68
+ :keywords => [keyword]}
69
+ subscribers << {:_key => "subscriber for #{keyword}",
70
+ :subscriptions => [keyword],
71
+ :route => "0.0.0.0:0/benchamrk"}
72
+ end
73
+
74
+ command_load_queries = [
75
+ "load --table Query",
76
+ JSON.generate(queries)
77
+ ]
78
+ command_load_subscribers = [
79
+ "load --table Subscriber",
80
+ JSON.generate(subscribers)
81
+ ]
82
+
83
+ @context.restore(command_load_queries.join("\n"))
84
+ @context.restore(command_load_subscribers.join("\n"))
85
+ end
86
+
87
+ def subscribe(keyword)
88
+ queries = @context["Query"]
89
+ query = queries.add(keyword, :keywords => [keyword])
90
+
91
+ subscribers = @context["Subscriber"]
92
+ subscribers.add("subscriber for #{keyword}",
93
+ :subscriptions => [query],
94
+ :route => "0.0.0.0:0/benchamrk")
95
+ end
96
+ end
97
+
98
+ class KeywordsGenerator
99
+ class << self
100
+ def generate(n_keywords)
101
+ new.generate(n_keywords)
102
+ end
103
+ end
104
+
105
+ def initialize
106
+ @generator = to_enum(:each)
107
+ end
108
+
109
+ def generate(n_keywords)
110
+ keywords = []
111
+ n_keywords.times do
112
+ keywords << @generator.next
113
+ end
114
+ keywords
115
+ end
116
+
117
+ def next
118
+ @generator.next
119
+ end
120
+
121
+ FIRST_INITIAL_LETTER = "㐀"
122
+ SUFFIX = "あいうえおかきくけこ"
123
+ def each
124
+ initial_letter = FIRST_INITIAL_LETTER
125
+ while true do
126
+ yield "#{initial_letter}#{SUFFIX}"
127
+ initial_letter.succ!
128
+ end
129
+ end
130
+ end
131
+
132
+ class TargetsGenerator
133
+ class << self
134
+ def generate(n_keywords, params)
135
+ new(params).generate(n_keywords)
136
+ end
137
+ end
138
+
139
+ PADDING = "パディング"
140
+ SIZE = 1000
141
+
142
+ def initialize(params)
143
+ @keywords = params[:keywords]
144
+ @incidence = params[:incidence]
145
+ @matched_keywords = params[:matched_keywords] || 1
146
+ end
147
+
148
+ def generate(n_targets)
149
+ targets = []
150
+
151
+ n_matched_targets = (n_targets.to_f * @incidence).to_i
152
+ n_unmatched_targets = (n_targets - n_matched_targets)
153
+
154
+ n_matched_targets.times do
155
+ targets << generate_target(@keywords.sample(@matched_keywords))
156
+ end
157
+
158
+ n_unmatched_targets.times do
159
+ targets << generate_target
160
+ end
161
+
162
+ targets
163
+ end
164
+
165
+ def generate_target(keywords=[])
166
+ (PADDING * (SIZE / PADDING.size)) + keywords.join("/")
167
+ end
168
+ end
169
+
170
+ class MessageCreator
171
+ class << self
172
+ def envelope_to_subscribe(keyword, route=nil)
173
+ message = {
174
+ "id" => Time.now.to_f.to_s,
175
+ "dataset" => WATCH_DATASET,
176
+ "date" => Time.now,
177
+ "statusCode" => 200,
178
+ "type" => "watch.subscribe",
179
+ "body" => {
180
+ "condition" => keyword,
181
+ "subscriber" => "subscriber for #{keyword}",
182
+ },
183
+ }
184
+ message
185
+ end
186
+
187
+ def envelope_to_feed(keyword)
188
+ {
189
+ "id" => Time.now.to_f.to_s,
190
+ "dataset" => WATCH_DATASET,
191
+ "date" => Time.now,
192
+ "statusCode" => 200,
193
+ "type" => "watch.feed",
194
+ "body" => {
195
+ "targets" => {
196
+ "keyword" => keyword,
197
+ },
198
+ },
199
+ }
200
+ end
201
+ end
202
+ end
203
+
204
+ class MessageReceiver
205
+ def initialize(options={})
206
+ default_options = {
207
+ :host => "0.0.0.0",
208
+ :port => 0,
209
+ }
210
+ options = default_options.merge(options)
211
+ @socket = TCPServer.new(options[:host], options[:port])
212
+ start
213
+ end
214
+
215
+ def close
216
+ @socket.close
217
+ end
218
+
219
+ def host
220
+ @socket.addr[3]
221
+ end
222
+
223
+ def port
224
+ @socket.addr[1]
225
+ end
226
+
227
+ def new_message
228
+ @messages.pop
229
+ end
230
+
231
+ def start
232
+ @messages = Queue.new
233
+ Thread.new do
234
+ loop do
235
+ Thread.new(@socket.accept) do |client|
236
+ unpacker = MessagePack::Unpacker.new(client)
237
+ unpacker.each do |object|
238
+ @messages.push(object)
239
+ end
240
+ client.close
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
246
+ end