lib/embulk/input_plugin.rb in embulk-0.4.10 vs lib/embulk/input_plugin.rb in embulk-0.5.0
- old
+ new
@@ -15,10 +15,14 @@
def self.cleanup(task, schema, count, commit_reports)
# do nothing by default
end
+ def self.guess(config)
+ raise NotImplementedError, "#{self}.guess(config) is not implemented. This input plugin does not support guess."
+ end
+
def initialize(task, schema, index, page_builder)
@task = task
@schema = schema
@index = index
@page_builder = page_builder
@@ -79,9 +83,15 @@
task_source = DataSource.from_java(java_task_source)
schema = Schema.from_java(java_schema)
commit_reports = java_commit_reports.map {|c| DataSource.from_java(c) }
@ruby_class.cleanup(task_source, schema, task_count, commit_reports)
return nil
+ end
+
+ def guess(java_config)
+ config = DataSource.from_java(java_config)
+ config_diff_hash = @ruby_class.guess(config)
+ return DataSource.from_ruby_hash(config_diff_hash).to_java
end
def run(java_task_source, java_schema, processor_index, java_output)
task_source = DataSource.from_java(java_task_source)
schema = Schema.from_java(java_schema)