Class: Innodb::UndoLog::UndoRecordCursor

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

Instance Method Summary collapse

Constructor Details

#initialize(undo_log, offset, direction = :forward) ⇒ UndoRecordCursor

Returns a new instance of UndoRecordCursor.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/innodb/undo_log.rb', line 68

def initialize(undo_log, offset, direction=:forward)
  @initial = true
  @undo_log = undo_log
  @offset = offset
  @direction = direction

  case offset
  when :min
    @undo_record = @undo_log.min_undo_record
  when :max
    raise "Not implemented"
  else
    @undo_record = @undo_log.undo_record(offset)
  end
end

Instance Method Details

#each_undo_recordObject



110
111
112
113
114
115
116
117
118
# File 'lib/innodb/undo_log.rb', line 110

def each_undo_record
  unless block_given?
    return enum_for(:each_undo_record)
  end

  while rec = undo_record
    yield rec
  end
end

#next_undo_recordObject



84
85
86
87
88
# File 'lib/innodb/undo_log.rb', line 84

def next_undo_record
  if rec = @undo_record.next
    @undo_record = rec
  end
end

#prev_undo_recordObject



90
91
92
93
94
# File 'lib/innodb/undo_log.rb', line 90

def prev_undo_record
  if rec = @undo_record.prev
    @undo_record = rec
  end
end

#undo_recordObject



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/innodb/undo_log.rb', line 96

def undo_record
  if @initial
    @initial = false
    return @undo_record
  end

  case @direction
  when :forward
    next_undo_record
  when :backward
    prev_undo_record
  end
end