Kentaro Hayashi
null+****@clear*****
Wed May 31 14:13:14 JST 2017
Kentaro Hayashi 2017-05-31 14:13:14 +0900 (Wed, 31 May 2017) New Revision: 6fc25664a6ed80614c845fc023aacca76ee7ae39 https://github.com/groonga/groonga-query-log/commit/6fc25664a6ed80614c845fc023aacca76ee7ae39 Merged 28dabff: Merge pull request #22 from kenhys/support-changed-labeled-drilldown Message: Support changed format about labeled drilldown Since Groonga 7.0.1, the query which uses labeled drilldown is changed. This commit supports parsing drilldown(N)[LABEL] case again. Before: drilldown(N)[LABEL] After: output.drilldowns[LABEL](N) Modified files: lib/groonga/query-log/parser.rb test/test-parser.rb Modified: lib/groonga/query-log/parser.rb (+6 -2) =================================================================== --- lib/groonga/query-log/parser.rb 2017-05-31 12:33:18 +0900 (1ccdac9) +++ lib/groonga/query-log/parser.rb 2017-05-31 14:13:14 +0900 (74de193) @@ -68,9 +68,13 @@ module Groonga statistic.start(time_stamp, rest) @parsing_statistics[context_id] = statistic when ":" - return unless /\A(\d+) (.+)\((\d+)\)/ =~ rest + return unless /\A(\d+) (.+)\((\d+)\)(\[.+\])?/ =~ rest elapsed = $1 - name = $2 + unless $4 + name = $2 + else + name = $2 + $4 + end n_records = $3.to_i statistic = @parsing_statistics[context_id] return if statistic.nil? Modified: test/test-parser.rb (+50 -0) =================================================================== --- test/test-parser.rb 2017-05-31 12:33:18 +0900 (4fb4ac7) +++ test/test-parser.rb 2017-05-31 14:13:14 +0900 (c8f1c5e) @@ -206,5 +206,55 @@ class ParserTest < Test::Unit::TestCase assert_equal(expected, operations) end end + + class LabeledDrilldownTest < self + def test_no_output_drilldown + statistics = parse(<<-LOG) +2017-05-31 11:22:19.683806|0x7ffc1ee41940|>select Shops --drilldown[item].keys items --drilldown[item].sortby price --drilldown[item].output_columns _key,_nsubrecs,price,price_with_tax --drilldown[item].columns[price_with_tax].stage initial --drilldown[item].columns[price_with_tax].type UInt32 --drilldown[item].columns[price_with_tax].flags COLUMN_SCALAR --drilldown[item].columns[price_with_tax].value 'price * 1.08' --drilldown[real_price].table item --drilldown[real_price].keys price_with_tax +2017-05-31 11:22:19.683980|0x7ffc1ee41940|:000000000176192 select(3) +2017-05-31 11:22:19.684356|0x7ffc1ee41940|:000000000553162 output(3) +2017-05-31 11:22:19.684468|0x7ffc1ee41940|:000000000665698 drilldown(6)[item] +2017-05-31 11:22:19.684488|0x7ffc1ee41940|:000000000683901 drilldown(3)[real_price] +2017-05-31 11:22:19.684558|0x7ffc1ee41940|<000000000754417 rc=0 + LOG + operations = statistics.first.operations.collect do |operation| + [operation[:name], operation[:n_records]] + end + expected = [ + ["select", 3], + ["output", 3], + ["drilldown[item]", 6], + ["drilldown[real_price]", 3] + ] + assert_equal(expected, operations) + end + + def test_output_drilldown + statistics = parse(<<-LOG) +2017-05-31 11:22:19.758189|0x7ffd1fc97890|>select Shops --drilldown[item].keys items --drilldown[item].sortby price --drilldown[item].output_columns _key,_nsubrecs,price,price_with_tax --drilldown[item].columns[price_with_tax].stage initial --drilldown[item].columns[price_with_tax].type UInt32 --drilldown[item].columns[price_with_tax].flags COLUMN_SCALAR --drilldown[item].columns[price_with_tax].value 'price * 1.08' --drilldown[real_price].table item --drilldown[real_price].keys price_with_tax +2017-05-31 11:22:19.758462|0x7ffd1fc97890|:000000000276579 select(3) +2017-05-31 11:22:19.758727|0x7ffd1fc97890|:000000000542224 columns[price_with_tax](6) +2017-05-31 11:22:19.758738|0x7ffd1fc97890|:000000000550409 drilldowns[item](6) +2017-05-31 11:22:19.758806|0x7ffd1fc97890|:000000000619409 drilldowns[real_price](3) +2017-05-31 11:22:19.758915|0x7ffd1fc97890|:000000000729209 output(3) +2017-05-31 11:22:19.759015|0x7ffd1fc97890|:000000000829476 output.drilldowns[item](6) +2017-05-31 11:22:19.759034|0x7ffd1fc97890|:000000000847090 output.drilldowns[real_price](3) +2017-05-31 11:22:19.759103|0x7ffd1fc97890|<000000000916234 rc=0 + LOG + operations = statistics.first.operations.collect do |operation| + [operation[:name], operation[:n_records]] + end + expected = [ + ["select", 3], + ["columns[price_with_tax]", 6], + ["drilldowns[item]", 6], + ["drilldowns[real_price]", 3], + ["output", 3], + ["output.drilldowns[item]", 6], + ["output.drilldowns[real_price]", 3] + ] + assert_equal(expected, operations) + end + end end end -------------- next part -------------- HTML����������������������������... Download