Class: Embulk::OutputPlugin::JavaAdapter

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

Defined Under Namespace

Classes: OutputAdapter

Instance Method Summary collapse

Constructor Details

#initialize(ruby_class) ⇒ JavaAdapter

Returns a new instance of JavaAdapter



57
58
59
# File 'embulk-core/src/main/ruby/embulk/output_plugin.rb', line 57

def initialize(ruby_class)
  @ruby_class = ruby_class
end

Instance Method Details

#cleanup(java_task_source, java_schema, task_count, java_task_reports) ⇒ Object



89
90
91
92
93
94
95
# File 'embulk-core/src/main/ruby/embulk/output_plugin.rb', line 89

def cleanup(java_task_source, java_schema, task_count, java_task_reports)
  task_source = DataSource.from_java(java_task_source)
  schema = Schema.from_java(java_schema)
  task_reports = java_task_reports.map {|c| DataSource.from_java(c) }
  @ruby_class.cleanup(task_source, schema, task_count, task_reports)
  return nil
end

#open(java_task_source, java_schema, processor_index) ⇒ Object



97
98
99
100
101
102
# File 'embulk-core/src/main/ruby/embulk/output_plugin.rb', line 97

def open(java_task_source, java_schema, processor_index)
  task_source = DataSource.from_java(java_task_source)
  schema = Schema.from_java(java_schema)
  ruby_object = @ruby_class.new(task_source, schema, processor_index)
  return OutputAdapter.new(ruby_object, schema)
end

#resume(java_task_source, java_schema, task_count, java_control) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'embulk-core/src/main/ruby/embulk/output_plugin.rb', line 75

def resume(java_task_source, java_schema, task_count, java_control)
  task_source = DataSource.from_java(java_task_source)
  schema = Schema.from_java(java_schema)
  config_diff_hash = @ruby_class.resume(task_source, schema, task_count) do |task_source_hash,columns,task_count|
    java_task_source = DataSource.from_ruby_hash(task_source_hash).to_java
    java_task_reports = java_control.run(java_task_source)
    java_task_reports.map {|java_task_report|
      DataSource.from_java(java_task_report)
    }
  end
  # TODO check return type of #resume
  return DataSource.from_ruby_hash(config_diff_hash).to_java
end

#transaction(java_config, java_schema, task_count, java_control) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'embulk-core/src/main/ruby/embulk/output_plugin.rb', line 61

def transaction(java_config, java_schema, task_count, java_control)
  config = DataSource.from_java(java_config)
  schema = Schema.from_java(java_schema)
  config_diff_hash = @ruby_class.transaction(config, schema, task_count) do |task_source_hash|
    java_task_source = DataSource.from_ruby_hash(task_source_hash).to_java
    java_task_reports = java_control.run(java_task_source)
    java_task_reports.map {|java_task_report|
      DataSource.from_java(java_task_report)
    }
  end
  # TODO check return type of #transaction
  return DataSource.from_ruby_hash(config_diff_hash).to_java
end