[groonga-commit:3549] ranguba/hroonga [master] implement flags option

null+ranguba at clear-code.com null+ranguba at clear-code.com
Sat Jun 18 00:02:32 EDT 2011


SHIMODA Hiroshi	2011-06-18 04:02:32 +0000 (Sat, 18 Jun 2011)

  New Revision: 9aa7c80927724b9eaa9c3a5a6b8f5ed40f82d365

  Log:
    implement flags option

  Modified files:
    lib/hroonga/command/column-create.rb
    lib/hroonga/command/request.rb
    lib/hroonga/command/table-create.rb

  Modified: lib/hroonga/command/column-create.rb (+15 -1)
===================================================================
--- lib/hroonga/command/column-create.rb    2011-06-18 03:00:58 +0000 (30affd4)
+++ lib/hroonga/command/column-create.rb    2011-06-18 04:02:32 +0000 (c071dd5)
@@ -38,10 +38,24 @@ module Hroonga
       def create
         Groonga::Schema.define(:context => context) do |schema|
           schema.change_table(request.table_name) do |table|
-            table.column(request.column_name, request.value_type, :type => request.column_type)
+            table.column(request.column_name, request.value_type, options)
           end
         end
       end
+
+      def options
+        @options ||= create_options
+      end
+
+      def create_options
+          options = {}
+          options[:type] = request.column_type
+          options[:source] = request.column_source
+          options[:with_section] = true if request.column_flags[:WITH_SECTION]
+          options[:with_weight] = true if request.column_flags[:WITH_WEIGHT]
+          options[:with_position] = true if request.column_flags[:WITH_POSITION]
+          options
+      end
     end
   end
 end

  Modified: lib/hroonga/command/request.rb (+11 -5)
===================================================================
--- lib/hroonga/command/request.rb    2011-06-18 03:00:58 +0000 (8e0a7ea)
+++ lib/hroonga/command/request.rb    2011-06-18 04:02:32 +0000 (4836787)
@@ -73,7 +73,7 @@ module Hroonga
       end
 
       def default_table_flags
-        nil #XXX
+        {}
       end
 
       def column_type
@@ -92,12 +92,16 @@ module Hroonga
         :ShortText
       end
 
+      def column_source
+        @column_source ||= option("source")
+      end
+
       def column_flags
         @column_flags ||= flags_option("flags") || default_column_flags
       end
 
       def default_column_flags
-        nil #XXX
+        {}
       end
 
 
@@ -155,10 +159,12 @@ module Hroonga
 
       def flags_option(key)
         if query.include?(key)
+          flags = {}
           value = unescape(query[key])
-          value = value.split("|")
-          #XXX
-          nil
+          value.strip.split(/\s*\|\s*/).each do |flag|
+            flags[flag.to_sym] = true
+          end
+          flags
         else
           nil
         end

  Modified: lib/hroonga/command/table-create.rb (+5 -3)
===================================================================
--- lib/hroonga/command/table-create.rb    2011-06-18 03:00:58 +0000 (004315e)
+++ lib/hroonga/command/table-create.rb    2011-06-18 04:02:32 +0000 (5f3417a)
@@ -47,9 +47,11 @@ module Hroonga
 
       def create_options
           options = {}
-          options[:type] = request.table_type if request.table_type
-          options[:key_type] = request.key_type if request.key_type
-          options[:default_tokenizer] = request.default_tokenizer if request.default_tokenizer
+          options[:type] = request.table_type
+          options[:key_type] = request.key_type
+          options[:default_tokenizer] = request.default_tokenizer
+          options[:key_normalize] = true if request.table_flags[:KEY_NORMALIZE]
+          options[:key_with_sis] = true if request.table_flags[:KEY_WITH_SIS]
           options
       end
     end



More information about the groonga-commit mailing list