[Groonga-commit] groonga/fluent-plugin-groonga at 10d015d [master] out: support mixed case on command in record case

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jan 16 10:04:18 JST 2018


Kouhei Sutou	2018-01-16 10:04:18 +0900 (Tue, 16 Jan 2018)

  New Revision: 10d015da37560d0424dee415bc57058279aecebe
  https://github.com/groonga/fluent-plugin-groonga/commit/10d015da37560d0424dee415bc57058279aecebe

  Message:
    out: support mixed case on command in record case

  Modified files:
    lib/fluent/plugin/out_groonga.rb
    test/test_output.rb

  Modified: lib/fluent/plugin/out_groonga.rb (+10 -5)
===================================================================
--- lib/fluent/plugin/out_groonga.rb    2018-01-16 10:01:18 +0900 (66c176d)
+++ lib/fluent/plugin/out_groonga.rb    2018-01-16 10:04:18 +0900 (3f25785)
@@ -583,22 +583,27 @@ module Fluent
           records = []
           chunk.msgpack_each do |message|
             tag, _, record = message
+            name = nil
+            arguments = nil
             case tag
             when /\Agroonga\.command\./
               name = $POSTMATCH
+              arguments = record
+            when "groonga.command"
+              name = record["name"]
+              arguments = record["arguments"]
+            end
+
+            if name
               unless records.empty?
                 store_records(records)
                 records.clear
               end
-              @client.execute(name, record)
+              @client.execute(name, arguments)
               case name
               when /\A(?:table|column)_(?:create|remove)/
                 @schema.clear_cache
               end
-            when "groonga.command"
-              name = record["name"]
-              arguments = record["arguments"]
-              @client.execute(name, arguments)
             else
               records << record
             end

  Modified: test/test_output.rb (+67 -0)
===================================================================
--- test/test_output.rb    2018-01-16 10:01:18 +0900 (baa8fc9)
+++ test/test_output.rb    2018-01-16 10:04:18 +0900 (ff1c510)
@@ -405,6 +405,73 @@ EOC
         ]
       end
 
+      def test_command_name_position_record
+        @response_bodies << JSON.generate([
+                                            [0, 0.0, 0.0],
+                                            table_list_response_body,
+                                          ])
+        @response_bodies << JSON.generate([
+                                            [0, 0.0, 0.0],
+                                            column_list_response_body,
+                                          ])
+        driver = create_driver
+        time = event_time("2012-10-26T08:45:42Z")
+        driver.run do
+          @response_bodies << JSON.generate([[0, 0.0, 0.0], 2])
+          driver.feed("log", time + 0, {"message" => "message1"})
+          driver.feed("log", time + 1, {"message" => "message2"})
+
+          @response_bodies << JSON.generate([[0, 0.0, 0.0], true])
+          driver.feed("groonga.command",
+                      time + 2,
+                      {
+                        "name" => "column_create",
+                        "arguments" => {
+                          "table" => "Logs",
+                          "name" => "new_column",
+                          "flags" => "COLUMN_SCALAR",
+                          "type" => "ShortText",
+                        },
+                      })
+
+          @response_bodies << JSON.generate([
+                                              [0, 0.0, 0.0],
+                                              table_list_response_body,
+                                            ])
+          new_column_list_response_body = column_list_response_body
+          new_column_list_response_body << [
+            258,
+            "new_column",
+            "/tmp/db/db.0000102",
+            "scalar",
+            "COLUMN_SCALAR",
+              "Logs",
+            "ShortText",
+            [
+            ],
+          ]
+          @response_bodies << JSON.generate([
+                                              [0, 0.0, 0.0],
+                                              new_column_list_response_body,
+                                            ])
+          @response_bodies << JSON.generate([[0, 0.0, 0.0], 2])
+          driver.feed("log", time + 3,
+                      {"message" => "message3", "new_column" => "value1"})
+          driver.feed("log", time + 4,
+                      {"message" => "message4", "new_column" => "value2"})
+        end
+        assert_equal([
+                       "/d/table_list",
+                       "/d/column_list?table=Logs",
+                       "/d/load?table=Logs",
+                       "/d/column_create?flags=COLUMN_SCALAR&name=new_column&table=Logs&type=ShortText",
+                       "/d/table_list",
+                       "/d/column_list?table=Logs",
+                       "/d/load?table=Logs",
+                     ],
+                     @request_urls)
+      end
+
       def test_command_name_position_tag
         @response_bodies << JSON.generate([
                                             [0, 0.0, 0.0],
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180116/4f463d80/attachment-0001.htm 



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