Class: Flydata::Mysql::MysqlDumpParser::InsertParser

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/command/sync.rb

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');

Defined Under Namespace

Modules: State

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ InsertParser

Returns a new instance of InsertParser.



1186
1187
1188
1189
1190
# File 'lib/flydata/command/sync.rb', line 1186

def initialize(file)
  @file = file
  @values = []
  @values_set = []
end

Instance Method Details

#parseObject



1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
# File 'lib/flydata/command/sync.rb', line 1206

def parse
  start_ruby_prof
  bench_start_time = Time.now
  target_line = @file.readline
  _parse(target_line)
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

#start_ruby_profObject



1192
1193
1194
# File 'lib/flydata/command/sync.rb', line 1192

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

#stop_ruby_profObject



1196
1197
1198
1199
1200
1201
1202
1203
1204
# File 'lib/flydata/command/sync.rb', line 1196

def stop_ruby_prof
  if 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