Sha256: a5165080b660a57b22c84bfacbf6a151bafde1bc7f9c7f6268ed9c589d4610d5

Contents?: true

Size: 1.39 KB

Versions: 45

Compression:

Stored size: 1.39 KB

Contents

module Embulk
  module Input

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

      def self.transaction(config, &control)
        files = ['file1', 'file2']
        task = {
          'files' => files,
          'hostname' => config.param('hostname', :string, default: nil)
        }

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

        resume(task, columns, files.length, &control)
      end

      def self.resume(task, columns, count, &control)
        puts "Example input started."
        commit_reports = yield(task, columns, count)
        puts "Example input finished. Commit reports = #{commit_reports.to_json}"

        next_config_diff = {}
        return next_config_diff
      end

      def initialize(task, schema, index, page_builder)
        super
        @file = task['files'][index]
        @hostname = task['hostname']
      end

      def run
        puts "Example input thread #{@index}..."

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

        commit_report = {}
        return commit_report
      end
    end

  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
embulk-0.6.27 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.26 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.25 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.24 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.23 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.22 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.21 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.20 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.19 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.18 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.17 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.16 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.15 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.14 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.13 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.12 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.11 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.10 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.9 lib/embulk/data/bundle/embulk/input/example.rb
embulk-0.6.8 lib/embulk/data/bundle/embulk/input/example.rb