Class: Innodb::Page::Inode
- Inherits:
-
Innodb::Page
- Object
- Innodb::Page
- Innodb::Page::Inode
- Defined in:
- lib/innodb/page/inode.rb
Overview
A specialized class for handling INODE pages, which contain index FSEG (file segment) information. This allows all extents and individual pages assigned to each index to be found.
Constant Summary collapse
- FRAG_ARRAY_N_SLOTS =
The number of “slots” (each representing one page) in the fragment array within each Inode entry.
32
- FRAG_SLOT_SIZE =
The size (in bytes) of each slot in the fragment array.
4
- MAGIC_N_VALUE =
A magic number which helps determine if an Inode structure is in use and populated with valid data.
97937874
Constants inherited from Innodb::Page
PAGE_TYPE, SPECIALIZED_CLASSES
Instance Attribute Summary
Attributes inherited from Innodb::Page
Instance Method Summary collapse
-
#dump ⇒ Object
Dump the contents of a page for debugging purposes.
-
#each_inode ⇒ Object
Iterate through all Inodes in the inode array.
-
#inode(cursor) ⇒ Object
Read a single Inode entry from the provided cursor.
-
#inode_at(offset) ⇒ Object
Read a single Inode entry from the provided byte offset by creating a cursor and reading the inode using the inode method.
-
#inodes_per_page ⇒ Object
The number of Inode entries that fit on a page.
-
#list_entry ⇒ Object
Return the list entry.
-
#next_address ⇒ Object
Return the “next” address pointer from the list entry.
-
#page_number_array(size, cursor) ⇒ Object
Read an array of page numbers (32-bit integers, which may be nil) from the provided cursor.
-
#pos_inode_array ⇒ Object
Return the byte offset of the Inode array in the page, which immediately follows the list entry.
-
#pos_list_entry ⇒ Object
Return the byte offset of the list node, which immediately follows the FIL header.
-
#prev_address ⇒ Object
Return the “previous” address pointer from the list entry.
-
#size_inode ⇒ Object
The size (in bytes) of an Inode entry.
-
#size_list_entry ⇒ Object
Return the byte offset of the list node.
Methods inherited from Innodb::Page
#cursor, #data, #fil_header, #initialize, #inspect, #lsn, maybe_undefined, #next, #offset, parse, #pos_fil_header, #pos_fil_trailer, #prev, #size, #size_fil_header, #size_fil_trailer, #type
Constructor Details
This class inherits a constructor from Innodb::Page
Instance Method Details
#dump ⇒ Object
Dump the contents of a page for debugging purposes.
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/innodb/page/inode.rb', line 102 def dump super puts "list entry:" pp list_entry puts puts "inodes:" each_inode do |i| pp i end puts end |
#each_inode ⇒ Object
Iterate through all Inodes in the inode array.
93 94 95 96 97 98 99 |
# File 'lib/innodb/page/inode.rb', line 93 def each_inode inode_cursor = cursor(pos_inode_array) inodes_per_page.times do this_inode = inode(inode_cursor) yield this_inode if this_inode[:fseg_id] != 0 end end |
#inode(cursor) ⇒ Object
Read a single Inode entry from the provided cursor.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/innodb/page/inode.rb', line 71 def inode(cursor) { :fseg_id => cursor.get_uint64, :not_full_n_used => cursor.get_uint32, :free => Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(cursor)), :not_full => Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(cursor)), :full => Innodb::List::Xdes.new(@space, Innodb::List.get_base_node(cursor)), :magic_n => cursor.get_uint32, :frag_array => page_number_array(FRAG_ARRAY_N_SLOTS, cursor), } end |
#inode_at(offset) ⇒ Object
Read a single Inode entry from the provided byte offset by creating a cursor and reading the inode using the inode method.
88 89 90 |
# File 'lib/innodb/page/inode.rb', line 88 def inode_at(offset) inode(cursor(offset)) end |
#inodes_per_page ⇒ Object
The number of Inode entries that fit on a page.
42 43 44 |
# File 'lib/innodb/page/inode.rb', line 42 def inodes_per_page (size - pos_inode_array - 10) / size_inode end |
#list_entry ⇒ Object
Return the list entry.
47 48 49 50 |
# File 'lib/innodb/page/inode.rb', line 47 def list_entry c = cursor(pos_list_entry) Innodb::List.get_node(c) end |
#next_address ⇒ Object
Return the “next” address pointer from the list entry. This is used by Innodb::List::Inode to iterate through Inode lists.
60 61 62 |
# File 'lib/innodb/page/inode.rb', line 60 def next_address list_entry[:next] end |
#page_number_array(size, cursor) ⇒ Object
Read an array of page numbers (32-bit integers, which may be nil) from the provided cursor.
66 67 68 |
# File 'lib/innodb/page/inode.rb', line 66 def page_number_array(size, cursor) size.times.map { |n| Innodb::Page.maybe_undefined(cursor.get_uint32) } end |
#pos_inode_array ⇒ Object
Return the byte offset of the Inode array in the page, which immediately follows the list entry.
31 32 33 |
# File 'lib/innodb/page/inode.rb', line 31 def pos_inode_array pos_list_entry + size_list_entry end |
#pos_list_entry ⇒ Object
Return the byte offset of the list node, which immediately follows the FIL header.
20 21 22 |
# File 'lib/innodb/page/inode.rb', line 20 def pos_list_entry pos_fil_header + size_fil_header end |
#prev_address ⇒ Object
Return the “previous” address pointer from the list entry. This is used by Innodb::List::Inode to iterate through Inode lists.
54 55 56 |
# File 'lib/innodb/page/inode.rb', line 54 def prev_address list_entry[:prev] end |
#size_inode ⇒ Object
The size (in bytes) of an Inode entry.
36 37 38 39 |
# File 'lib/innodb/page/inode.rb', line 36 def size_inode (16 + (3 * Innodb::List::BASE_NODE_SIZE) + (FRAG_ARRAY_N_SLOTS * FRAG_SLOT_SIZE)) end |