[Groonga-commit] droonga/fluent-plugin-droonga at 0922eb2 [master] Add CollectionVolume

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Mar 21 15:43:34 JST 2014


Kouhei Sutou	2014-03-21 15:43:34 +0900 (Fri, 21 Mar 2014)

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

  Message:
    Add CollectionVolume

  Added files:
    lib/droonga/catalog/collection_volume.rb
    test/unit/catalog/test_collection_volume.rb

  Added: lib/droonga/catalog/collection_volume.rb (+36 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/catalog/collection_volume.rb    2014-03-21 15:43:34 +0900 (48fac53)
@@ -0,0 +1,36 @@
+# 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 CollectionVolume
+      def initialize(data)
+        @data = data
+      end
+
+      def dimension
+        @data["dimension"] || "_key"
+      end
+
+      def slicer
+        @data["slicer"] || "hash"
+      end
+
+      def slices
+        @data["slices"]
+      end
+    end
+  end
+end

  Added: test/unit/catalog/test_collection_volume.rb (+66 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/catalog/test_collection_volume.rb    2014-03-21 15:43:34 +0900 (9c006d5)
@@ -0,0 +1,66 @@
+# 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/collection_volume"
+
+class CatalogSingleVolumeTest < Test::Unit::TestCase
+  def create_collection_volume(data)
+    Droonga::Catalog::CollectionVolume.new(data)
+  end
+
+  class DimensionTest < self
+    def test_default
+      data = {
+      }
+      volume = create_collection_volume(data)
+      assert_equal("_key", volume.dimension)
+    end
+
+    def test_specified
+      data = {
+        "dimension" => "group",
+      }
+      volume = create_collection_volume(data)
+      assert_equal("group", volume.dimension)
+    end
+  end
+
+  class SlicerTest < self
+    def test_default
+      data = {
+      }
+      volume = create_collection_volume(data)
+      assert_equal("hash", volume.slicer)
+    end
+
+    def test_specified
+      data = {
+        "slicer" => "ordinal",
+      }
+      volume = create_collection_volume(data)
+      assert_equal("ordinal", volume.slicer)
+    end
+  end
+
+  class SlicesTest < self
+    def test_empty
+      data = {
+        "slices" => [],
+      }
+      volume = create_collection_volume(data)
+      assert_equal([], volume.slices)
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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