innodb_ruby 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ require "ostruct"
5
5
  require "pp"
6
6
  require "innodb"
7
7
 
8
- def space_summary(space)
8
+ def space_summary(space, start_page)
9
9
  puts "%-12s%-20s%-12s%-12s%-20s" % [
10
10
  "page",
11
11
  "type",
@@ -14,18 +14,18 @@ def space_summary(space)
14
14
  "lsn",
15
15
  ]
16
16
 
17
- space.each_page do |page_number, page|
17
+ space.each_page(start_page) do |page_number, page|
18
18
  puts "%-12i%-20s%-12i%-12i%-20i" % [
19
19
  page_number,
20
20
  page.type,
21
- page.prev,
22
- page.next,
23
- page.lsn,
21
+ page.prev || 0,
22
+ page.next || 0,
23
+ page.lsn || 0,
24
24
  ]
25
25
  end
26
26
  end
27
27
 
28
- def space_index_pages_summary(space)
28
+ def space_index_pages_summary(space, start_page)
29
29
  puts "%-12s%-8s%-8s%-8s%-8s%-8s" % [
30
30
  "page",
31
31
  "index",
@@ -35,7 +35,7 @@ def space_index_pages_summary(space)
35
35
  "records",
36
36
  ]
37
37
 
38
- space.each_page do |page_number, page|
38
+ space.each_page(start_page) do |page_number, page|
39
39
  case page.type
40
40
  when :INDEX
41
41
  puts "%-12i%-8i%-8i%-8i%-8i%-8i" % [
@@ -52,7 +52,7 @@ def space_index_pages_summary(space)
52
52
  end
53
53
  end
54
54
 
55
- def space_page_type_regions(space)
55
+ def space_page_type_regions(space, start_page)
56
56
  puts "%-12s%-12s%-12s%-20s" % [
57
57
  "start",
58
58
  "end",
@@ -60,7 +60,7 @@ def space_page_type_regions(space)
60
60
  "type",
61
61
  ]
62
62
 
63
- space.each_page_type_region do |region|
63
+ space.each_page_type_region(start_page) do |region|
64
64
  puts "%-12i%-12i%-12i%-20s" % [
65
65
  region[:start],
66
66
  region[:end],
@@ -185,14 +185,14 @@ def index_fseg_summary(index, fseg_name, list_name)
185
185
  print_xdes_list(fseg[list_name])
186
186
  end
187
187
 
188
- def space_index_pages_free_plot(space, image)
188
+ def space_index_pages_free_plot(space, image, start_page)
189
189
  unless require "gnuplot"
190
190
  raise "Couldn't load gnuplot. Is it installed?"
191
191
  end
192
192
 
193
193
  index_data = {0 => {:x => [], :y => []}}
194
194
 
195
- space.each_page do |page_number, page|
195
+ space.each_page(start_page) do |page_number, page|
196
196
  case page.type
197
197
  when :INDEX
198
198
  data = (index_data[page.page_header[:index_id]] ||= {:x => [], :y => []})
@@ -360,22 +360,26 @@ The following modes are supported:
360
360
  Dump the contents of the page, using the Ruby pp ("pretty-print") module.
361
361
 
362
362
  space-summary
363
- Summarize all pages within a tablespace.
363
+ Summarize all pages within a tablespace. A starting page number can be
364
+ provided with the --page/-p argument.
364
365
 
365
366
  space-index-pages-summary
366
367
  Summarize all "INDEX" pages within a tablespace. This is useful to analyze
367
368
  page fill rates and record counts per page. In addition to "INDEX" pages,
368
369
  "ALLOCATED" pages are also printed and assumed to be completely empty.
370
+ A starting page number can be provided with the --page/-p argument.
369
371
 
370
372
  space-index-pages-free-plot
371
373
  Use Ruby's gnuplot module to produce a scatterplot of page free space for
372
374
  all "INDEX" and "ALLOCATED" pages in a tablespace. More aesthetically
373
375
  pleasing plots can be produced with space-index-pages-summary output,
374
- but this is a quick and easy way to produce a passable plot.
376
+ but this is a quick and easy way to produce a passable plot. A starting
377
+ page number can be provided with the --page/-p argument.
375
378
 
376
379
  space-page-type-regions
377
380
  Summarize all contiguous regions of the same page type. This is useful to
378
- provide an overall view of the space and allocations within it.
381
+ provide an overall view of the space and allocations within it. A starting
382
+ page number can be provided with the --page/-p argument.
379
383
 
380
384
  space-lists
381
385
  Print the names of all lists in a space.
@@ -485,14 +489,14 @@ ARGV.each do |mode|
485
489
  space.page(page).dump
486
490
  end
487
491
  when "space-summary"
488
- space_summary(space)
492
+ space_summary(space, @options.pages.first || 0)
489
493
  when "space-index-pages-summary"
490
- space_index_pages_summary(space)
494
+ space_index_pages_summary(space, @options.pages.first || 0)
491
495
  when "space-index-pages-free-plot"
492
496
  name = File.basename(@options.file).sub(".ibd", "")
493
- space_index_pages_free_plot(space, name)
497
+ space_index_pages_free_plot(space, name, @options.pages.first || 0)
494
498
  when "space-page-type-regions"
495
- space_page_type_regions(space)
499
+ space_page_type_regions(space, @options.pages.first || 0)
496
500
  when "space-lists"
497
501
  space_lists(space)
498
502
  when "space-indexes"
@@ -380,7 +380,15 @@ class Innodb::Page::Index < Innodb::Page
380
380
  # fields, a transaction ID and roll pointer.
381
381
  if level == 0 && record_format[:type] == :clustered
382
382
  this_record[:transaction_id] = c.get_hex(6)
383
- this_record[:roll_pointer] = c.get_hex(7)
383
+ first_byte = c.get_uint8
384
+ this_record[:roll_pointer] = {
385
+ :is_insert => (first_byte & 0x80) == 0x80,
386
+ :rseg_id => first_byte & 0x7f,
387
+ :undo_log => {
388
+ :page => c.get_uint32,
389
+ :offset => c.get_uint16,
390
+ }
391
+ }
384
392
  end
385
393
 
386
394
  # If this is a leaf page of the clustered index, or any page of a
@@ -84,12 +84,12 @@ class Innodb::Space
84
84
 
85
85
  # Iterate through all pages in a tablespace, returning the page number
86
86
  # and an Innodb::Page object for each one.
87
- def each_page
87
+ def each_page(start_page=0)
88
88
  unless block_given?
89
89
  return Enumerable::Enumerator.new(self, :each_page)
90
90
  end
91
91
 
92
- (0...@pages).each do |page_number|
92
+ (start_page...@pages).each do |page_number|
93
93
  current_page = page(page_number)
94
94
  yield page_number, current_page if current_page
95
95
  end
@@ -97,13 +97,13 @@ class Innodb::Space
97
97
 
98
98
  # Iterate through unique regions in the space by page type. This is useful
99
99
  # to achieve an overall view of the space.
100
- def each_page_type_region
100
+ def each_page_type_region(start_page=0)
101
101
  unless block_given?
102
102
  return Enumerable::Enumerator.new(self, :each_page_type_region)
103
103
  end
104
104
 
105
105
  region = nil
106
- each_page do |page_number, page|
106
+ each_page(start_page) do |page_number, page|
107
107
  if region && region[:type] == page.type
108
108
  region[:end] = page_number
109
109
  region[:count] += 1
@@ -1,3 +1,3 @@
1
1
  module Innodb
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "enumerator"
2
+
1
3
  # An InnoDB "extent descriptor entry" or "+XDES+". These structures are used
2
4
  # in the +XDES+ entry array contained in +FSP_HDR+ and +XDES+ pages.
3
5
  #
@@ -86,7 +88,9 @@ class Innodb::Xdes
86
88
  return Enumerable::Enumerator.new(self, :each_page_status)
87
89
  end
88
90
 
89
- xdes[:bitmap].bytes.each_with_index do |byte, byte_index|
91
+ bitmap = Enumerable::Enumerator.new(xdes[:bitmap], :each_byte)
92
+
93
+ bitmap.each_with_index do |byte, byte_index|
90
94
  (0..3).each_with_index do |page, page_index|
91
95
  page_number = xdes[:start_page] + (byte_index * 4) + page_index
92
96
  page_bits = ((byte >> (page * BITS_PER_PAGE)) & BITMAP_BV_ALL)
@@ -125,4 +129,4 @@ class Innodb::Xdes
125
129
  def next_address
126
130
  xdes[:list][:next]
127
131
  end
128
- end
132
+ end
metadata CHANGED
@@ -1,48 +1,35 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: innodb_ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 4
10
- version: 0.7.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jeremy Cole
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-12-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: bindata
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70358166884520 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 13
29
- segments:
30
- - 1
31
- - 4
32
- - 5
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.4.5
34
22
  type: :runtime
35
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *70358166884520
36
25
  description: Library for parsing InnoDB data files in Ruby
37
26
  email: jeremy@jcole.us
38
- executables:
27
+ executables:
39
28
  - innodb_log
40
29
  - innodb_space
41
30
  extensions: []
42
-
43
31
  extra_rdoc_files: []
44
-
45
- files:
32
+ files:
46
33
  - README.md
47
34
  - lib/innodb.rb
48
35
  - lib/innodb/cursor.rb
@@ -65,37 +52,27 @@ files:
65
52
  - bin/innodb_space
66
53
  homepage: http://jcole.us/
67
54
  licenses: []
68
-
69
55
  post_install_message:
70
56
  rdoc_options: []
71
-
72
- require_paths:
57
+ require_paths:
73
58
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ required_ruby_version: !ruby/object:Gem::Requirement
75
60
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
66
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
92
71
  requirements: []
93
-
94
72
  rubyforge_project:
95
- rubygems_version: 1.8.10
73
+ rubygems_version: 1.8.6
96
74
  signing_key:
97
75
  specification_version: 3
98
76
  summary: InnoDB data file parser
99
77
  test_files: []
100
-
101
78
  has_rdoc: