Class: Lhm::ChunkInsert

Inherits:
Object
  • Object
show all
Defined in:
lib/lhm/chunk_insert.rb

Constant Summary collapse

LOG_PREFIX =
"ChunkInsert"

Instance Method Summary collapse

Constructor Details

#initialize(migration, connection, lowest, highest, options = {}) ⇒ ChunkInsert

Returns a new instance of ChunkInsert.



9
10
11
12
13
14
15
# File 'lib/lhm/chunk_insert.rb', line 9

def initialize(migration, connection, lowest, highest, options = {})
  @migration = migration
  @connection = connection
  @lowest = lowest
  @highest = highest
  @options = options
end

Instance Method Details

#bottomObject



21
22
23
# File 'lib/lhm/chunk_insert.rb', line 21

def bottom
  @lowest
end

#expected_rowsObject



29
30
31
# File 'lib/lhm/chunk_insert.rb', line 29

def expected_rows
  @options.fetch(:expected_rows, top - bottom + 1)
end

#insert_and_return_count_of_rows_createdObject



17
18
19
# File 'lib/lhm/chunk_insert.rb', line 17

def insert_and_return_count_of_rows_created
  @connection.update(sql, should_retry: true, log_prefix: LOG_PREFIX)
end

#topObject



25
26
27
# File 'lib/lhm/chunk_insert.rb', line 25

def top
  @highest
end