[Groonga-commit] droonga/fluent-plugin-droonga at a7b942b [master] Support {} style load

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 6 13:40:22 JST 2014


Kouhei Sutou	2014-02-06 13:40:22 +0900 (Thu, 06 Feb 2014)

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

  Message:
    Support {} style load

  Modified files:
    lib/groonga_command_converter.rb

  Modified: lib/groonga_command_converter.rb (+12 -9)
===================================================================
--- lib/groonga_command_converter.rb    2014-02-06 13:30:37 +0900 (fdf832a)
+++ lib/groonga_command_converter.rb    2014-02-06 13:40:22 +0900 (4874058)
@@ -57,7 +57,7 @@ module Droonga
         parsed_values << value
       end
       @command_parser.on_load_complete do |command|
-        command[:columns] = parsed_columns.join(",")
+        command[:columns] ||= parsed_columns.join(",") if parsed_columns
         command[:values] = parsed_values.to_json
         split_load_command_to_add_commands(command, &block)
       end
@@ -113,7 +113,7 @@ module Droonga
     end
 
     def split_load_command_to_add_commands(command, &block)
-      columns = command[:columns].split(",")
+      columns = command.columns
       values = command[:values]
       values = JSON.parse(values)
       values.each do |record|
@@ -121,13 +121,16 @@ module Droonga
           :table => command[:table],
         }
 
-        record_values = {}
-        record.each_with_index do |value, column_index|
-          column = columns[column_index]
-          if column == "_key"
-            body[:key] = value
-          else
-            record_values[column.to_sym] = value
+        if record.is_a?(Hash)
+          record_values = record
+        else
+          record.each_with_index do |value, column_index|
+            column = columns[column_index]
+            if column == "_key"
+              body[:key] = value
+            else
+              record_values[column.to_sym] = value
+            end
           end
         end
         body[:values] = record_values unless record_values.empty?
-------------- next part --------------
HTML����������������������������...
Download 



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