Class: Innodb::LSN
- Inherits:
-
Object
- Object
- Innodb::LSN
- Defined in:
- lib/innodb/lsn.rb
Instance Attribute Summary collapse
-
#lsn_no ⇒ Object
(also: #no)
readonly
The Log Sequence Number.
Instance Method Summary collapse
-
#advance(count_lsn_no, group) ⇒ Object
Advance by a given LSN amount.
-
#delta(length) ⇒ Object
Returns the LSN delta for the given amount of data.
-
#initialize(lsn, offset) ⇒ LSN
constructor
Initialize coordinates.
-
#location(group) ⇒ Object
Returns the location coordinates of this LSN.
-
#record?(group) ⇒ Boolean
Whether LSN might point to log record data.
-
#reposition(new_lsn_no, group) ⇒ Object
Place LSN in a new position.
Constructor Details
#initialize(lsn, offset) ⇒ LSN
Initialize coordinates.
13 14 15 16 |
# File 'lib/innodb/lsn.rb', line 13 def initialize(lsn, offset) @lsn_no = lsn @lsn_offset = offset end |
Instance Attribute Details
#lsn_no ⇒ Object (readonly) Also known as: no
The Log Sequence Number.
7 8 9 |
# File 'lib/innodb/lsn.rb', line 7 def lsn_no @lsn_no end |
Instance Method Details
#advance(count_lsn_no, group) ⇒ Object
Advance by a given LSN amount.
28 29 30 31 |
# File 'lib/innodb/lsn.rb', line 28 def advance(count_lsn_no, group) new_lsn_no = @lsn_no + count_lsn_no reposition(new_lsn_no, group) end |
#delta(length) ⇒ Object
Returns the LSN delta for the given amount of data.
39 40 41 42 43 44 |
# File 'lib/innodb/lsn.rb', line 39 def delta(length) fragment = (@lsn_no % LOG_BLOCK_SIZE) - LOG_BLOCK_HEADER_SIZE raise "Invalid fragment #{fragment} for LSN #{@lsn_no}" unless fragment.between?(0, LOG_BLOCK_DATA_SIZE - 1) length + ((fragment + length) / LOG_BLOCK_DATA_SIZE * LOG_BLOCK_FRAME_SIZE) end |
#location(group) ⇒ Object
Returns the location coordinates of this LSN.
34 35 36 |
# File 'lib/innodb/lsn.rb', line 34 def location(group) location_of(@lsn_offset, group) end |
#record?(group) ⇒ Boolean
Whether LSN might point to log record data.
47 48 49 |
# File 'lib/innodb/lsn.rb', line 47 def record?(group) data_offset?(@lsn_offset, group) end |
#reposition(new_lsn_no, group) ⇒ Object
Place LSN in a new position.
19 20 21 22 23 24 25 |
# File 'lib/innodb/lsn.rb', line 19 def reposition(new_lsn_no, group) new_offset = offset_of(@lsn_no, @lsn_offset, new_lsn_no, group) @lsn_no = new_lsn_no @lsn_offset = new_offset [@lsn_no, @lsn_offset] end |