Class: Innodb::LogGroup
- Inherits:
-
Object
- Object
- Innodb::LogGroup
- Defined in:
- lib/innodb/log_group.rb
Instance Method Summary collapse
-
#capacity ⇒ Object
The log group capacity (in bytes).
-
#each_block(&block) ⇒ Object
Iterate through all blocks.
-
#each_log(&block) ⇒ Object
Iterate through all logs.
-
#initialize(log_files) ⇒ LogGroup
constructor
Initialize group given a set of sorted log files.
-
#log(log_no) ⇒ Object
Returns the log at the given position in the log group.
-
#log_size ⇒ Object
The size in byes of each and every log in the group.
-
#logs ⇒ Object
The number of log files in the group.
-
#max_checkpoint_lsn ⇒ Object
Returns the LSN coordinates of the most recent (highest) checkpoint.
-
#reader(lsn_coordinates = start_lsn) ⇒ Object
Returns a LogReader using the given LSN reference coordinates.
-
#record(lsn_no) ⇒ Object
Parse and return a record at a given LSN.
-
#size ⇒ Object
The size of the log group (in bytes).
-
#start_lsn ⇒ Object
Returns the LSN coordinates of the data at the start of the log group.
Constructor Details
Instance Method Details
#capacity ⇒ Object
The log group capacity (in bytes).
49 50 51 |
# File 'lib/innodb/log_group.rb', line 49 def capacity @logs.first.capacity * @logs.count end |
#each_block(&block) ⇒ Object
Iterate through all blocks.
20 21 22 23 24 25 26 |
# 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) ⇒ Object
Iterate through all logs.
13 14 15 16 17 |
# 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) ⇒ Object
Returns the log at the given position in the log group.
34 35 36 |
# File 'lib/innodb/log_group.rb', line 34 def log(log_no) @logs.at(log_no) end |
#log_size ⇒ Object
The size in byes of each and every log in the group.
39 40 41 |
# File 'lib/innodb/log_group.rb', line 39 def log_size @logs.first.size end |
#logs ⇒ Object
The number of log files in the group.
29 30 31 |
# File 'lib/innodb/log_group.rb', line 29 def logs @logs.count end |
#max_checkpoint_lsn ⇒ Object
Returns the LSN coordinates of the most recent (highest) checkpoint.
59 60 61 |
# 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) ⇒ Object
Returns a LogReader using the given LSN reference coordinates.
64 65 66 |
# 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) ⇒ Object
Parse and return a record at a given LSN.
69 70 71 |
# File 'lib/innodb/log_group.rb', line 69 def record(lsn_no) reader.seek(lsn_no).record end |
#size ⇒ Object
The size of the log group (in bytes)
44 45 46 |
# File 'lib/innodb/log_group.rb', line 44 def size @logs.first.size * @logs.count end |
#start_lsn ⇒ Object
Returns the LSN coordinates of the data at the start of the log group.
54 55 56 |
# File 'lib/innodb/log_group.rb', line 54 def start_lsn [@logs.first.header[:start_lsn], Innodb::Log::LOG_HEADER_SIZE] end |