Class: Innodb::Page::Inode

Inherits:
Innodb::Page show all
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

Constants inherited from Innodb::Page

PAGE_TYPE, PAGE_TYPE_BY_VALUE, SPECIALIZED_CLASSES

Instance Attribute Summary

Attributes inherited from Innodb::Page

#space

Instance Method Summary collapse

Methods inherited from Innodb::Page

#checksum, #checksum_crc32, #checksum_crc32?, #checksum_innodb, #checksum_innodb?, #checksum_invalid?, #checksum_trailer, #checksum_type, #checksum_valid?, #corrupt?, #cursor, #each_page_body_byte_as_uint8, #each_page_header_byte_as_uint8, #fil_header, #fil_trailer, handle, #in_doublewrite_buffer?, #initialize, #inspect, #lsn, #lsn_low32_header, #lsn_low32_trailer, maybe_undefined, #misplaced?, #misplaced_offset?, #misplaced_space?, #name, #next, #offset, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #pos_partial_page_header, #prev, #size, #size_fil_header, #size_fil_trailer, #size_page_body, #size_partial_page_header, #space_id, #torn?, #type

Constructor Details

This class inherits a constructor from Innodb::Page

Instance Method Details

#dumpObject

Dump the contents of a page for debugging purposes.



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/innodb/page/inode.rb', line 124

def dump
  super

  puts "list entry:"
  pp list_entry
  puts

  puts "inodes:"
  each_inode do |inode|
    inode.dump
  end
  puts
end

#each_allocated_inodeObject

Iterate through all allocated inodes in the inode array.



76
77
78
79
80
81
82
83
84
# File 'lib/innodb/page/inode.rb', line 76

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

  each_inode do |this_inode|
    yield this_inode if this_inode.allocated?
  end
end

#each_inodeObject

Iterate through all Inodes in the inode array.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/innodb/page/inode.rb', line 61

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

  inode_cursor = cursor(pos_inode_array)
  inodes_per_page.times do |n|
    inode_cursor.name("inode[#{n}]") do |c|
      this_inode = Innodb::Inode.new_from_cursor(@space, c)
      yield this_inode
    end
  end
end

#each_region {|{ :offset => pos_list_entry, :length => size_list_entry, :name => :list_entry, :info => "Inode List Entry", }| ... } ⇒ Object

Yields:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/innodb/page/inode.rb', line 86

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

  super do |region|
    yield region
  end

  yield({
    :offset => pos_list_entry,
    :length => size_list_entry,
    :name => :list_entry,
    :info => "Inode List Entry",
  })

  each_inode do |inode|
    if inode.allocated?
      yield({
        :offset => inode.offset,
        :length => Innodb::Inode::SIZE,
        :name => :inode_used,
        :info => "Inode (used)",
      })
    else
      yield({
        :offset => inode.offset,
        :length => Innodb::Inode::SIZE,
        :name => :inode_free,
        :info => "Inode (free)",
      })
    end
  end

  nil
end

#inode_at(cursor) ⇒ Object

Read a single Inode entry from the provided byte offset by creating a cursor and reading the inode using the inode method.



56
57
58
# File 'lib/innodb/page/inode.rb', line 56

def inode_at(cursor)
  cursor.name("inode[#{cursor.position}]") { |c| Innodb::Inode.new_from_cursor(@space, c) }
end

#inodes_per_pageObject

The number of Inode entries that fit on a page.



27
28
29
# File 'lib/innodb/page/inode.rb', line 27

def inodes_per_page
  (size - pos_inode_array - 10) / Innodb::Inode::SIZE
end

#list_entryObject

Return the list entry.



36
37
38
39
40
# File 'lib/innodb/page/inode.rb', line 36

def list_entry
  cursor(pos_list_entry).name("list") do |c|
    Innodb::List.get_node(c)
  end
end

#next_addressObject

Return the “next” address pointer from the list entry. This is used by Innodb::List::Inode to iterate through Inode lists.



50
51
52
# File 'lib/innodb/page/inode.rb', line 50

def next_address
  list_entry[:next]
end

#pos_inode_arrayObject

Return the byte offset of the Inode array in the page, which immediately follows the list entry.



22
23
24
# File 'lib/innodb/page/inode.rb', line 22

def pos_inode_array
  pos_list_entry + size_list_entry
end

#pos_list_entryObject

Return the byte offset of the list node, which immediately follows the FIL header.



11
12
13
# File 'lib/innodb/page/inode.rb', line 11

def pos_list_entry
  pos_page_body
end

#prev_addressObject

Return the “previous” address pointer from the list entry. This is used by Innodb::List::Inode to iterate through Inode lists.



44
45
46
# File 'lib/innodb/page/inode.rb', line 44

def prev_address
  list_entry[:prev]
end

#size_inode_arrayObject



31
32
33
# File 'lib/innodb/page/inode.rb', line 31

def size_inode_array
  inodes_per_page * Innodb::Inode::SIZE
end

#size_list_entryObject

Return the size of the list node.



16
17
18
# File 'lib/innodb/page/inode.rb', line 16

def size_list_entry
  Innodb::List::NODE_SIZE
end