[Groonga-commit] groonga/fluent-plugin-droonga at 8482c2a [master] column_create: support index-type column

Back to archive index

Kosuke Asami null+****@clear*****
Tue Jul 16 15:02:50 JST 2013


Kosuke Asami	2013-07-16 15:02:50 +0900 (Tue, 16 Jul 2013)

  New Revision: 8482c2a7429a1fb4866e146dae517f2c097d765f
  https://github.com/groonga/fluent-plugin-droonga/commit/8482c2a7429a1fb4866e146dae517f2c097d765f

  Message:
    column_create: support index-type column
    
    TODO:
    Support "name" parameter and "type" parameter for index-type column

  Modified files:
    lib/droonga/plugin/groonga/column_create.rb
    test/plugin/groonga/test_column_create.rb

  Modified: lib/droonga/plugin/groonga/column_create.rb (+15 -1)
===================================================================
--- lib/droonga/plugin/groonga/column_create.rb    2013-07-16 14:37:35 +0900 (b304da4)
+++ lib/droonga/plugin/groonga/column_create.rb    2013-07-16 15:02:50 +0900 (a9e5d60)
@@ -30,7 +30,7 @@ module Droonga
         @command = command_class.new("column_create", request)
 
         if****@comma*****_index?
-          # TODO: define_index
+          define_index
         else
           define_column
         end
@@ -66,6 +66,20 @@ module Droonga
         end
         options
       end
+
+      def define_index
+        table_name = @command["table"]
+        target_table = @command["type"]
+        target_column = @command["source"]
+
+        options = {}
+        Groonga::Schema.define(:context => @context) do |schema|
+          schema.change_table(table_name) do |table|
+            table.index("#{target_table}.#{target_column}", options)
+          end
+        end
+        [true]
+      end
     end
   end
 end

  Modified: test/plugin/groonga/test_column_create.rb (+22 -0)
===================================================================
--- test/plugin/groonga/test_column_create.rb    2013-07-16 14:37:35 +0900 (6d318f4)
+++ test/plugin/groonga/test_column_create.rb    2013-07-16 15:02:50 +0900 (3a4e2a7)
@@ -64,5 +64,27 @@ column_create Books title COLUMN_VECTOR ShortText
       @handler.column_create(request)
       assert_equal("table_create Books TABLE_HASH_KEY --key_type ShortText\n#{data[:schema]}", dump)
     end
+
+    data({
+           "WITH_SECTION" => {
+             :flags => "COLUMN_INDEX",
+             :schema => <<-SCHEMA,
+column_create Books Books_title COLUMN_INDEX Books title
+             SCHEMA
+           },
+         })
+    def test_index_flags(data)
+      request = {
+        "table"  => "Books",
+        "name"   => "entry_title",
+        "type"   => "Books",
+        "source" => "title",
+        "flags"  => data[:flags],
+      }
+      @handler.table_create({"name" => "Books"})
+      @handler.column_create({"table" => "Books", "name" => "title", "type" => "ShortText"})
+      @handler.column_create(request)
+      assert_equal("table_create Books TABLE_HASH_KEY --key_type ShortText\ncolumn_create Books title COLUMN_SCALAR ShortText\n\n#{data[:schema]}", dump)
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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