Class: Embulk::Output::Vertica::OutputThreadPool
- Inherits:
-
Object
- Object
- Embulk::Output::Vertica::OutputThreadPool
- Defined in:
- lib/embulk/output/vertica/output_thread.rb
Instance Method Summary collapse
- #commit ⇒ Object
- #enqueue(page) ⇒ Object
-
#initialize(task, schema, size) ⇒ OutputThreadPool
constructor
A new instance of OutputThreadPool.
- #start ⇒ Object
Constructor Details
#initialize(task, schema, size) ⇒ OutputThreadPool
Returns a new instance of OutputThreadPool.
7 8 9 10 11 12 |
# File 'lib/embulk/output/vertica/output_thread.rb', line 7 def initialize(task, schema, size) @size = size converters = ValueConverterFactory.create_converters(schema, task['default_timezone'], task['column_options']) @output_threads = size.times.map { OutputThread.new(task, schema, converters) } @current_index = 0 end |
Instance Method Details
#commit ⇒ Object
26 27 28 |
# File 'lib/embulk/output/vertica/output_thread.rb', line 26 def commit task_reports = @size.times.map {|i| @output_threads[i].commit } end |
#enqueue(page) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/embulk/output/vertica/output_thread.rb', line 14 def enqueue(page) @mutex.synchronize do @output_threads[@current_index].enqueue(page) @current_index = (@current_index + 1) % @size end end |
#start ⇒ Object
21 22 23 24 |
# File 'lib/embulk/output/vertica/output_thread.rb', line 21 def start @mutex = Mutex.new @size.times.map {|i| @output_threads[i].start } end |