[Groonga-commit] groonga/groonga-query-log at 45ef38c [master] Add support for flush

Back to archive index
Kouhei Sutou null+****@clear*****
Thu May 9 18:48:47 JST 2019


Kouhei Sutou	2019-05-09 18:48:47 +0900 (Thu, 09 May 2019)

  Revision: 45ef38ccd47f85ca83aa5eb3806901d8dc2c42df
  https://github.com/groonga/groonga-query-log/commit/45ef38ccd47f85ca83aa5eb3806901d8dc2c42df

  Message:
    Add support for flush

  Modified files:
    lib/groonga-query-log/parser.rb
    test/test-parser.rb

  Modified: lib/groonga-query-log/parser.rb (+12 -8)
===================================================================
--- lib/groonga-query-log/parser.rb    2019-03-26 16:49:02 +0900 (ec3dab7)
+++ lib/groonga-query-log/parser.rb    2019-05-09 18:48:47 +0900 (2a3365a)
@@ -116,17 +116,21 @@ module GroongaQueryLog
         statistic.start(time_stamp, rest)
         @parsing_statistics[context_id] = statistic
       when ":"
-        return unless /\A(\d+) (.+)\((\d+)\)(\[.+\])?(?:: (.*))?/ =~ rest
-        elapsed = $1
-        name = $2
-        name += $4 if $4
-        n_records = $3.to_i
-        extra = $5
+        return unless /\A
+                       (?<elapsed>\d+)
+                       \ 
+                       (?<name>[a-zA-Z._-]+)
+                       (?<sub_name_before>\[.+?\])?
+                       (?:\((?<n_records>\d+)\))?
+                       (?<sub_name_after>\[.+?\])?
+                       (?::\ (?<extra>.*))?
+                      /x =~ rest
         statistic = @parsing_statistics[context_id]
         return if statistic.nil?
-        statistic.add_operation(:name => name,
+        full_name = "#{name}#{sub_name_before}#{sub_name_after}"
+        statistic.add_operation(:name => full_name,
                                 :elapsed => elapsed.to_i,
-                                :n_records => n_records,
+                                :n_records => n_records.to_i,
                                 :extra => extra)
       when "<"
         return unless /\A(\d+) rc=(-?\d+)/ =~ rest

  Modified: test/test-parser.rb (+28 -1)
===================================================================
--- test/test-parser.rb    2019-03-26 16:49:02 +0900 (c020d96)
+++ test/test-parser.rb    2019-05-09 18:48:47 +0900 (a21a5b1)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2017  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2011-2019  Kouhei Sutou <kou****@clear*****>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -267,6 +267,33 @@ class ParserTest < Test::Unit::TestCase
     end
   end
 
+  class NameFieldTest < self
+    def test_io_flush
+      statistics = parse(<<-LOG)
+2019-05-09 18:44:25.983672|0x7fff5e4a3060|>io_flush Lexicon.sources_value --output_type json
+2019-05-09 18:44:25.989502|0x7fff5e4a3060|:000000005833721 flush[Lexicon.sources_value]
+2019-05-09 18:44:25.989519|0x7fff5e4a3060|:000000005848066 flush[(anonymous:table:dat_key)]
+2019-05-09 18:44:25.990491|0x7fff5e4a3060|:000000006820471 flush[(anonymous:column:var_size)]
+2019-05-09 18:44:25.990496|0x7fff5e4a3060|:000000006824538 flush[(anonymous:table:hash_key)]
+2019-05-09 18:44:25.991425|0x7fff5e4a3060|:000000007753922 flush[(anonymous:column:var_size)]
+2019-05-09 18:44:25.991427|0x7fff5e4a3060|:000000007755618 flush[(DB)]
+2019-05-09 18:44:25.991431|0x7fff5e4a3060|<000000007759904 rc=0
+      LOG
+      operations = statistics.first.operations.collect do |operation|
+        operation[:name]
+      end
+      expected = [
+        "flush[Lexicon.sources_value]",
+        "flush[(anonymous:table:dat_key)]",
+        "flush[(anonymous:column:var_size)]",
+        "flush[(anonymous:table:hash_key)]",
+        "flush[(anonymous:column:var_size)]",
+        "flush[(DB)]",
+      ]
+      assert_equal(expected, operations)
+    end
+  end
+
   class ExtraFieldTest < self
     def test_load
       statistics = parse(<<-LOG)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190509/237f3a41/attachment-0001.html>


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