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.



288
289
290
291
292
293
294
# File 'lib/fluent/plugin/out_groonga.rb', line 288

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

Instance Method Details

#clear_cacheObject



317
318
319
320
# File 'lib/fluent/plugin/out_groonga.rb', line 317

def clear_cache
  @target_table = nil
  @columns = nil
end

#update(records) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/fluent/plugin/out_groonga.rb', line 296

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