Class: Flydata::SourceMysql::Parser::MysqlDumpParser::InsertParser

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/source_mysql/parser/dump_parser.rb,
ext/flydata/source_mysql/parser/dump_parser_ext.cpp

Overview

Parse the insert line containing multiple values. (max line size is 1kb)

ex) INSERT INTO `data_entries` VALUES (2,2,'access_log'), (2,3,'access_log2');

Constant Summary collapse

RUN_PROFILE =

INSERT INTO ‘data_entries` VALUES (2,2,’access_log’), (2,3,‘access_log2’);

false

Instance Method Summary collapse

Instance Method Details

#parse(line) ⇒ Object



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/flydata/source_mysql/parser/dump_parser.rb', line 463

def parse(line)
  start_ruby_prof
  bench_start_time = Time.now
  begin
    _parse(line)
  rescue DumpParseError => e
    $log.error "Encountered an error while parsing this chunk:\n  #{e.message}. backtrace: #{e.backtrace}"
    raise
  ensure
    stop_ruby_prof
    if ENV['FLYDATA_BENCHMARK']
      puts " -> time:#{Time.now.to_f - bench_start_time.to_f} size:#{target_line.size}"
    end
  end
end

#start_ruby_profObject



449
450
451
# File 'lib/flydata/source_mysql/parser/dump_parser.rb', line 449

def start_ruby_prof
  RubyProf.start if RUN_PROFILE and defined?(RubyProf) and not RubyProf.running?
end

#stop_ruby_profObject



453
454
455
456
457
458
459
460
461
# File 'lib/flydata/source_mysql/parser/dump_parser.rb', line 453

def stop_ruby_prof
  if RUN_PROFILE and defined?(RubyProf) and RubyProf.running?
    result = RubyProf.stop
    #printer = RubyProf::GraphPrinter.new(result)
    printer = RubyProf::GraphHtmlPrinter.new(result)
    #printer.print(STDOUT)
    printer.print(File.new("ruby-prof-out-#{Time.now.to_i}.html", "w"), :min_percent => 3)
  end
end