[Groonga-commit] droonga/fluent-plugin-droonga at 111d865 [master] Introduce Catalog::Dataset

Back to archive index

Yoji Shidara null+****@clear*****
Thu Feb 27 14:03:51 JST 2014


Yoji Shidara	2014-02-27 14:03:51 +0900 (Thu, 27 Feb 2014)

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

  Message:
    Introduce Catalog::Dataset

  Added files:
    lib/droonga/catalog/dataset.rb
    test/unit/catalog/test_dataset.rb
  Modified files:
    lib/droonga/catalog/version1.rb
    lib/droonga/catalog/version2.rb

  Added: lib/droonga/catalog/dataset.rb (+35 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/catalog/dataset.rb    2014-02-27 14:03:51 +0900 (e35c8e0)
@@ -0,0 +1,35 @@
+# Copyright (C) 2014 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+module Droonga
+  module Catalog
+    class Dataset
+      def initialize(name, data)
+        @name = name
+        @data = data
+      end
+
+      # provided for compatibility
+      def [](key)
+        @data[key]
+      end
+
+      # provided for compatibility
+      def []=(key, value)
+        @data[key] = value
+      end
+    end
+  end
+end

  Modified: lib/droonga/catalog/version1.rb (+3 -1)
===================================================================
--- lib/droonga/catalog/version1.rb    2014-02-27 13:47:26 +0900 (d1c07e8)
+++ lib/droonga/catalog/version1.rb    2014-02-27 14:03:51 +0900 (3c65098)
@@ -14,6 +14,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 require "droonga/catalog/base"
+require "droonga/catalog/dataset"
 
 module Droonga
   module Catalog
@@ -36,7 +37,8 @@ module Droonga
         device = @data["farms"][name]["device"]
         pattern = Regexp.new("^#{name}\.")
         results = {}
-        @data["datasets"].each do |dataset_name, dataset|
+        @data["datasets"].each do |dataset_name, dataset_data|
+          dataset = Dataset.new(dataset_name, dataset_data)
           workers = dataset["workers"]
           plugins = dataset["plugins"]
           dataset["ring"].each do |key, part|

  Modified: lib/droonga/catalog/version2.rb (+3 -1)
===================================================================
--- lib/droonga/catalog/version2.rb    2014-02-27 13:47:26 +0900 (fc5cbe0)
+++ lib/droonga/catalog/version2.rb    2014-02-27 14:03:51 +0900 (e0dbb45)
@@ -14,6 +14,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 require "droonga/catalog/base"
+require "droonga/catalog/dataset"
 
 module Droonga
   module Catalog
@@ -27,7 +28,8 @@ module Droonga
         device = "."
         pattern = Regexp.new("^#{name}\.")
         results = {}
-        @data["datasets"].each do |dataset_name, dataset|
+        @data["datasets"].each do |dataset_name, dataset_data|
+          dataset = Dataset.new(dataset_name, dataset_data)
           n_workers = dataset["nWorkers"]
           plugins = dataset["plugins"]
           dataset["replicas"].each do |replica|

  Added: test/unit/catalog/test_dataset.rb (+35 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/catalog/test_dataset.rb    2014-02-27 14:03:51 +0900 (46c048d)
@@ -0,0 +1,35 @@
+# Copyright (C) 2014 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+require "droonga/catalog/dataset"
+
+class CatalogDatasetTest < Test::Unit::TestCase
+  private
+  def create_dataset(dataset_name, data)
+    Droonga::Catalog::Dataset.new(dataset_name, data)
+  end
+
+  class DatasetTest < self
+    def test_value
+      assert_equal(2,
+                   create_dataset("dataset_name",
+                                  {
+                                    "nWorkers" => 2
+                                  }
+                                 )["nWorkers"]
+                  )
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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