class Fluent::Plugin::MapFilter

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_map.rb, line 29
def configure(conf)
  super
  @format = determine_format()
  configure_format()
  @map = create_map(conf)
  @map_support = Fluent::Plugin::MapSupport.new(@map, self)
end
configure_format() click to toggle source
# File lib/fluent/plugin/filter_map.rb, line 55
def configure_format()
  case @format
  when "map"
    # pass
  when "record"
    raise Fluent::ConfigError, "multi and 2 parameters(time, and record) are not compatible" if @multi
  when "multimap"
    # pass.
  else
    raise Fluent::ConfigError, "format #{@format} is invalid."
  end
end
create_map(conf) click to toggle source
# File lib/fluent/plugin/filter_map.rb, line 68
def create_map(conf)
  # return string like double array.
  case @format
  when "map"
    parse_map()
  when "record"
    "[[#{@time}, #{@record}]]"
  when "multimap"
    parse_multimap(conf)
  end
end
determine_format() click to toggle source
# File lib/fluent/plugin/filter_map.rb, line 43
def determine_format()
  if @format
    @format
  elsif @map
    "map"
  elsif @time && @record
    "record"
  else
    raise Fluent::ConfigError, "Any of map, 2 parameters(time, and record) or format is required "
  end
end
filter_stream(tag, es) click to toggle source
# File lib/fluent/plugin/filter_map.rb, line 80
def filter_stream(tag, es)
  begin
    new_es = Fluent::MultiEventStream.new
    tag_output_es = @map_support.do_map(tag, es)
    tag_output_es.each_pair do |tag, output_es|
      output_es.each{|time, record|
        new_es.add(time, record)
      }
    end
    new_es
  rescue SyntaxError => e
    log.error "map command is syntax error: #{@map}"
    e #for test
  end
end
stop() click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_map.rb, line 37
def stop
  @map_support.stop

  super
end