Class: Droonga::Catalog::Version2
- Defined in:
- lib/droonga/catalog/version2.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #datasets ⇒ Object
- #get_routes(name, args) ⇒ Object
-
#initialize(data, path) ⇒ Version2
constructor
A new instance of Version2.
- #slices(name) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(data, path) ⇒ Version2
Returns a new instance of Version2.
23 24 25 26 27 |
# File 'lib/droonga/catalog/version2.rb', line 23 def initialize(data, path) super validate prepare_data end |
Instance Method Details
#datasets ⇒ Object
29 30 31 |
# File 'lib/droonga/catalog/version2.rb', line 29 def datasets @datasets end |
#get_routes(name, args) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/droonga/catalog/version2.rb', line 60 def get_routes(name, args) routes = [] dataset = dataset(name) case args["type"] when "broadcast" volumes = dataset.replicas.select(args["replica"].to_sym) volumes.each do |volume| slices = volume.select_slices slices.each do |slice| routes << slice.volume.address end end when "scatter" volumes = dataset.replicas.select(args["replica"].to_sym) volumes.each do |volume| slice = volume.choose_slice(args["record"]) routes << slice.volume.address end end routes end |
#slices(name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/droonga/catalog/version2.rb', line 33 def slices(name) device = "." pattern = Regexp.new("^#{name}\.") results = {} @datasets.each do |dataset_name, dataset| n_workers = dataset.n_workers plugins = dataset.plugins dataset.replicas.each do |volume| volume.slices.each do |slice| volume_address = slice.volume.address if pattern =~ volume_address path = File.join([device, $POSTMATCH, "db"]) path = File.(path, base_path) = { :dataset => dataset_name, :database => path, :n_workers => n_workers, :plugins => plugins } results[volume_address] = end end end end results end |