Class: Embulk::FilterPlugin::JavaAdapter

Inherits:
Object
  • Object
show all
Includes:
Java::FilterPlugin
Defined in:
embulk-core/src/main/ruby/embulk/filter_plugin.rb

Defined Under Namespace

Classes: OutputAdapter

Instance Method Summary collapse

Constructor Details

#initialize(ruby_class) ⇒ JavaAdapter

Returns a new instance of JavaAdapter



44
45
46
# File 'embulk-core/src/main/ruby/embulk/filter_plugin.rb', line 44

def initialize(ruby_class)
  @ruby_class = ruby_class
end

Instance Method Details

#open(java_task_source, java_in_schema, java_out_schema, java_output) ⇒ Object



59
60
61
62
63
64
65
66
# File 'embulk-core/src/main/ruby/embulk/filter_plugin.rb', line 59

def open(java_task_source, java_in_schema, java_out_schema, java_output)
  task_source = DataSource.from_java(java_task_source)
  in_schema = Schema.from_java(java_in_schema)
  out_schema = Schema.from_java(java_out_schema)
  page_builder = PageBuilder.new(out_schema, java_output)
  ruby_object = @ruby_class.new(task_source, in_schema, out_schema, page_builder)
  return OutputAdapter.new(ruby_object, in_schema, page_builder)
end

#transaction(java_config, java_in_schema, java_control) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'embulk-core/src/main/ruby/embulk/filter_plugin.rb', line 48

def transaction(java_config, java_in_schema, java_control)
  config = DataSource.from_java(java_config)
  in_schema = Schema.from_java(java_in_schema)
  @ruby_class.transaction(config, in_schema) do |task_source_hash, out_columns|
    java_task_source = DataSource.from_ruby_hash(task_source_hash).to_java
    java_out_schemas = Schema.new(out_columns).to_java
    java_control.run(java_task_source, java_out_schemas)
  end
  nil
end