Class: Innodb::IbufBitmap
- Inherits:
-
Object
- Object
- Innodb::IbufBitmap
- Defined in:
- lib/innodb/ibuf_bitmap.rb
Defined Under Namespace
Classes: PageStatus
Constant Summary collapse
- BITS_PER_PAGE =
4
- BITMAP_BV_FREE =
1 + 2
- BITMAP_BV_BUFFERED =
4
- BITMAP_BV_IBUF =
8
- BITMAP_BV_ALL =
BITMAP_BV_FREE | BITMAP_BV_BUFFERED | BITMAP_BV_IBUF
Instance Method Summary collapse
- #each_page_status ⇒ Object
-
#initialize(page, cursor) ⇒ IbufBitmap
constructor
A new instance of IbufBitmap.
- #read_bitmap(cursor) ⇒ Object
- #size_bitmap ⇒ Object
Constructor Details
#initialize(page, cursor) ⇒ IbufBitmap
Returns a new instance of IbufBitmap.
18 19 20 21 |
# File 'lib/innodb/ibuf_bitmap.rb', line 18 def initialize(page, cursor) @page = page @bitmap = read_bitmap(cursor) end |
Instance Method Details
#each_page_status ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/innodb/ibuf_bitmap.rb', line 31 def each_page_status return enum_for(:each_page_status) unless block_given? bitmap = @bitmap.enum_for(:each_byte) bitmap.each_with_index do |byte, byte_index| (0..1).each do |page_offset| page_number = (byte_index * 2) + page_offset page_bits = ((byte >> (page_offset * BITS_PER_PAGE)) & BITMAP_BV_ALL) page_status = PageStatus.new( free: (page_bits & BITMAP_BV_FREE), buffered: (page_bits & BITMAP_BV_BUFFERED != 0), ibuf: (page_bits & BITMAP_BV_IBUF != 0) ) yield page_number, page_status end end end |
#read_bitmap(cursor) ⇒ Object
27 28 29 |
# File 'lib/innodb/ibuf_bitmap.rb', line 27 def read_bitmap(cursor) cursor.name("ibuf_bitmap") { |c| c.read_bytes(size_bitmap) } end |
#size_bitmap ⇒ Object
23 24 25 |
# File 'lib/innodb/ibuf_bitmap.rb', line 23 def size_bitmap (@page.space.pages_per_bookkeeping_page * BITS_PER_PAGE) / 8 end |