Class: GroongaDelta::LocalReader::TableTarget

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/groonga-delta/local-reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, timestamp, name, action) ⇒ TableTarget

Returns a new instance of TableTarget.



292
293
294
295
296
297
# File 'lib/groonga-delta/local-reader.rb', line 292

def initialize(path, timestamp, name, action)
  @path = path
  @timestamp = timestamp
  @name = name
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



291
292
293
# File 'lib/groonga-delta/local-reader.rb', line 291

def action
  @action
end

#nameObject (readonly)

Returns the value of attribute name.



290
291
292
# File 'lib/groonga-delta/local-reader.rb', line 290

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



288
289
290
# File 'lib/groonga-delta/local-reader.rb', line 288

def path
  @path
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



289
290
291
# File 'lib/groonga-delta/local-reader.rb', line 289

def timestamp
  @timestamp
end

Instance Method Details

#apply(logger, client, processor) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/groonga-delta/local-reader.rb', line 299

def apply(logger, client, processor)
  apply_log(logger, @path) do
    if @path.end_with?(".grn")
      processor.load(@path)
    else
      # TODO: Add support for @action == "delete"
      table = Arrow::Table.load(@path)
      command = Groonga::Command::Load.new(table: @name,
                                           values: table,
                                           command_version: "3")
      response = client.load(command.arguments)
      processor.process_response(response, command)
    end
  end
end

#vacuum(logger) ⇒ Object



315
316
317
318
319
# File 'lib/groonga-delta/local-reader.rb', line 315

def vacuum(logger)
  vacuum_log(logger, @path) do
    FileUtils.rm(@path)
  end
end