Class: Innodb::IbufBitmap
- Inherits:
-
Object
- Object
- Innodb::IbufBitmap
- Defined in:
- lib/innodb/ibuf_bitmap.rb
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(page, cursor) ⇒ Object
- #size_bitmap ⇒ Object
Constructor Details
#initialize(page, cursor) ⇒ IbufBitmap
Returns a new instance of IbufBitmap.
15 16 17 18 |
# File 'lib/innodb/ibuf_bitmap.rb', line 15 def initialize(page, cursor) @page = page @bitmap = read_bitmap(page, cursor) end |
Instance Method Details
#each_page_status ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/innodb/ibuf_bitmap.rb', line 30 def each_page_status unless block_given? return enum_for(:each_page_status) end 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 = { :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(page, cursor) ⇒ Object
24 25 26 27 28 |
# File 'lib/innodb/ibuf_bitmap.rb', line 24 def read_bitmap(page, cursor) cursor.name("ibuf_bitmap") do |c| c.get_bytes(size_bitmap) end end |
#size_bitmap ⇒ Object
20 21 22 |
# File 'lib/innodb/ibuf_bitmap.rb', line 20 def size_bitmap (@page.space.pages_per_bookkeeping_page * BITS_PER_PAGE) / 8 end |