Class: Embulk::OutputExample
- Inherits:
-
OutputPlugin
- Object
- OutputPlugin
- Embulk::OutputExample
- Defined in:
- lib/embulk/data/bundle/embulk/output_example.rb
Instance Attribute Summary
Attributes inherited from OutputPlugin
Class Method Summary collapse
Instance Method Summary collapse
- #abort ⇒ Object
- #add(page) ⇒ Object
- #close ⇒ Object
- #commit ⇒ Object
- #finish ⇒ Object
-
#initialize(task, schema, index) ⇒ OutputExample
constructor
A new instance of OutputExample.
Methods inherited from OutputPlugin
Constructor Details
#initialize(task, schema, index) ⇒ OutputExample
Returns a new instance of OutputExample.
19 20 21 22 23 24 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 19 def initialize(task, schema, index) puts "Example output thread #{index}..." super = task.param('message', :string) @records = 0 end |
Class Method Details
.transaction(config, schema, processor_count, &control) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 7 def self.transaction(config, schema, processor_count, &control) task = { 'message' => config.param('message', :string, default: "record") } puts "Example output started." commit_reports = yield(task) puts "Example output finished. Commit reports = #{commit_reports.to_json}" return {} end |
Instance Method Details
#abort ⇒ Object
40 41 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 40 def abort end |
#add(page) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 29 def add(page) page.each do |record| hash = Hash[schema.names.zip(record)] puts "#{@message}: #{hash.to_json}" @records += 1 end end |
#close ⇒ Object
26 27 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 26 def close end |
#commit ⇒ Object
43 44 45 46 47 48 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 43 def commit commit_report = { "records" => @records } return commit_report end |
#finish ⇒ Object
37 38 |
# File 'lib/embulk/data/bundle/embulk/output_example.rb', line 37 def finish end |