Class: Fluent::Compat::TextParser::ValuesParser

Inherits:
Parser show all
Includes:
Fluent::Compat::TypeConverter
Defined in:
lib/fluent/compat/parser.rb

Constant Summary

Constants included from Fluent::Compat::TypeConverter

Fluent::Compat::TypeConverter::Converters

Constants inherited from Plugin::Parser

Plugin::Parser::AVAILABLE_PARSER_VALUE_TYPES, Plugin::Parser::PARSER_TYPES, Plugin::Parser::TRUTHY_VALUES

Constants included from Fluent::Configurable

Fluent::Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Plugin::Parser

#type_converters

Attributes inherited from Plugin::Base

#under_plugin_development

Instance Method Summary collapse

Methods included from Fluent::Compat::TypeConverter

included

Methods inherited from Plugin::Parser

#build_type_converters, #call, #convert_values, #implement?, #initialize, #parse, #parse_io, #parse_partial_data, #parse_time, #parse_with_timeout, #parser_type, #start, #stop, #string_like_null

Methods included from TimeMixin::Parser

included, #time_parser_create

Methods included from Plugin::OwnedByMixin

#log, #owner, #owner=

Methods inherited from Plugin::Base

#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #initialize, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Fluent::Configurable

#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Plugin::Parser

Instance Method Details

#configure(conf) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# 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) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# 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