Class: Fluent::Plugin::GroongaOutput::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_groonga.rb

Defined Under Namespace

Classes: Column, Table, TypeGuesser

Instance Method Summary collapse

Constructor Details

#initialize(client, table_name, mappings) ⇒ Schema

Returns a new instance of Schema.



293
294
295
296
297
298
299
# File 'lib/fluent/plugin/out_groonga.rb', line 293

def initialize(client, table_name, mappings)
  @client = client
  @table_name = table_name
  @mappings = mappings
  @taget_table = nil
  @columns = nil
end

Instance Method Details

#update(records) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/fluent/plugin/out_groonga.rb', line 301

def update(records)
  ensure_table
  ensure_columns

  nonexistent_columns = {}
  records.each do |record|
    record.each do |key, value|
      next if pseudo_column_name?(key)
      column = @columns[key]
      if column.nil?
        nonexistent_columns[key] ||= []
        nonexistent_columns[key] << value
      end
    end
  end

  nonexistent_columns.each do |name, values|
    @columns[name] = create_column(name, values)
  end
end