[Groonga-commit] ranguba/rroonga at b81506e [master] schema: support forward index

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Feb 21 16:42:09 JST 2014


Kouhei Sutou	2014-02-21 16:42:09 +0900 (Fri, 21 Feb 2014)

  New Revision: b81506e4c3fd711ac034de9cdfd7b71402abbffe
  https://github.com/ranguba/rroonga/commit/b81506e4c3fd711ac034de9cdfd7b71402abbffe

  Message:
    schema: support forward index

  Modified files:
    lib/groonga/schema.rb
    test/test-schema-dumper.rb

  Modified: lib/groonga/schema.rb (+1 -1)
===================================================================
--- lib/groonga/schema.rb    2014-02-21 16:40:46 +0900 (ecdb53e)
+++ lib/groonga/schema.rb    2014-02-21 16:42:09 +0900 (e290d51)
@@ -1445,7 +1445,7 @@ module Groonga
             target_column_full_name = target_column_full_name.name
           end
           target_table, target_column = target_column_full_name.split(/\./, 2)
-          target_columns = [target_column]
+          target_columns = [target_column].compact
           key = [target_table, target_columns]
         else
           target_table_name = target_table_or_target_column_full_name

  Modified: test/test-schema-dumper.rb (+49 -0)
===================================================================
--- test/test-schema-dumper.rb    2014-02-21 16:40:46 +0900 (38e9d04)
+++ test/test-schema-dumper.rb    2014-02-21 16:42:09 +0900 (9d74ba7)
@@ -104,6 +104,23 @@ class SchemaDumperTest < Test::Unit::TestCase
     end
   end
 
+  def define_forward_index_schema
+    Groonga::Schema.define do |schema|
+      schema.create_table("Tags",
+                          :type => :hash,
+                          :key_type => "ShortText") do |table|
+      end
+
+      schema.create_table("Memos",
+                          :type => :patricia_trie,
+                          :key_type => "ShortText") do |table|
+        table.index("Tags",
+                    :name => "tags",
+                    :with_weight => true)
+      end
+    end
+  end
+
   def define_double_array_trie_schema
     Groonga::Schema.define do |schema|
       schema.create_table("Accounts",
@@ -220,6 +237,27 @@ end
       SCHEMA
     end
 
+    def test_forward_index
+      define_forward_index_schema
+      assert_equal(<<-SCHEMA, dump)
+create_table("Memos",
+             :type => :patricia_trie,
+             :key_type => "ShortText",
+             :force => true) do |table|
+end
+
+create_table("Tags",
+             :type => :hash,
+             :key_type => "ShortText",
+             :force => true) do |table|
+end
+
+change_table("Memos") do |table|
+  table.index("Tags", [], :name => "tags", :with_weight => true)
+end
+      SCHEMA
+    end
+
     def test_double_array_trie
       define_double_array_trie_schema
       assert_equal(<<-SCHEMA, dump)
@@ -289,6 +327,17 @@ column_create Terms Items_title COLUMN_INDEX|WITH_POSITION Items title
       SCHEMA
     end
 
+    def test_forward_index
+      define_forward_index_schema
+      assert_equal(<<-SCHEMA, dump)
+table_create Memos TABLE_PAT_KEY --key_type ShortText
+
+table_create Tags TABLE_HASH_KEY --key_type ShortText
+
+column_create Memos tags COLUMN_INDEX|WITH_WEIGHT Tags
+      SCHEMA
+    end
+
     def test_double_array_trie
       define_double_array_trie_schema
       assert_equal(<<-SCHEMA, dump)
-------------- next part --------------
HTML����������������������������...
Download 



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