class Innodb::LogGroup

Public Class Methods

new(log_files) click to toggle source

Initialize group given a set of sorted log files.

# File lib/innodb/log_group.rb, line 7
def initialize(log_files)
  @logs = log_files.map { |fn| Innodb::Log.new(fn) }
  raise "Log file sizes do not match" unless @logs.map(&:size).uniq.size == 1
end

Public Instance Methods

capacity() click to toggle source

The log group capacity (in bytes).

# File lib/innodb/log_group.rb, line 49
def capacity
  @logs.first.capacity * @logs.count
end
each_block(&block) click to toggle source

Iterate through all blocks.

# File lib/innodb/log_group.rb, line 20
def each_block(&block)
  return enum_for(:each_block) unless block_given?

  each_log do |log|
    log.each_block(&block)
  end
end
each_log(&block) click to toggle source

Iterate through all logs.

# File lib/innodb/log_group.rb, line 13
def each_log(&block)
  return enum_for(:each_log) unless block_given?

  @logs.each(&block)
end
log(log_no) click to toggle source

Returns the log at the given position in the log group.

# File lib/innodb/log_group.rb, line 34
def log(log_no)
  @logs.at(log_no)
end
log_size() click to toggle source

The size in byes of each and every log in the group.

# File lib/innodb/log_group.rb, line 39
def log_size
  @logs.first.size
end
logs() click to toggle source

The number of log files in the group.

# File lib/innodb/log_group.rb, line 29
def logs
  @logs.count
end
max_checkpoint_lsn() click to toggle source

Returns the LSN coordinates of the most recent (highest) checkpoint.

# File lib/innodb/log_group.rb, line 59
def max_checkpoint_lsn
  @logs.first.checkpoint.max_by(&:number).to_h.values_at(:lsn, :lsn_offset)
end
reader(lsn_coordinates = start_lsn) click to toggle source

Returns a LogReader using the given LSN reference coordinates.

# File lib/innodb/log_group.rb, line 64
def reader(lsn_coordinates = start_lsn)
  Innodb::LogReader.new(Innodb::LSN.new(*lsn_coordinates), self)
end
record(lsn_no) click to toggle source

Parse and return a record at a given LSN.

# File lib/innodb/log_group.rb, line 69
def record(lsn_no)
  reader.seek(lsn_no).record
end
size() click to toggle source

The size of the log group (in bytes)

# File lib/innodb/log_group.rb, line 44
def size
  @logs.first.size * @logs.count
end
start_lsn() click to toggle source

Returns the LSN coordinates of the data at the start of the log group.

# File lib/innodb/log_group.rb, line 54
def start_lsn
  [@logs.first.header[:start_lsn], Innodb::Log::LOG_HEADER_SIZE]
end