[Groonga-commit] droonga/fluent-plugin-droonga at d47d395 [use-dataset-class] Use Droonga::Catalog::Dataset

Back to archive index

Yoji Shidara null+****@clear*****
Tue Feb 18 11:42:38 JST 2014


Yoji Shidara	2014-02-18 11:42:38 +0900 (Tue, 18 Feb 2014)

  New Revision: d47d39573b35907b84943bbf6dbaae065443b1fa
  https://github.com/droonga/fluent-plugin-droonga/commit/d47d39573b35907b84943bbf6dbaae065443b1fa

  Message:
    Use Droonga::Catalog::Dataset

  Modified files:
    lib/droonga/catalog/base.rb
    lib/droonga/catalog/dataset.rb

  Modified: lib/droonga/catalog/base.rb (+2 -12)
===================================================================
--- lib/droonga/catalog/base.rb    2014-02-17 18:54:52 +0900 (fcfdbbf)
+++ lib/droonga/catalog/base.rb    2014-02-18 11:42:38 +0900 (e6ca540)
@@ -16,6 +16,7 @@
 require "digest/sha1"
 require "zlib"
 require "time"
+require "droonga/catalog/dataset"
 require "droonga/message_processing_error"
 require "droonga/catalog/errors"
 
@@ -33,18 +34,7 @@ module Droonga
         raise MultiplexError.new(@errors) unles****@error*****?
 
         @data["datasets"].each do |name, dataset|
-          number_of_partitions = dataset["number_of_partitions"]
-          next if number_of_partitions < 2
-          total_weight = compute_total_weight(dataset)
-          continuum = []
-          dataset["ring"].each do |key, value|
-            points = number_of_partitions * 160 * value["weight"] / total_weight
-            points.times do |point|
-              hash = Digest::SHA1.hexdigest("#{key}:#{point}")
-              continuum << [hash[0..7].to_i(16), key]
-            end
-          end
-          dataset["continuum"] = continuum.sort do |a, b| a[0] - b[0]; end
+          dataset = Droonga::Catalog::Dataset.new(dataset)
         end
         @options = @data["options"] || {}
       end

  Modified: lib/droonga/catalog/dataset.rb (+4 -0)
===================================================================
--- lib/droonga/catalog/dataset.rb    2014-02-17 18:54:52 +0900 (1fe4432)
+++ lib/droonga/catalog/dataset.rb    2014-02-18 11:42:38 +0900 (c2c1c3d)
@@ -26,6 +26,10 @@ module Droonga
         @continuum ||= compute_continuum
       end
 
+      def [](key)
+        @data[key]
+      end
+
       private
       def compute_continuum
         number_of_partitions = @data["number_of_partitions"]
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index