class Fluent::Compat::TextParser::ValuesParser
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::Compat::TypeConverter#configure
# File lib/fluent/compat/parser.rb, line 191 def configure(conf) super if @time_key && !@keys.include?(@time_key) && @estimate_current_event raise Fluent::ConfigError, "time_key (#{@time_key.inspect}) is not included in keys (#{@keys.inspect})" end if @time_format && !@time_key raise Fluent::ConfigError, "time_format parameter is ignored because time_key parameter is not set. at #{conf.inspect}" end @time_parser = time_parser_create if @null_value_pattern @null_value_pattern = Regexp.new(@null_value_pattern) end @mutex = Mutex.new end
values_map(values)
click to toggle source
# File lib/fluent/compat/parser.rb, line 211 def values_map(values) record = Hash[keys.zip(values.map { |value| convert_value_to_nil(value) })] if @time_key value = @keep_time_key ? record[@time_key] : record.delete(@time_key) time = if value.nil? if @estimate_current_event Fluent::EventTime.now else nil end else @mutex.synchronize { @time_parser.parse(value) } end elsif @estimate_current_event time = Fluent::EventTime.now else time = nil end convert_field_type!(record) if @type_converters return time, record end
Private Instance Methods
convert_field_type!(record)
click to toggle source
# File lib/fluent/compat/parser.rb, line 238 def convert_field_type!(record) @type_converters.each_key { |key| if value = record[key] record[key] = convert_type(key, value) end } end
convert_value_to_nil(value)
click to toggle source
# File lib/fluent/compat/parser.rb, line 246 def convert_value_to_nil(value) if value and @null_empty_string value = (value == '') ? nil : value end if value and @null_value_pattern value = ::Fluent::StringUtil.match_regexp(@null_value_pattern, value) ? nil : value end value end