Class: Fluent::GroongaOutput::TablesCreator
- Inherits:
-
Object
- Object
- Fluent::GroongaOutput::TablesCreator
- Defined in:
- lib/fluent/plugin/out_groonga.rb
Instance Method Summary (collapse)
- - (Object) create
-
- (TablesCreator) initialize(client, definitions)
constructor
A new instance of TablesCreator.
Constructor Details
- (TablesCreator) initialize(client, definitions)
Returns a new instance of TablesCreator
256 257 258 259 |
# File 'lib/fluent/plugin/out_groonga.rb', line 256 def initialize(client, definitions) @client = client @definitions = definitions end |
Instance Method Details
- (Object) create
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/fluent/plugin/out_groonga.rb', line 261 def create return if @definitions.empty? table_list = @client.execute("table_list") @definitions.each do |definition| existing_table = table_list.find do |table| table.name == definition.name end if existing_table next unless definition.have_difference?(existing_table) # TODO: Is it OK? @client.execute("table_remove", "name" => definition.name) end @client.execute("table_create", definition.to_create_arguments) definition.indexes.each do |index| @client.execute("column_create", index.to_create_arguments) end end end |