innodb_ruby 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/innodb_space CHANGED
@@ -52,6 +52,24 @@ def space_index_pages_summary(space)
52
52
  end
53
53
  end
54
54
 
55
+ def space_page_type_regions(space)
56
+ puts "%-12s%-12s%-12s%-20s" % [
57
+ "start",
58
+ "end",
59
+ "count",
60
+ "type",
61
+ ]
62
+
63
+ space.each_page_type_region do |region|
64
+ puts "%-12i%-12i%-12i%-20s" % [
65
+ region[:start],
66
+ region[:end],
67
+ region[:count],
68
+ region[:type],
69
+ ]
70
+ end
71
+ end
72
+
55
73
  def index_recurse(index)
56
74
  index.recurse(
57
75
  lambda do |page, depth|
@@ -183,6 +201,10 @@ The following modes are supported:
183
201
  page fill rates and record counts per page. In addition to "INDEX" pages,
184
202
  "ALLOCATED" pages are also printed and assumed to be completely empty.
185
203
 
204
+ space-page-type-regions
205
+ Summarize all contiguous regions of the same page type. This is useful to
206
+ provide an overall view of the space and allocations within it.
207
+
186
208
  index-recurse
187
209
  Recurse an index, starting at the root (which must be provided in the first
188
210
  --page/-p argument), printing the node pages, node pointers (links), leaf
@@ -266,6 +288,8 @@ ARGV.each do |mode|
266
288
  space_summary(space)
267
289
  when "space-index-pages-summary"
268
290
  space_index_pages_summary(space)
291
+ when "space-page-type-regions"
292
+ space_page_type_regions(space)
269
293
  when "index-recurse"
270
294
  unless space.record_describer
271
295
  usage 1, "Record describer necessary for index recursion"
data/lib/innodb/index.rb CHANGED
@@ -24,6 +24,11 @@ class Innodb::Index
24
24
  end
25
25
  end
26
26
 
27
+ # A helper function to access the index ID in the page header.
28
+ def id
29
+ @root.page_header[:index_id]
30
+ end
31
+
27
32
  # Internal method used by recurse.
28
33
  def _recurse(parent_page, page_proc, link_proc, depth=0)
29
34
  if page_proc && parent_page.type == :INDEX
@@ -139,6 +139,12 @@ class Innodb::Page::Index < Innodb::Page
139
139
  page_header && page_header[:level]
140
140
  end
141
141
 
142
+ # A helper function to identify root index pages; they must be the only pages
143
+ # at their level.
144
+ def root?
145
+ self.prev.nil? && self.next.nil?
146
+ end
147
+
142
148
  RECORD_BITS_SIZE = 3
143
149
  RECORD_NEXT_SIZE = 2
144
150
 
data/lib/innodb/space.rb CHANGED
@@ -35,6 +35,20 @@ class Innodb::Space
35
35
  Innodb::Index.new(self, root_page_number)
36
36
  end
37
37
 
38
+ # Iterate through each index by guessing that the root pages will be
39
+ # present starting at page 3, and walking forward until we find a non-
40
+ # root page. This should work fine for IBD files, but not for ibdata
41
+ # files.
42
+ def each_index
43
+ (3...@pages).each do |page_number|
44
+ if page(page_number).root?
45
+ yield index(page_number)
46
+ else
47
+ break
48
+ end
49
+ end
50
+ end
51
+
38
52
  # Iterate through all pages in a tablespace, returning the page number
39
53
  # and an Innodb::Page object for each one.
40
54
  def each_page
@@ -43,4 +57,25 @@ class Innodb::Space
43
57
  yield page_number, current_page if current_page
44
58
  end
45
59
  end
60
+
61
+ # Iterate through unique regions in the space by page type. This is useful
62
+ # to achieve an overall view of the space.
63
+ def each_page_type_region
64
+ region = nil
65
+ each_page do |page_number, page|
66
+ if region && region[:type] == page.type
67
+ region[:end] = page_number
68
+ region[:count] += 1
69
+ else
70
+ yield region if region
71
+ region = {
72
+ :start => page_number,
73
+ :end => page_number,
74
+ :type => page.type,
75
+ :count => 1,
76
+ }
77
+ end
78
+ end
79
+ yield region if region
80
+ end
46
81
  end
@@ -1,3 +1,3 @@
1
1
  module Innodb
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innodb_ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Cole
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-01 00:00:00 Z
18
+ date: 2012-12-04 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Library for parsing InnoDB data files in Ruby