Created
March 15, 2015 04:54
-
-
Save frsyuki/9c4128cd888cf12551b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Embulk | |
module Parser | |
class XxxParserPlugin < ParserPlugin | |
Plugin.register_parser("xxx", self) | |
def self.transaction(config, &control) | |
parser_task = config.load_config(Java::LineDecoder::DecoderTask) | |
# configuration code: | |
task = { | |
"decoder_task" => DataSource.from_java(parser_task.dump) | |
} | |
columns = [ | |
# ... | |
] | |
yield(task, columns) | |
end | |
def init | |
@decoder_task = task.prop("decoder_task", :hash).load_task(Java::LineDecoder::DecoderTask) | |
end | |
def run(file_input) | |
decoder = Java::LineDecoder.new(file_input, @decoder_task) | |
while decoder.nextFile | |
while line = decoder.poll | |
# TODO record = parse(line) | |
record = ["col1", 2, 3.0] | |
page_builder.add(record) | |
end | |
end | |
page_builder.finish | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こちらのコードを私の環境(Embulk 0.5.2)で試してみたところ、22行目で以下のエラーが出て動きませんでした。
ここは、Embulk::DataSourceの定義を確認して、propをparamに直しました。
また、28行目でcannot convert instance of class org.jruby.RubyObject to booleanというエラーが出ましたが、これは @hiroysato のapache_log_ruby.rbを参考に
と書き換えたところ動作しました。ありがとうございます!