groonga-query-log 1.7.1 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc465fa277253d4a2f6f4b42ddc9553393572f6d6ad03496b17d308036f90f51
4
- data.tar.gz: 1d458256bf29ef9d84100e66a535563d85a240f823e5dfd524bb45122bc1fa55
3
+ metadata.gz: 5c1dd6a2bc5f431a4003c5468aa573a55563107a7eb875ef6af59b2150bb0ab9
4
+ data.tar.gz: 503abaf07344e2453e74bf34fd053560ce2bb3acce212527ea0559520167e81b
5
5
  SHA512:
6
- metadata.gz: 1954617ef0c708f19af1a204bfd26a71cf7799204237f7be72a00c42c0aafacfc177f9785ed2f456108cad47dd3d2756cd9608eddb80780fa67a6e142e85e673
7
- data.tar.gz: 31df2208d65ffde3cb0b25dbcac5290f080f85310d747e3e1cd89e4a11f78a50dab071ebee27048e4c6d6bf3c59da7281180657c8ecd0e2adf2495f3ac348fba
6
+ metadata.gz: ff08e69d1c1197d42fc763a685e2780e24c4e6432c3b04035b5076b1cd0fe126411fc36a8965da55abbde8cf94ac59a5032bc0028f52ceea6143abb5084c9f30
7
+ data.tar.gz: f4d689ada13d114ffce2f7d4d6d50ca6d38dbce1974a6df7fba5e9d677234d451de0da939aef0720f5876715d6d3848741cb8abbfeb12c005f6b0fa0983eb3b7
data/doc/text/news.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # News
2
2
 
3
+ ## 1.7.6: 2021-02-24
4
+
5
+ ### Improvements
6
+
7
+ * `replayer`: Ignored `load` without `values`.
8
+
9
+ * `statistics`: Added `n_records` to each operation.
10
+
11
+ ## 1.7.5: 2020-11-18
12
+
13
+ ### Improvements
14
+
15
+ * `analyze`: Ignored static file access.
16
+
17
+ ## 1.7.4: 2020-11-12
18
+
19
+ ### Fixes
20
+
21
+ * `server-verifier`: Fixed a bug that `--max-limit` doesn't work.
22
+
23
+ * `run-regression-test`: Fixed a bug that `--max-limit` doesn't work.
24
+
25
+ ## 1.7.3: 2020-11-12
26
+
27
+ ### Improvements
28
+
29
+ * `check-crash`: Added support for showing Groonga version.
30
+
31
+ * `server-verifier`: Added `--max-limit` option.
32
+
33
+ * `run-regression-test`: Added `--max-limit` option.
34
+
35
+ ### Fixes
36
+
37
+ * `GroongaQueryLog::Parser`: Fixed a bug that target command filter
38
+ may not work.
39
+
40
+ ## 1.7.2: 2020-06-02
41
+
42
+ ### Fixes
43
+
44
+ * `server-verifier`: Fixed a bug that performance verification
45
+ doesn't try 5 times.
46
+
3
47
  ## 1.7.1: 2020-06-01
4
48
 
5
49
  ### Fixes
@@ -71,6 +71,7 @@ module GroongaQueryLog
71
71
  end
72
72
 
73
73
  class GroongaProcess
74
+ attr_reader :version
74
75
  attr_reader :pid
75
76
  attr_reader :start_time
76
77
  attr_reader :start_log_path
@@ -80,7 +81,8 @@ module GroongaQueryLog
80
81
  attr_writer :crashed
81
82
  attr_writer :finished
82
83
  attr_reader :important_entries
83
- def initialize(pid, start_time, start_log_path)
84
+ def initialize(version, pid, start_time, start_log_path)
85
+ @version = version
84
86
  @pid = pid
85
87
  @start_time = start_time
86
88
  @end_time = @start_time
@@ -121,6 +123,7 @@ module GroongaQueryLog
121
123
  need_query_log_parsing = false
122
124
  p [:process,
123
125
  :success,
126
+ process.version,
124
127
  process.start_time.iso8601,
125
128
  process.end_time.iso8601,
126
129
  process.pid,
@@ -129,6 +132,7 @@ module GroongaQueryLog
129
132
  elsif process.crashed?
130
133
  p [:process,
131
134
  :crashed,
135
+ process.version,
132
136
  process.start_time.iso8601,
133
137
  process.end_time.iso8601,
134
138
  process.pid,
@@ -137,6 +141,7 @@ module GroongaQueryLog
137
141
  else
138
142
  p [:process,
139
143
  :unfinished,
144
+ process.version,
140
145
  process.start_time.iso8601,
141
146
  process.pid,
142
147
  process.start_log_path]
@@ -144,6 +149,7 @@ module GroongaQueryLog
144
149
 
145
150
  unless process.n_leaks.zero?
146
151
  p [:leak,
152
+ process.version,
147
153
  process.n_leaks,
148
154
  process.end_time.iso8601,
149
155
  process.pid,
@@ -184,7 +190,8 @@ module GroongaQueryLog
184
190
  end
185
191
  end
186
192
  unless @unflushed_statistics.empty?
187
- puts("Unflushed commands in #{start.iso8601}/#{last.iso8601}")
193
+ puts("Unflushed commands in " +
194
+ "#{start_time.iso8601}/#{end_time.iso8601}")
188
195
  @unflushed_statistics.each do |statistic|
189
196
  puts("#{statistic.start_time.iso8601}: #{statistic.raw_command}")
190
197
  end
@@ -320,7 +327,8 @@ module GroongaQueryLog
320
327
  end
321
328
 
322
329
  case entry.message
323
- when /\Agrn_init:/, /\Amroonga \d+\.\d+ started\.\z/
330
+ when /\Agrn_init: <(.+?)>/, /\Amroonga (\d+\.\d+) started\.\z/
331
+ version = $1
324
332
  process = @running_processes[entry.pid]
325
333
  if process
326
334
  process.finished = true
@@ -328,12 +336,15 @@ module GroongaQueryLog
328
336
  yield(process)
329
337
  @running_processes.delete(entry.pid)
330
338
  end
331
- process = GroongaProcess.new(entry.pid, entry.timestamp, path)
339
+ process = GroongaProcess.new(version,
340
+ entry.pid,
341
+ entry.timestamp,
342
+ path)
332
343
  @running_processes[entry.pid] = process
333
344
  when /\Agrn_fin \((\d+)\)\z/
334
345
  n_leaks = $1.to_i
335
346
  @running_processes[entry.pid] ||=
336
- GroongaProcess.new(entry.pid, Time.at(0), path)
347
+ GroongaProcess.new(nil, entry.pid, Time.at(0), path)
337
348
  process = @running_processes[entry.pid]
338
349
  process.n_leaks = n_leaks
339
350
  process.end_time = entry.timestamp
@@ -343,7 +354,7 @@ module GroongaQueryLog
343
354
  @running_processes.delete(entry.pid)
344
355
  else
345
356
  @running_processes[entry.pid] ||=
346
- GroongaProcess.new(entry.pid, Time.at(0), path)
357
+ GroongaProcess.new(nil, entry.pid, Time.at(0), path)
347
358
  process = @running_processes[entry.pid]
348
359
  case entry.log_level
349
360
  when :notice
@@ -66,6 +66,7 @@ module GroongaQueryLog
66
66
  @rewrite_and_not_operator = false
67
67
  @debug_rewrite = false
68
68
  @omit_rate = 0.0
69
+ @max_limit = -1
69
70
 
70
71
  @care_order = true
71
72
  @ignored_drilldown_keys = []
@@ -313,6 +314,12 @@ module GroongaQueryLog
313
314
  "(#{@omit_rate})") do |rate|
314
315
  @omit_rate = rate
315
316
  end
317
+ parser.on("--max-limit=LIMIT", Integer,
318
+ "Use LIMIT as the max limit value",
319
+ "Negative value doesn't rewrite the limit parameter",
320
+ "(#{@max_limit})") do |limit|
321
+ @max_limit = limit
322
+ end
316
323
 
317
324
  parser.separator("")
318
325
  parser.separator("Comparisons:")
@@ -466,6 +473,7 @@ module GroongaQueryLog
466
473
  @rewrite_and_not_operator,
467
474
  :debug_rewrite => @debug_rewrite,
468
475
  :omit_rate => @omit_rate,
476
+ :max_limit => @max_limit,
469
477
  :target_command_names => @target_command_names,
470
478
  :verify_performance => @verify_performance,
471
479
  :performance_verfifier_options => @performance_verfifier_options,
@@ -919,6 +927,10 @@ module GroongaQueryLog
919
927
  command_line << "--omit-rate"
920
928
  command_line << @options[:omit_rate].to_s
921
929
  end
930
+ if @options[:max_limit] >= 0
931
+ command_line << "--max-limit"
932
+ command_line << @options[:max_limit].to_s
933
+ end
922
934
  if @options[:target_command_names]
923
935
  command_line << "--target-command-names"
924
936
  command_line << @options[:target_command_names].join(",")
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2018 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2020 Horimoto Yasuhiro <horimoto@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
@@ -280,6 +280,13 @@ module GroongaQueryLog
280
280
  @options.nullable_reference_number_accessors << accessor
281
281
  end
282
282
 
283
+ parser.on("--max-limit=LIMIT", Integer,
284
+ "Use LIMIT as the max limit value",
285
+ "Negative value doesn't rewrite the limit parameter",
286
+ "(#{@options.max_limit})") do |limit|
287
+ @options.max_limit = limit
288
+ end
289
+
283
290
  create_parser_performance(parser)
284
291
 
285
292
  parser.separator("")
@@ -160,7 +160,7 @@ module GroongaQueryLog
160
160
 
161
161
  def target_statistic?(statistic)
162
162
  if @target_commands
163
- unless @target_commands.include?(statistic.command.name)
163
+ unless @target_commands.include?(statistic.command.command_name)
164
164
  return false
165
165
  end
166
166
  end
@@ -47,6 +47,7 @@ module GroongaQueryLog
47
47
  parser.parse(input) do |statistic|
48
48
  next if statistic.command.nil?
49
49
  next unless target_command?(statistic.command)
50
+ next unless available_command?(statistic.command)
50
51
  # TODO: validate orignal_source is one line
51
52
  output.puts(statistic.command.original_source)
52
53
  output.flush
@@ -83,19 +84,15 @@ module GroongaQueryLog
83
84
  end
84
85
  begin
85
86
  replay_command(client, id, statistic.command)
86
- rescue Groonga::Client::Error
87
+ rescue => error
87
88
  # TODO: add error log mechanism
88
89
  $stderr.puts(Time.now.iso8601(6))
89
90
  $stderr.puts(statistic.command.original_source)
90
- $stderr.puts($!.raw_error.message)
91
- $stderr.puts($!.raw_error.backtrace)
92
- return false
93
- rescue
94
- # TODO: add error log mechanism
95
- $stderr.puts(Time.now.iso8601(6))
96
- $stderr.puts(statistic.command.original_source)
97
- $stderr.puts($!.message)
98
- $stderr.puts($!.backtrace)
91
+ if error.respond_to?(:raw_error)
92
+ error = raw_error
93
+ end
94
+ $stderr.puts(error.message)
95
+ $stderr.puts(error.backtrace)
99
96
  return false
100
97
  end
101
98
  end
@@ -136,6 +133,15 @@ module GroongaQueryLog
136
133
  @options.target_command_name?(command.command_name)
137
134
  end
138
135
 
136
+ def available_command?(command)
137
+ case command.command_name
138
+ when "load"
139
+ not command.values.nil?
140
+ else
141
+ true
142
+ end
143
+ end
144
+
139
145
  class NullOutput
140
146
  class << self
141
147
  def open
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2018 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2013-2020 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2020 Horimoto Yasuhiro <horimoto@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
@@ -170,6 +170,14 @@ module GroongaQueryLog
170
170
  def verify_command(groonga1_client, groonga2_client, command)
171
171
  command["cache"] = "no" if @options.disable_cache?
172
172
  command["cache"] = "no" if @options.verify_performance?
173
+ if @options.max_limit >= 0 and command["limit"]
174
+ limit = command["limit"].to_i
175
+ if limit >= 0
176
+ command["limit"] = [limit, @options.max_limit].min.to_s
177
+ else
178
+ command["limit"] = @options.max_limit.to_s
179
+ end
180
+ end
173
181
  command["output_type"] = "json"
174
182
  rewrite_filter(command, "filter")
175
183
  rewrite_filter(command, "scorer")
@@ -219,17 +227,16 @@ module GroongaQueryLog
219
227
  responses1,
220
228
  responses2,
221
229
  @options.performance_verifier_options)
222
- if verifier.slow?
223
- @slow = true
224
- @events.push([:slow,
225
- command,
226
- verifier.old_elapsed_time,
227
- verifier.new_elapsed_time,
228
- verifier.old_elapsed_times,
229
- verifier.new_elapsed_times])
230
- return
231
- end
230
+ return unless verifier.slow?
232
231
  end
232
+
233
+ @slow = true
234
+ @events.push([:slow,
235
+ command,
236
+ verifier.old_elapsed_time,
237
+ verifier.new_elapsed_time,
238
+ verifier.old_elapsed_times,
239
+ verifier.new_elapsed_times])
233
240
  end
234
241
 
235
242
  def rewrite_filter(command, name)
@@ -318,6 +325,7 @@ module GroongaQueryLog
318
325
  attr_reader :performance_verifier_options
319
326
  attr_writer :debug_rewrite
320
327
  attr_writer :omit_rate
328
+ attr_accessor :max_limit
321
329
  def initialize
322
330
  @groonga1 = GroongaOptions.new
323
331
  @groonga2 = GroongaOptions.new
@@ -352,6 +360,7 @@ module GroongaQueryLog
352
360
  @performance_verifier_options = PerformanceVerifier::Options.new
353
361
  @debug_rewrite = false
354
362
  @omit_rate = 0.0
363
+ @max_limit = -1
355
364
  end
356
365
 
357
366
  def request_queue_size
@@ -115,6 +115,7 @@ module GroongaQueryLog
115
115
  end
116
116
 
117
117
  def select_family_command?
118
+ return false if command.nil?
118
119
  case command.command_name
119
120
  when "select", "range_filter"
120
121
  true
@@ -151,6 +152,7 @@ module GroongaQueryLog
151
152
  operation_data["relative_elapsed"] = operation[:relative_elapsed_in_seconds]
152
153
  operation_data["context"] = operation[:context]
153
154
  operation_data["slow"] = operation[:slow?]
155
+ operation_data["n_records"] = operation[:n_records]
154
156
  operations << operation_data
155
157
  end
156
158
  data["operations"] = operations
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module GroongaQueryLog
18
- VERSION = "1.7.1"
18
+ VERSION = "1.7.6"
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
2
- # Copyright (C) 2014-2019 Sutou Kouhei <kou@clear-code.com>
2
+ # Copyright (C) 2014-2021 Sutou Kouhei <kou@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,7 @@ class AnalyzerCommandTest < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_no_specified
45
+ require_tty
45
46
  assert_equal("Error: Please specify input log files.\n",
46
47
  run_analyzer)
47
48
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
2
- # Copyright (C) 2015-2018 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2015-2021 Sutou Kouhei <kou@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU Lesser General Public
@@ -45,6 +45,7 @@ column_create --flags "COLUMN_SCALAR" --name "title" --table "Comments" --type "
45
45
  end
46
46
 
47
47
  def test_no_specified
48
+ require_tty
48
49
  assert_equal("Error: Please specify input log files.\n",
49
50
  run_extractor)
50
51
  end
@@ -1,2 +1,2 @@
1
1
  {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.003128856,"return_code":0,"slow":false,"command":{"raw":"load --table Video","name":"load","parameters":[{"key":"table","value":"Video"}]},"operations":[]}
2
- {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false}]}
2
+ {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false,"n_records":2},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false,"n_records":2},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false,"n_records":2}]}
@@ -1,4 +1,4 @@
1
1
  [
2
2
  {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.003128856,"return_code":0,"slow":false,"command":{"raw":"load --table Video","name":"load","parameters":[{"key":"table","value":"Video"}]},"operations":[]},
3
- {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false}]}
3
+ {"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false,"n_records":2},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false,"n_records":2},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false,"n_records":2}]}
4
4
  ]
data/test/helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2011-2021 Sutou Kouhei <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,10 @@ module Helper
29
29
  end
30
30
 
31
31
  module Command
32
+ def require_tty
33
+ omit("Require tty") unless $stdin.tty?
34
+ end
35
+
32
36
  def open_error_output
33
37
  Tempfile.open("groonga-query-log.error") do |error|
34
38
  error.sync = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-query-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-31 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charty
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
317
  requirements: []
318
- rubygems_version: 3.2.0.pre1
318
+ rubygems_version: 3.3.0.dev
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: Groonga-query-log is a collection of library and tools to process [Groonga](http://groonga.org/)'s