YUKI Hiroshi
null+****@clear*****
Fri Dec 5 12:23:40 JST 2014
YUKI Hiroshi 2014-12-05 12:23:40 +0900 (Fri, 05 Dec 2014) New Revision: d6aa915f652cdb401c60c0bacdda2baa07fefb6d https://github.com/droonga/droonga-engine/commit/d6aa915f652cdb401c60c0bacdda2baa07fefb6d Merged e0f9f34: Merge pull request #30 from piroor/replicas-in-a-branch Message: Split complex functions to simple one Modified files: lib/droonga/catalog/dataset.rb Modified: lib/droonga/catalog/dataset.rb (+20 -14) =================================================================== --- lib/droonga/catalog/dataset.rb 2014-12-05 12:17:00 +0900 (ad31d8e) +++ lib/droonga/catalog/dataset.rb 2014-12-05 12:23:40 +0900 (bfe2dc9) @@ -64,7 +64,7 @@ module Droonga end def compute_routes(message, live_nodes) - compute_routes_from_replicas(replicas, message, live_nodes) + routes_from_replicas(replicas, message, live_nodes) end def single_slice? @@ -77,34 +77,40 @@ module Droonga end private - def compute_routes_from_replicas(replicas, message, live_nodes) + def routes_from_replicas(replicas, message, live_nodes) routes = [] case message["type"] when "broadcast" replicas = replicas.select(message["replica"].to_sym, live_nodes) replicas.each do |replica| slices = replica.select_slices - slices.each do |slice| - if slice.replicas - routes += compute_routes_from_replicas(slice.replicas, message, live_nodes) - else - routes << slice.volume.address.to_s - end - end + routes += routes_from_slices(slices, message, live_nodes) end when "scatter" replicas = replicas.select(message["replica"].to_sym, live_nodes) replicas.each do |replica| slice = replica.choose_slice(message["record"]) - if slice.replicas - routes += compute_routes_from_replicas(slice.replicas, message, live_nodes) - else - routes << slice.volume.address.to_s - end + routes += routes_from_slice(slice, message, live_nodes) end end routes end + + def routes_from_slices(slices, message, live_nodes) + routes = [] + slices.each do |slice| + routes += routes_from_slice(slice, message, live_nodes) + end + routes + end + + def routes_from_slice(slice, message, live_nodes) + if slice.replicas + routes_from_replicas(slice.replicas, message, live_nodes) + else + [slice.volume.address.to_s] + end + end end end end -------------- next part -------------- HTML����������������������������... Descargar