def run(&blck)
left_cursor = right_cursor = nil
left_cursor = session.left.select_cursor(
:table => left_table,
:row_buffer_size => scan_options[:row_buffer_size],
:type_cast => true
)
right_cursor = session.right.select_cursor(
:table => right_table,
:row_buffer_size => scan_options[:row_buffer_size],
:type_cast => true
)
left_row = right_row = nil
update_progress 0
while left_row or right_row or left_cursor.next? or right_cursor.next?
left_row ||= left_cursor.next_row if left_cursor.next?
right_row ||= right_cursor.next_row if right_cursor.next?
rank = rank_rows left_row, right_row
case rank
when -1
yield :left, left_row
left_row = nil
update_progress 1
when 1
yield :right, right_row
right_row = nil
update_progress 1
when 0
update_progress 2
if not left_row == right_row
yield :conflict, [left_row, right_row]
end
left_row = right_row = nil
end
end
ensure
[left_cursor, right_cursor].each {|cursor| cursor.clear if cursor}
end