Class: Innodb::Page::Index::RecordCursor
- Inherits:
-
Object
- Object
- Innodb::Page::Index::RecordCursor
- Defined in:
- lib/innodb/page/index.rb
Overview
A class for cursoring through records starting from an arbitrary point.
Instance Method Summary collapse
-
#initialize(page, offset) ⇒ RecordCursor
constructor
A new instance of RecordCursor.
-
#record ⇒ Object
Return the next record, and advance the cursor.
Constructor Details
#initialize(page, offset) ⇒ RecordCursor
Returns a new instance of RecordCursor.
568 569 570 571 |
# File 'lib/innodb/page/index.rb', line 568 def initialize(page, offset) @page = page @offset = offset end |
Instance Method Details
#record ⇒ Object
Return the next record, and advance the cursor. Return nil when the end of records is reached.
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/innodb/page/index.rb', line 575 def record return nil unless @offset record = @page.record(@offset) if record == @page.supremum # We've reached the end of the linked list at supremum. @offset = nil elsif record.next == @offset # The record links to itself; go ahead and return it (once), but set # the next offset to nil to end the loop. @offset = nil record else @offset = record.next record end end |