Class: Innodb::Page::Index::RecordCursor

Inherits:
Object
  • Object
show all
Defined in:
lib/innodb/page/index.rb

Overview

A class for cursoring through records starting from an arbitrary point.

Instance Method Summary collapse

Constructor Details

#initialize(page, offset) ⇒ RecordCursor

Returns a new instance of RecordCursor.



418
419
420
421
# File 'lib/innodb/page/index.rb', line 418

def initialize(page, offset)
  @page   = page
  @offset = offset
end

Instance Method Details

#recordObject

Return the next record, and advance the cursor. Return nil when the end of records is reached.



425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/innodb/page/index.rb', line 425

def record
  return nil unless @offset

  record = @page.record(@offset)

  if record == @page.supremum
    @offset = nil
  else
    @offset = record[:next]
    record
  end
end