Class: Innodb::Page::Index::Compressed

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

Overview

This is horribly incomplete and broken. InnoDB compression does not currently work in innodb_ruby. Patches are welcome! (Hint hint, nudge nudge, Facebook developers!)

Constant Summary

Constants inherited from Innodb::Page::Index

PAGE_DIRECTION, PAGE_DIR_SLOT_MAX_N_OWNED, PAGE_DIR_SLOT_MIN_N_OWNED, PAGE_DIR_SLOT_SIZE, RECORD_COMPACT_BITS_SIZE, RECORD_INFO_DELETED_FLAG, RECORD_INFO_MIN_REC_FLAG, RECORD_MAX_N_FIELDS, RECORD_MAX_N_SYSTEM_FIELDS, RECORD_MAX_N_USER_FIELDS, RECORD_NEXT_SIZE, RECORD_REDUNDANT_BITS_SIZE, RECORD_REDUNDANT_OFF1_NULL_MASK, RECORD_REDUNDANT_OFF1_OFFSET_MASK, RECORD_REDUNDANT_OFF2_EXTERN_MASK, RECORD_REDUNDANT_OFF2_NULL_MASK, RECORD_REDUNDANT_OFF2_OFFSET_MASK, RECORD_TYPES

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::Index

#binary_search_by_directory, #directory_slot_for_record, #directory_space, #dump, #each_child_page, #each_directory_offset, #each_directory_record, #each_garbage_record, #each_record, #each_region, #fseg_header, #garbage_offset, #header_space, #index_id, #infimum, #leaf?, #level, #linear_search_from_cursor, #make_record_description, #max_record, #min_record, #offset_is_directory_slot?, #page_header, #pos_directory, #pos_fseg_header, #pos_index_header, #pos_infimum, #pos_records, #pos_supremum, #pos_user_records, #record, #record_bytes, #record_cursor, #record_describer, #record_describer=, #record_fields, #record_format, #record_header, #record_header_compact_additional, #record_header_compact_null_bitmap, #record_header_compact_variable_lengths_and_externs, #record_header_redundant_additional, #record_header_redundant_field_end_offsets, #record_if_exists, #record_is_directory_slot?, #record_space, #records, #root?, #size_fseg_header, #size_index_header, #size_mum_record, #size_mum_record_header_additional, #size_record_header, #supremum, #system_record, #trailer_space, #used_space

Methods inherited from Innodb::Page

#checksum, #checksum_crc32, #checksum_crc32?, #checksum_innodb, #checksum_innodb?, #checksum_invalid?, #checksum_trailer, #checksum_type, #checksum_valid?, #corrupt?, #cursor, #dump, #each_page_body_byte_as_uint8, #each_page_header_byte_as_uint8, #each_region, #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

#directoryObject



13
14
15
# File 'lib/innodb/page/index_compressed.rb', line 13

def directory
  super.map { |n| n & 0x3fff }
end

#directory_slotsObject

The number of directory slots in use.



9
10
11
# File 'lib/innodb/page/index_compressed.rb', line 9

def directory_slots
  page_header[:n_heap] - 2
end

#free_spaceObject

Return the amount of free space in the page.



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

def free_space
  free_space_start = size - size_fil_trailer - directory_space -
    (uncompressed_columns_size * (page_header[:n_heap] - 2))
  puts "Free space start == %04x" % [offset * size + free_space_start]
  c = cursor(free_space_start).backward
  zero_bytes = 0
  while (b = c.get_uint8) == 0
    zero_bytes += 1
  end
  zero_bytes
  #page_header[:garbage] +
  #  (size - size_fil_trailer - directory_space - page_header[:heap_top])
end

#uncompressed_columns_sizeObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/innodb/page/index_compressed.rb', line 17

def uncompressed_columns_size
  if level == 0
    if record_format && record_format[:type] == :clustered
      6 + 7 # Transaction ID + Roll Pointer
    else
      0
    end
  else
    4 # Node pointer for non-leaf pages
  end
end