Class: Impala::ProgressReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/impala/progress_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(cursor, options = {}) ⇒ ProgressReporter

Returns a new instance of ProgressReporter.



3
4
5
6
7
8
# File 'lib/impala/progress_reporter.rb', line 3

def initialize(cursor, options = {})
  @cursor = cursor
  @progress_every = options.fetch(:progress_every, 60).to_f
  @show_progress = options.fetch(:show_progress, false)
  @start_time = @last_progress = Time.now
end

Instance Method Details

#reportObject



14
15
16
17
18
19
20
21
# File 'lib/impala/progress_reporter.rb', line 14

def report
  return unless enough_time_elapsed?
  @last_progress = Time.now
  message = sprintf("Progress %.02f%% after %.02f seconds",
                    cursor.progress * 100,
                    total_time_elapsed)
  progress_stream.puts message
end

#show?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/impala/progress_reporter.rb', line 10

def show?
  @show_progress
end