Class: Innodb::Page::Blob

Inherits:
Innodb::Page show all
Defined in:
lib/innodb/page/blob.rb

Constant Summary

Constants inherited from Innodb::Page

PAGE_TYPE, PAGE_TYPE_BY_VALUE, UNDEFINED_PAGE_NUMBER

Instance Attribute Summary

Attributes inherited from Innodb::Page

#space

Instance Method Summary collapse

Methods inherited from Innodb::Page

#checksum_crc32, #checksum_crc32?, #checksum_innodb, #checksum_innodb?, #checksum_invalid?, #checksum_type, #checksum_valid?, #corrupt?, #cursor, #default_page_size?, #each_page_body_byte_as_uint8, #each_page_header_byte_as_uint8, #extent_descriptor?, #fil_header, #fil_trailer, handle, #in_doublewrite_buffer?, #initialize, #inspect, #inspect_header_fields, maybe_undefined, #misplaced?, #misplaced_offset?, #misplaced_space?, #name, page_type_by_value, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #pos_partial_page_header, register_specialization, #size, #size_fil_header, #size_fil_trailer, #size_page_body, #size_partial_page_header, specialization_for, specialization_for?, #torn?, undefined?

Constructor Details

This class inherits a constructor from Innodb::Page

Instance Method Details

#blob_dataObject



29
30
31
32
33
# File 'lib/innodb/page/blob.rb', line 29

def blob_data
  cursor(pos_blob_data).name("blob_data") do |c|
    c.read_bytes(blob_header[:length])
  end
end

#blob_headerObject



20
21
22
23
24
25
26
27
# File 'lib/innodb/page/blob.rb', line 20

def blob_header
  cursor(pos_blob_header).name("blob_header") do |c|
    {
      length: c.name("length") { c.read_uint32 },
      next: c.name("next") { Innodb::Page.maybe_undefined(c.read_uint32) },
    }
  end
end

#dumpObject

Dump the contents of a page for debugging purposes.



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/innodb/page/blob.rb', line 64

def dump
  super

  puts "blob header:"
  pp blob_header
  puts

  puts "blob data:"
  HexFormat.puts(blob_data)
  puts

  puts
end

#each_region {|Region.new( offset: pos_blob_header, length: size_blob_header, name: :blob_header, info: "Blob Header" )| ... } ⇒ Object

Yields:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/innodb/page/blob.rb', line 41

def each_region(&block)
  return enum_for(:each_region) unless block_given?

  super

  yield Region.new(
    offset: pos_blob_header,
    length: size_blob_header,
    name: :blob_header,
    info: "Blob Header"
  )

  yield Region.new(
    offset: pos_blob_data,
    length: blob_header[:length],
    name: :blob_data,
    info: "Blob Data"
  )

  nil
end

#next_blob_pageObject



35
36
37
38
39
# File 'lib/innodb/page/blob.rb', line 35

def next_blob_page
  return unless blob_header[:next]

  space.page(blob_header[:next])
end

#pos_blob_dataObject



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

def pos_blob_data
  pos_blob_header + size_blob_header
end

#pos_blob_headerObject



8
9
10
# File 'lib/innodb/page/blob.rb', line 8

def pos_blob_header
  pos_page_body
end

#size_blob_headerObject



12
13
14
# File 'lib/innodb/page/blob.rb', line 12

def size_blob_header
  4 + 4
end