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, SPECIALIZED_CLASSES

Instance Attribute Summary

Attributes inherited from Innodb::Page

#space

Instance Method Summary collapse

Methods inherited from Innodb::Page

#calculate_checksum, #checksum, #corrupt?, #cursor, #data, #fil_header, handle, #initialize, #inspect, #lsn, maybe_undefined, #next, #offset, parse, #pos_fil_header, #pos_fil_trailer, #pos_page_body, #prev, #size, #size_fil_header, #size_fil_trailer, #type

Constructor Details

This class inherits a constructor from Innodb::Page

Instance Method Details

#blob_dataObject



25
26
27
28
29
# File 'lib/innodb/page/blob.rb', line 25

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

#blob_headerObject



16
17
18
19
20
21
22
23
# File 'lib/innodb/page/blob.rb', line 16

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

#dumpObject

Dump the contents of a page for debugging purposes.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/innodb/page/blob.rb', line 45

def dump
  super

  puts "blob header:"
  pp blob_header
  puts

  puts "blob data:"
  dump_hex(blob_data)
  puts

  puts
end

#dump_hex(string) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/innodb/page/blob.rb', line 31

def dump_hex(string)
  slice_size = 16
  bytes = string.split("").map { |s| s.ord }
  string.split("").each_slice(slice_size).each_with_index do |slice_bytes, slice_count|
    puts "%08i  %-23s  %-23s  |%-16s|" % [
      (slice_count * slice_size),
      slice_bytes[0..8].map { |n| "%02x" % n.ord }.join(" "),
      slice_bytes[8..16].map { |n| "%02x" % n.ord }.join(" "),
      slice_bytes.join(""),
    ]
  end
end

#pos_blob_dataObject



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

def pos_blob_data
  pos_blob_header + size_blob_header
end

#pos_blob_headerObject



4
5
6
# File 'lib/innodb/page/blob.rb', line 4

def pos_blob_header
  pos_fil_header + size_fil_header
end

#size_blob_headerObject



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

def size_blob_header
  4 + 4
end