Sha256: c03123fad5e6f6d042d67e885e0d8314a68e1d7c419aa6a8e234979ee39fa7db

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

module Embulk

  class InputExample < InputPlugin
    # input plugin file name must be: embulk/output_<name>.rb
    Plugin.register_input('example', self)

    def self.transaction(config, &control)
      task = {
        'message' => config.param('message', :string, default: nil)
      }
      threads = config.param('threads', :integer, default: 2)

      columns = [
        Column.new(0, 'col0', :long),
        Column.new(1, 'col1', :double),
        Column.new(2, 'col2', :string),
      ]

      puts "Example input started."
      commit_reports = yield(task, columns, threads)
      puts "Example input finished. Commit reports = #{commit_reports.to_json}"

      return {}
    end

    def self.run(task, schema, index, page_builder)
      puts "Example input thread #{index}..."

      10.times do |i|
        page_builder.add([i, 10.0, "example"])
      end
      page_builder.finish  # don't forget to call finish :-)

      commit_report = {
      }
      return commit_report
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
embulk-0.1.0 lib/embulk/data/bundle/embulk/input_example.rb