Skip to content

Instantly share code, notes, and snippets.

@muziyoshiz
Created May 30, 2015 08:36
Show Gist options
  • Save muziyoshiz/9c6558302c9c184c783b to your computer and use it in GitHub Desktop.
Save muziyoshiz/9c6558302c9c184c783b to your computer and use it in GitHub Desktop.
Sample filter: embulk-filter-myapp
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