[Groonga-commit] groonga/fluent-plugin-droonga at 259c265 [master] table_create: use command-client to parse parameters

アーカイブの一覧に戻る

Kosuke Asami null+****@clear*****
Thu Jul 11 15:43:10 JST 2013


Kosuke Asami	2013-07-11 15:43:10 +0900 (Thu, 11 Jul 2013)

  New Revision: 259c265b47cc9e1ca6f4cb1b8e70f5403b3445de
  https://github.com/groonga/fluent-plugin-droonga/commit/259c265b47cc9e1ca6f4cb1b8e70f5403b3445de

  Message:
    table_create: use command-client to parse parameters

  Modified files:
    Gemfile
    lib/droonga/plugin/groonga/table_create.rb

  Modified: Gemfile (+3 -0)
===================================================================
--- Gemfile    2013-07-11 13:39:21 +0900 (2208e8f)
+++ Gemfile    2013-07-11 15:43:10 +0900 (a0c8af6)
@@ -18,8 +18,11 @@ source "https://rubygems.org"
 gemspec
 
 local_rroonga_path = File.join(File.dirname(__FILE__), "..", "rroonga")
+local_groonga_command_path = File.join(File.dirname(__FILE__), "..", "groonga-command")
 if File.exist?(local_rroonga_path)
   gem "rroonga", :path => local_rroonga_path
+  gem "groonga-command", :path => local_groonga_command_path
 elsif ENV["TRAVIS"] == "true"
   gem "rroonga", :git => "git://github.com/ranguba/rroonga.git"
+  gem "groonga-command", :git => "git://github.com/groonga/groonga-command.git"
 end

  Modified: lib/droonga/plugin/groonga/table_create.rb (+17 -20)
===================================================================
--- lib/droonga/plugin/groonga/table_create.rb    2013-07-11 13:39:21 +0900 (49fcc9a)
+++ lib/droonga/plugin/groonga/table_create.rb    2013-07-11 15:43:10 +0900 (61e74c1)
@@ -16,6 +16,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 require "groonga"
+require "groonga/command/table-create"
 
 module Droonga
   class GroongaHandler
@@ -25,10 +26,13 @@ module Droonga
       end
 
       def execute(request)
-        name = request["name"]
+        command_class = Groonga::Command.find("table_create")
+        command = command_class.new("table_create", request)
+
+        name = command["name"]
         return [false] unless name
 
-        options = parse_request(request)
+        options = parse_request(command)
         Groonga::Schema.define(:context => @context) do |schema|
           schema.create_table(name, options)
         end
@@ -48,24 +52,17 @@ module Droonga
 
       def parse_flags(options, request)
         options[:type] = :hash
-        if request["flags"]
-          request["flags"].split(/\|/).each do |flag|
-            case flag
-            when "TABLE_NO_KEY"
-              options[:type] = :array
-            when "TABLE_HASH_KEY"
-              options[:type] = :hash
-            when "TABLE_PAT_KEY"
-              options[:type] = :patricia_trie
-            when "TABLE_DAT_KEY"
-              options[:type] = :double_array_trie
-            when "KEY_WITH_SIS"
-              options[:key_with_sis] = true
-            end
-          end
-          if options[:key_with_sis]
-            options[:key_with_sis] = false unless options[:type] == :patricia_trie
-          end
+        if request.table_no_key?
+          options[:type] = :array
+        elsif request.table_hash_key?
+          options[:type] = :hash
+        elsif request.table_pat_key?
+          options[:type] = :patricia_trie
+        elsif request.table_dat_key?
+          options[:type] = :double_array_trie
+        end
+        if request.key_with_sis? and request.table_pat_key?
+          options[:key_with_sis] = true
         end
         options
       end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る