Class: Groonga::QueryLog::Parser
- Inherits:
-
Object
- Object
- Groonga::QueryLog::Parser
- Defined in:
- lib/groonga/query-log/parser.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(input) {|statistics| ... } ⇒ Object
Parses query-log file as stream to Analyzer::Statistics including some informations for each query.
- #parsing_statistics ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
26 27 28 29 30 31 |
# File 'lib/groonga/query-log/parser.rb', line 26 def initialize(={}) @options = @slow_operation_threshold = [:slow_operation_threshold] @slow_response_threshold = [:slow_response_threshold] @parsing_statistics = {} end |
Instance Method Details
#parse(input) {|statistics| ... } ⇒ Object
Parses query-log file as stream to Analyzer::Statistics including some informations for each query.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/groonga/query-log/parser.rb', line 42 def parse(input, &block) input.each_line do |line| next unless line.valid_encoding? case line when /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)\.(\d+)\|(.+?)\|([>:<])/ year, month, day, hour, minutes, seconds, micro_seconds = $1, $2, $3, $4, $5, $6, $7 context_id = $8 type = $9 rest = $POSTMATCH.strip time_stamp = Time.local(year, month, day, hour, minutes, seconds, micro_seconds) parse_line(time_stamp, context_id, type, rest, &block) end end end |
#parsing_statistics ⇒ Object
59 60 61 |
# File 'lib/groonga/query-log/parser.rb', line 59 def parsing_statistics @parsing_statistics.values end |