YUKI Hiroshi
null+****@clear*****
Fri Jan 24 17:19:08 JST 2014
YUKI Hiroshi 2014-01-24 17:19:08 +0900 (Fri, 24 Jan 2014) New Revision: cd5562628a9f8549e3084770072b0780c9a671c1 https://github.com/droonga/fluent-plugin-droonga/commit/cd5562628a9f8549e3084770072b0780c9a671c1 Message: Reduce responses of Groonga commands Modified files: lib/droonga/plugin/distributor/groonga.rb lib/droonga/plugin/output_adapter/groonga.rb Modified: lib/droonga/plugin/distributor/groonga.rb (+28 -0) =================================================================== --- lib/droonga/plugin/distributor/groonga.rb 2014-01-24 17:17:05 +0900 (e5d8da6) +++ lib/droonga/plugin/distributor/groonga.rb 2014-01-24 17:19:08 +0900 (717b6cb) @@ -41,5 +41,33 @@ module Droonga def column_create(message) broadcast_all(message) end + + private + def scatterer(message, key) + scatterer = super + scatterer["outputs"] << "result" + scatterer + end + + def reducer(message) + reducer = super + reducer["body"]["result"] = { + "result_reduced" => { + "type" => "sum", + }, + } + reducer["inputs"] << "result" + reducer["outputs"] << "result_reduced" + reducer + end + + def gatherer(message) + gatherer = super + gatherer["body"]["result_reduced"] = { + "output" => "result", + } + gatherer["inputs"] << "result_reduced" + gatherer + end end end Modified: lib/droonga/plugin/output_adapter/groonga.rb (+3 -1) =================================================================== --- lib/droonga/plugin/output_adapter/groonga.rb 2014-01-24 17:17:05 +0900 (7cf7726) +++ lib/droonga/plugin/output_adapter/groonga.rb 2014-01-24 17:19:08 +0900 (7559eab) @@ -27,7 +27,9 @@ module Droonga command :groonga_generic_response def groonga_generic_response(output_message) - output_message.body = output_message.body["result"] + if output_message.body.include?("result") + output_message.body = output_message.body["result"] + end end end end -------------- next part -------------- HTML����������������������������... Download