[Groonga-commit] groonga/groonga-query-log at 50ce266 [master] Add support for sub name after [...]

Back to archive index
Kouhei Sutou null+****@clear*****
Thu May 9 19:02:56 JST 2019


Kouhei Sutou	2019-05-09 19:02:56 +0900 (Thu, 09 May 2019)

  Revision: 50ce2661b010168c4d91209341259e42eab3648f
  https://github.com/groonga/groonga-query-log/commit/50ce2661b010168c4d91209341259e42eab3648f

  Message:
    Add support for sub name after [...]

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

  Modified: lib/groonga-query-log/parser.rb (+1 -1)
===================================================================
--- lib/groonga-query-log/parser.rb    2019-05-09 18:54:08 +0900 (a3198b4)
+++ lib/groonga-query-log/parser.rb    2019-05-09 19:02:56 +0900 (c02ce44)
@@ -121,7 +121,7 @@ module GroongaQueryLog
                        \ 
                        (?<raw_message>
                          (?<name>[a-zA-Z._-]+)
-                         (?<sub_name_before>\[.+?\])?
+                         (?<sub_name_before>\[.+?\](?:[a-zA-Z._-]*))?
                          (?:\((?<n_records>\d+)\))?
                          (?<sub_name_after>\[.+?\])?
                          (?::\ (?<extra>.*))?

  Modified: test/test-parser.rb (+28 -0)
===================================================================
--- test/test-parser.rb    2019-05-09 18:54:08 +0900 (79c92e4)
+++ test/test-parser.rb    2019-05-09 19:02:56 +0900 (a581b98)
@@ -298,6 +298,34 @@ class ParserTest < Test::Unit::TestCase
       ]
       assert_equal(expected, operations)
     end
+
+    def test_labeled_drilldown
+      statistics = parse(<<-LOG)
+2019-05-09 19:00:12.085062|0x7ffdf54d2180|>select Memos   --limit 0   --output_columns _id   --drilldowns[tags].keys tags   --drilldowns[tags].adjuster 'categories @ \"full-text-search\" * 2 + categories @ \"mysql\"'   --drilldowns[tags].output_columns _key,_nsubrecs,_score --output_type json
+2019-05-09 19:00:12.085165|0x7ffdf54d2180|:000000000105785 select(3)
+2019-05-09 19:00:12.085664|0x7ffdf54d2180|:000000000605514 drilldowns[tags].adjust(3)
+2019-05-09 19:00:12.085672|0x7ffdf54d2180|:000000000611117 drilldowns[tags](3)
+2019-05-09 19:00:12.085696|0x7ffdf54d2180|:000000000635356 output(0)
+2019-05-09 19:00:12.085722|0x7ffdf54d2180|:000000000661819 output.drilldowns[tags](3)
+2019-05-09 19:00:12.085768|0x7ffdf54d2180|<000000000707717 rc=0
+      LOG
+      operations = statistics.first.operations.collect do |operation|
+        [operation[:name], operation[:raw_message]]
+      end
+      expected = [
+        ["select",
+         "select(3)"],
+        ["drilldowns[tags].adjust",
+         "drilldowns[tags].adjust(3)"],
+        ["drilldowns[tags]",
+         "drilldowns[tags](3)"],
+        ["output",
+         "output(0)"],
+        ["output.drilldowns[tags]",
+         "output.drilldowns[tags](3)"],
+      ]
+      assert_equal(expected, operations)
+    end
   end
 
   class ExtraFieldTest < self
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190509/5017a002/attachment-0001.html>


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