YUKI Hiroshi
null+****@clear*****
Fri May 9 13:21:37 JST 2014
YUKI Hiroshi 2014-05-09 13:21:37 +0900 (Fri, 09 May 2014) New Revision: 184e3e739eeef57eb2a84e9602c7ffabf7a2cf24 https://github.com/droonga/droonga-engine/commit/184e3e739eeef57eb2a84e9602c7ffabf7a2cf24 Message: Cache collected all nodes Modified files: lib/droonga/catalog/collection_volume.rb lib/droonga/catalog/dataset.rb lib/droonga/catalog/single_volume.rb lib/droonga/catalog/slice.rb lib/droonga/catalog/version1.rb lib/droonga/catalog/version2.rb lib/droonga/catalog/volume_collection.rb Modified: lib/droonga/catalog/collection_volume.rb (+9 -5) =================================================================== --- lib/droonga/catalog/collection_volume.rb 2014-05-09 13:00:08 +0900 (ef8cc1a) +++ lib/droonga/catalog/collection_volume.rb 2014-05-09 13:21:37 +0900 (9e10260) @@ -70,11 +70,7 @@ module Droonga end def all_nodes - nodes = [] - slices.each do |slice| - nodes += slice.all_nodes - end - nodes.uniq.sort + @all_nodes ||= collect_all_nodes end private @@ -109,6 +105,14 @@ module Droonga key end end + + def collect_all_nodes + nodes = [] + slices.each do |slice| + nodes += slice.all_nodes + end + nodes.uniq.sort + end end end end Modified: lib/droonga/catalog/dataset.rb (+3 -3) =================================================================== --- lib/droonga/catalog/dataset.rb 2014-05-09 13:00:08 +0900 (a07ea4e) +++ lib/droonga/catalog/dataset.rb 2014-05-09 13:21:37 +0900 (9d2bbb3) @@ -59,14 +59,14 @@ module Droonga end def all_nodes - replicas.all_nodes + @all_nodes ||= replicas.all_nodes end def get_routes(args) routes = [] case args["type"] when "broadcast" - volumes = replicas.select(args["replica"].to_sym) + volumes = replicas.select(args["replica"].to_sym, args["live_nodes"]) volumes.each do |volume| slices = volume.select_slices slices.each do |slice| @@ -74,7 +74,7 @@ module Droonga end end when "scatter" - volumes = replicas.select(args["replica"].to_sym) + volumes = replicas.select(args["replica"].to_sym, args["live_nodes"]) volumes.each do |volume| slice = volume.choose_slice(args["record"]) routes << slice.volume.address Modified: lib/droonga/catalog/single_volume.rb (+1 -1) =================================================================== --- lib/droonga/catalog/single_volume.rb 2014-05-09 13:00:08 +0900 (c851266) +++ lib/droonga/catalog/single_volume.rb 2014-05-09 13:21:37 +0900 (5db817f) @@ -25,7 +25,7 @@ module Droonga end def all_nodes - [address.split("/").first] + @all_nodes ||= [address.split("/").first] end end end Modified: lib/droonga/catalog/slice.rb (+1 -1) =================================================================== --- lib/droonga/catalog/slice.rb 2014-05-09 13:00:08 +0900 (94e9b3a) +++ lib/droonga/catalog/slice.rb 2014-05-09 13:21:37 +0900 (1a3b3b9) @@ -38,7 +38,7 @@ module Droonga end def all_nodes - volume.all_nodes + @all_nodes ||= volume.all_nodes end end end Modified: lib/droonga/catalog/version1.rb (+8 -4) =================================================================== --- lib/droonga/catalog/version1.rb 2014-05-09 13:00:08 +0900 (f1c858b) +++ lib/droonga/catalog/version1.rb 2014-05-09 13:21:37 +0900 (390e93e) @@ -67,10 +67,7 @@ module Droonga end def all_nodes - nodes = @data["zones"].collect do |zone| - zone.split("/").first - end - nodes.sort.uniq + @all_nodes ||= collect_all_nodes end private @@ -100,6 +97,13 @@ module Droonga end end + def collect_all_nodes + nodes = @data["zones"].collect do |zone| + zone.split("/").first + end + nodes.sort.uniq + end + def validate do_validation do validate_effective_date Modified: lib/droonga/catalog/version2.rb (+9 -5) =================================================================== --- lib/droonga/catalog/version2.rb 2014-05-09 13:00:08 +0900 (22f7425) +++ lib/droonga/catalog/version2.rb 2014-05-09 13:21:37 +0900 (da1e42f) @@ -58,11 +58,7 @@ module Droonga end def all_nodes - nodes = [] - @datasets.each do |name, dataset| - nodes += dataset.all_nodes - end - nodes.sort.uniq + @all_nodes ||= collect_all_nodes end private @@ -77,6 +73,14 @@ module Droonga @datasets[name] = Dataset.new(name, dataset) end end + + def collect_all_nodes + nodes = [] + @datasets.each do |name, dataset| + nodes += dataset.all_nodes + end + nodes.sort.uniq + end end end end Modified: lib/droonga/catalog/volume_collection.rb (+5 -0) =================================================================== --- lib/droonga/catalog/volume_collection.rb 2014-05-09 13:00:08 +0900 (0eb9194) +++ lib/droonga/catalog/volume_collection.rb 2014-05-09 13:21:37 +0900 (966ac9e) @@ -53,6 +53,11 @@ module Droonga end def all_nodes + @all_nodes ||= collect_all_nodes + end + + private + def collect_all_nodes nodes = [] @volumes.each do |volume| nodes += volume.all_nodes -------------- next part -------------- HTML����������������������������... ダウンロード