Sha256: 9be27d264566ab0af647d791b467c6a8555d29d329387f91e8262cd0a91ae91e
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'lhm/id_set_chunk_insert' module Lhm class IdSetChunkFinder LOG_PREFIX = "Chunker" def initialize(migration, connection = nil, options = {}) @migration = migration @connection = connection @ids = options[:ids] @throttler = options[:throttler] @processed_rows = 0 end def table_empty? ids.nil? || ids.empty? end def validate end def each_chunk @processed_rows = 0 while @processed_rows < ids.length next_idx = [@processed_rows + @throttler.stride, @ids.length].min ids_to_insert = ids[@processed_rows...next_idx] @processed_rows = next_idx yield IdSetChunkInsert.new(@migration, @connection, ids_to_insert) end end def max_rows ids.length end def processed_rows @processed_rows end private def ids @ids ||= select_ids_from_db end def select_ids_from_db @connection.select_values("select id from `#{ @migration.origin_name }` order by id asc", should_retry: true, log_prefix: LOG_PREFIX) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lhm-teak-3.6.2 | lib/lhm/id_set_chunk_finder.rb |
lhm-teak-3.6.1 | lib/lhm/id_set_chunk_finder.rb |