innodb_ruby 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/innodb_log CHANGED
@@ -5,12 +5,37 @@ require "ostruct"
5
5
  require "set"
6
6
  require "innodb"
7
7
 
8
+ def log_summary(log, space_ids)
9
+ puts "%-10s%-30s%-10s%-10s" % [
10
+ "block",
11
+ "type",
12
+ "space",
13
+ "page",
14
+ ]
15
+ log.each_block do |block_number, block|
16
+ if block.record
17
+ space_id = block.record[:space]
18
+ if @options.space_ids.empty? or @options.space_ids.include?(space_id)
19
+ puts "%-10i%-30s%-10i%-10i" % [
20
+ block_number,
21
+ block.record[:type],
22
+ space_id,
23
+ block.record[:page_number],
24
+ ]
25
+ if @options.dump
26
+ block.dump
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
8
33
  def usage(exit_code, message = nil)
9
34
  print "Error: #{message}\n" unless message.nil?
10
35
 
11
36
  print <<'END_OF_USAGE'
12
37
 
13
- Usage: innodb_log [-d] [-s] <file> [block-number]
38
+ Usage: innodb_log [-d] [-s] <file> [<mode>]
14
39
 
15
40
  --help, -?
16
41
  Print this usage text.
@@ -21,6 +46,11 @@ Usage: innodb_log [-d] [-s] <file> [block-number]
21
46
  --space-id, -s
22
47
  Print only given space id (may provide multiple times).
23
48
 
49
+ The following modes are supported:
50
+
51
+ log-summary (default)
52
+ A summary of all blocks within log that contain at least one record.
53
+
24
54
  END_OF_USAGE
25
55
 
26
56
  exit exit_code
@@ -49,32 +79,18 @@ getopt.each do |opt, arg|
49
79
  end
50
80
  end
51
81
 
52
- filename, block_number = ARGV.shift(2)
82
+ filename, mode = ARGV.shift(2)
53
83
  if filename.nil?
54
84
  usage 1
55
85
  end
56
86
 
57
87
  log = Innodb::Log.new(filename)
58
88
 
59
- puts "%-10s%-30s%-10s%-10s" % [
60
- "block",
61
- "type",
62
- "space",
63
- "page",
64
- ]
65
- log.each_block do |block_number, block|
66
- if block.record
67
- space_id = block.record[:space]
68
- if @options.space_ids.empty? or @options.space_ids.include?(space_id)
69
- puts "%-10i%-30s%-10i%-10i" % [
70
- block_number,
71
- block.record[:type],
72
- space_id,
73
- block.record[:page_number],
74
- ]
75
- if @options.dump
76
- block.dump
77
- end
78
- end
79
- end
89
+ mode ||= "log-summary"
90
+
91
+ case mode
92
+ when "log-summary"
93
+ log_summary(log, @options.space_ids)
94
+ else
95
+ usage 1, "Unknown mode: #{mode}"
80
96
  end
data/lib/innodb/inode.rb CHANGED
@@ -88,7 +88,7 @@ class Innodb::Inode
88
88
 
89
89
  # Calculate the total number of pages in use (not free) within this fseg.
90
90
  def used_pages
91
- frag_array_n_used + not_full_n_used
91
+ frag_array_n_used + not_full_n_used +
92
92
  (full.length * @space.pages_per_extent)
93
93
  end
94
94
 
data/lib/innodb/system.rb CHANGED
@@ -48,6 +48,36 @@ class Innodb::System
48
48
  end
49
49
  end
50
50
 
51
+ def object_by_field(method, field, value)
52
+ send(method).select { |o| o[field] == value }.first
53
+ end
54
+
55
+ def object_by_two_fields(method, f1, v1, f2, v2)
56
+ send(method).select { |o| o[f1] == v1 && o[f2] == v2 }.first
57
+ end
58
+
59
+ def table_by_id(value)
60
+ object_by_field(:each_table, "ID", value)
61
+ end
62
+
63
+ def table_by_name(value)
64
+ object_by_field(:each_table, "NAME", value)
65
+ end
66
+
67
+ def index_by_id(value)
68
+ object_by_field(:each_index, "ID", value)
69
+ end
70
+
71
+ def index_by_name(table_name, index_name)
72
+ unless table = table_by_name(table_name)
73
+ return nil
74
+ end
75
+
76
+ object_by_two_fields(:each_index,
77
+ "TABLE_ID", table["ID"],
78
+ "NAME", index_name)
79
+ end
80
+
51
81
  def add_space(space)
52
82
  @spaces[space.space_id] = space
53
83
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Innodb
4
- VERSION = "0.8.5"
4
+ VERSION = "0.8.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innodb_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-30 00:00:00.000000000 Z
13
+ date: 2014-02-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bindata