Created
May 30, 2015 08:36
-
-
Save muziyoshiz/9c6558302c9c184c783b to your computer and use it in GitHub Desktop.
Sample filter: embulk-filter-myapp
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 Filter | |
class MyappFilterPlugin < FilterPlugin | |
Plugin.register_filter("myapp", self) | |
def self.transaction(config, in_schema, &control) | |
yield({}, in_schema) | |
end | |
def init | |
end | |
def close | |
end | |
def add(page) | |
# find index of "comment" column | |
columns = page.schema.select{|c| c.name == "comment" } | |
idx = columns[0].index | |
# filtering code: | |
page.each do |record| | |
case record[idx] | |
when /^login failure:/ | |
record[idx] = "login failure" | |
when /^login by/ | |
record[idx] = "login" | |
end | |
page_builder.add(record) | |
end | |
end | |
def finish | |
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