innodb_ruby 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4fb0470eeceb5fbe16a858c30310c5046a8d2512
4
+ data.tar.gz: f9396fbc702f8b4be752c8300f9dc7cb47317cc2
5
+ SHA512:
6
+ metadata.gz: 001c98d6754675ecfa62f6e93562fc3c398ecfe9f18c869a0685816102dc8d37b0001ebbca317c3aaa0da75616fa5e7669eb537afcad548f301ec61329988f02
7
+ data.tar.gz: 2ea7115e3ca1fabfa606789ca645605feca86a4bedb5b1fc3dc5a8369d6bd46b653990eb35d70f0b5ee785f77e6983ef9609ebc7e508c89cd0174bdffc1523bf
File without changes
@@ -339,6 +339,10 @@ def space_index_pages_summary(space, start_page)
339
339
  print_index_page_summary(space.each_page(start_page))
340
340
  end
341
341
 
342
+ def space_index_fseg_pages_summary(space, fseg_id)
343
+ print_index_page_summary(space.inode(fseg_id).each_page)
344
+ end
345
+
342
346
  def space_page_type_regions(space, start_page)
343
347
  puts "%-12s%-12s%-12s%-20s" % [
344
348
  "start",
@@ -413,11 +417,12 @@ def space_list_iterate(space, list_name)
413
417
  end
414
418
 
415
419
  def space_indexes(innodb_system, space)
416
- puts "%-12s%-32s%-12s%-12s%-12s%-12s%-12s" % [
420
+ puts "%-12s%-32s%-12s%-12s%-12s%-12s%-12s%-12s" % [
417
421
  "id",
418
422
  "name",
419
423
  "root",
420
424
  "fseg",
425
+ "fseg_id",
421
426
  "used",
422
427
  "allocated",
423
428
  "fill_factor",
@@ -425,11 +430,12 @@ def space_indexes(innodb_system, space)
425
430
 
426
431
  space.each_index do |index|
427
432
  index.each_fseg do |fseg_name, fseg|
428
- puts "%-12i%-32s%-12i%-12s%-12i%-12i%-12s" % [
433
+ puts "%-12i%-32s%-12i%-12s%-12i%-12i%-12i%-12s" % [
429
434
  index.id,
430
435
  innodb_system ? innodb_system.index_name_by_id(index.id) : "",
431
436
  index.root.offset,
432
437
  fseg_name,
438
+ fseg.fseg_id,
433
439
  fseg.used_pages,
434
440
  fseg.total_pages,
435
441
  "%.2f%%" % fseg.fill_factor,
@@ -987,6 +993,12 @@ def print_inode_detail(inode)
987
993
  ]
988
994
  end
989
995
 
996
+ def space_inodes_fseg_id(space)
997
+ space.each_inode do |inode|
998
+ puts inode.fseg_id
999
+ end
1000
+ end
1001
+
990
1002
  def space_inodes_summary(space)
991
1003
  space.each_inode do |inode|
992
1004
  print_inode_summary(inode)
@@ -1310,7 +1322,8 @@ end
1310
1322
 
1311
1323
  def page_illustrate(page)
1312
1324
  width = 64
1313
- blocks = Array.new(page.size, " ")
1325
+ unknown_page_content = page.type == :INDEX && page.record_describer.nil?
1326
+ blocks = Array.new(page.size, unknown_page_content ? "▞" : " ")
1314
1327
  identifiers = {}
1315
1328
  identifier_sort = 0
1316
1329
  count_by_identifier = Hash.new(0)
@@ -1373,12 +1386,19 @@ def page_illustrate(page)
1373
1386
  ]
1374
1387
  free_space = page.size - count_by_identifier.inject(0) { |sum,(k,v)| sum + v }
1375
1388
  puts " %s %-30s %8i %7.2f%%" % [
1376
- " ",
1377
- "Free",
1389
+ unknown_page_content ? "▞" : " ",
1390
+ unknown_page_content ? "Unknown (no data dictionary)" : "Free",
1378
1391
  free_space,
1379
1392
  100.0 * (free_space.to_f / page.size.to_f),
1380
1393
  ]
1381
1394
 
1395
+ if unknown_page_content
1396
+ puts
1397
+ puts "Note:"
1398
+ puts " Records could not be parsed because no data dictionary or record describer"
1399
+ puts " was available. Use -s instead of -f, or provide a record describer class."
1400
+ end
1401
+
1382
1402
  puts
1383
1403
  end
1384
1404
 
@@ -1639,6 +1659,9 @@ The following options are supported:
1639
1659
  --list, -L <list>
1640
1660
  Operate on the list <list>.
1641
1661
 
1662
+ --fseg-id, -F <fseg_id>
1663
+ Operate on the file segment (fseg) <fseg_id>.
1664
+
1642
1665
  --require, -r <file>
1643
1666
  Use Ruby's "require" to load the file <file>. This is useful for loading
1644
1667
  classes with record describers.
@@ -1673,6 +1696,10 @@ The following modes are supported:
1673
1696
  "ALLOCATED" pages are also printed and assumed to be completely empty.
1674
1697
  A starting page number can be provided with the --page/-p argument.
1675
1698
 
1699
+ space-index-fseg-pages-summary
1700
+ The same as space-index-pages-summary but only iterate one fseg, provided
1701
+ with the --fseg-id/-F argument.
1702
+
1676
1703
  space-index-pages-free-plot
1677
1704
  Use Ruby's gnuplot module to produce a scatterplot of page free space for
1678
1705
  all "INDEX" and "ALLOCATED" pages in a tablespace. More aesthetically
@@ -1721,6 +1748,9 @@ The following modes are supported:
1721
1748
  producing SVG format output, allowing the user to get an overview of page
1722
1749
  modification recency.
1723
1750
 
1751
+ space-inodes-fseg-id
1752
+ Iterate through all inodes, printing only the FSEG ID.
1753
+
1724
1754
  space-inodes-summary
1725
1755
  Iterate through all inodes, printing a short summary of each FSEG.
1726
1756
 
@@ -1814,6 +1844,7 @@ Signal.trap("PIPE") { exit }
1814
1844
  @options.record = nil
1815
1845
  @options.level = nil
1816
1846
  @options.list = nil
1847
+ @options.fseg_id = nil
1817
1848
  @options.describer = nil
1818
1849
  @options.illustration_line_width = 64
1819
1850
  @options.illustration_block_size = 8
@@ -1829,6 +1860,7 @@ getopt_options = [
1829
1860
  [ "--record", "-R", GetoptLong::REQUIRED_ARGUMENT ],
1830
1861
  [ "--level", "-l", GetoptLong::REQUIRED_ARGUMENT ],
1831
1862
  [ "--list", "-L", GetoptLong::REQUIRED_ARGUMENT ],
1863
+ [ "--fseg-id", "-F", GetoptLong::REQUIRED_ARGUMENT ],
1832
1864
  [ "--require", "-r", GetoptLong::REQUIRED_ARGUMENT ],
1833
1865
  [ "--describer", "-d", GetoptLong::REQUIRED_ARGUMENT ],
1834
1866
  [ "--illustration-line-width", GetoptLong::REQUIRED_ARGUMENT ],
@@ -1859,6 +1891,8 @@ getopt.each do |opt, arg|
1859
1891
  @options.level = arg.to_i
1860
1892
  when "--list"
1861
1893
  @options.list = arg.to_sym
1894
+ when "--fseg-id"
1895
+ @options.fseg_id = arg.to_i
1862
1896
  when "--require"
1863
1897
  require File.expand_path(arg)
1864
1898
  when "--describer"
@@ -1967,6 +2001,10 @@ if [
1967
2001
  usage 1, "Record describer must be specified using -d/--describer"
1968
2002
  end
1969
2003
 
2004
+ if ["space-index-fseg-pages-summary"].include?(mode) and !@options.fseg_id
2005
+ usage 1, "File segment id must be specified using -F/--fseg-id"
2006
+ end
2007
+
1970
2008
  if @options.trace > 0
1971
2009
  BufferCursor.trace!
1972
2010
  end
@@ -1986,6 +2024,8 @@ when "space-summary"
1986
2024
  space_summary(space, @options.page || 0)
1987
2025
  when "space-index-pages-summary"
1988
2026
  space_index_pages_summary(space, @options.page || 0)
2027
+ when "space-index-fseg-pages-summary"
2028
+ space_index_fseg_pages_summary(space, @options.fseg_id)
1989
2029
  when "space-index-pages-free-plot"
1990
2030
  file_name = space.name.sub(".ibd", "").sub(/[^a-zA-Z0-9_]/, "_")
1991
2031
  space_index_pages_free_plot(space, file_name, @options.page || 0)
@@ -2009,6 +2049,8 @@ when "space-lsn-age-illustrate"
2009
2049
  space_lsn_age_illustrate(space)
2010
2050
  when "space-lsn-age-illustrate-svg"
2011
2051
  space_lsn_age_illustrate_svg(space)
2052
+ when "space-inodes-fseg-id"
2053
+ space_inodes_fseg_id(space)
2012
2054
  when "space-inodes-summary"
2013
2055
  space_inodes_summary(space)
2014
2056
  when "space-inodes-detail"
@@ -7,14 +7,14 @@ class Innodb::Checksum
7
7
 
8
8
  # This is derived from ut_fold_ulint_pair in include/ut0rnd.ic in the
9
9
  # InnoDB source code. Since Ruby's Bignum class is *much* slower than its
10
- # Fixnum class, we mask back to 32 bits to keep things from overflowing
10
+ # Integer class, we mask back to 32 bits to keep things from overflowing
11
11
  # and being promoted to Bignum.
12
12
  def self.fold_pair(n1, n2)
13
13
  (((((((n1 ^ n2 ^ MASK2) << 8) & MAX) + n1) & MAX) ^ MASK1) + n2) & MAX
14
14
  end
15
15
 
16
16
  # Iterate through the provided enumerator, which is expected to return a
17
- # Fixnum (or something coercible to it), and "fold" them together to produce
17
+ # Integer (or something coercible to it), and "fold" them together to produce
18
18
  # a single value.
19
19
  def self.fold_enumerator(enumerator)
20
20
  fold = 0
@@ -129,11 +129,12 @@ class Innodb::DataType
129
129
  end
130
130
 
131
131
  frac << get_digits(stream, mask, @comp_fractional)
132
+ frac = "0" if frac.empty?
132
133
 
133
134
  # Convert to something resembling a string representation.
134
135
  str = mask.to_s.chop + intg + '.' + frac
135
136
 
136
- BigDecimal.new(str).to_s('F')
137
+ BigDecimal(str).to_s('F')
137
138
  end
138
139
 
139
140
  private
@@ -127,9 +127,52 @@ class Innodb::Inode
127
127
 
128
128
  # Iterate through all lists, yielding the list name and the list itself.
129
129
  def each_list
130
+ unless block_given?
131
+ return enum_for(:each_list)
132
+ end
133
+
130
134
  lists.each do |name|
131
135
  yield name, list(name)
132
136
  end
137
+
138
+ nil
139
+ end
140
+
141
+ # Iterate through the fragment array followed by all lists, yielding the
142
+ # page number. This allows a convenient way to identify all pages that are
143
+ # part of this inode.
144
+ def each_page_number
145
+ unless block_given?
146
+ return enum_for(:each_page_number)
147
+ end
148
+
149
+ frag_array_pages.each do |page_number|
150
+ yield page_number
151
+ end
152
+
153
+ each_list do |fseg_name, fseg_list|
154
+ fseg_list.each do |xdes|
155
+ xdes.each_page_status do |page_number|
156
+ yield page_number
157
+ end
158
+ end
159
+ end
160
+
161
+ nil
162
+ end
163
+
164
+ # Iterate through the page as associated with this inode using the
165
+ # each_page_number method, and yield the page number and page.
166
+ def each_page
167
+ unless block_given?
168
+ return enum_for(:each_page)
169
+ end
170
+
171
+ each_page_number do |page_number|
172
+ yield page_number, space.page(page_number)
173
+ end
174
+
175
+ nil
133
176
  end
134
177
 
135
178
  # Compare one Innodb::Inode to another.
@@ -13,10 +13,6 @@ class Innodb::Record
13
13
  record[:header]
14
14
  end
15
15
 
16
- def next
17
- header[:next]
18
- end
19
-
20
16
  def type
21
17
  header[:type]
22
18
  end
@@ -379,6 +379,12 @@ class Innodb::Space
379
379
  end
380
380
  end
381
381
 
382
+ # Return an Inode by fseg_id. Iterates through the inode list, but it
383
+ # normally is fairly small, so should be relatively efficient.
384
+ def inode(fseg_id)
385
+ each_inode.select { |inode| inode.fseg_id == fseg_id }.first
386
+ end
387
+
382
388
  # Iterate through the page numbers in the doublewrite buffer.
383
389
  def each_doublewrite_page_number
384
390
  return nil unless system_space?
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module Innodb
4
- VERSION = "0.9.15"
4
+ VERSION = "0.9.16"
5
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innodb_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.15
5
- prerelease:
4
+ version: 0.9.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy Cole
@@ -10,38 +9,46 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2016-09-21 00:00:00.000000000 Z
12
+ date: 2019-07-28 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bindata
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.4'
21
+ - - ">="
21
22
  - !ruby/object:Gem::Version
22
23
  version: 1.4.5
23
24
  type: :runtime
24
25
  prerelease: false
25
26
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
27
  requirements:
28
- - - ! '>='
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '1.4'
31
+ - - ">="
29
32
  - !ruby/object:Gem::Version
30
33
  version: 1.4.5
31
34
  - !ruby/object:Gem::Dependency
32
35
  name: digest-crc
33
36
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
37
  requirements:
36
- - - ! '>='
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
41
+ - - ">="
37
42
  - !ruby/object:Gem::Version
38
43
  version: 0.4.1
39
44
  type: :runtime
40
45
  prerelease: false
41
46
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
47
  requirements:
44
- - - ! '>='
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '0.4'
51
+ - - ">="
45
52
  - !ruby/object:Gem::Version
46
53
  version: 0.4.1
47
54
  description: Library for parsing InnoDB data files in Ruby
@@ -52,9 +59,11 @@ executables:
52
59
  extensions: []
53
60
  extra_rdoc_files: []
54
61
  files:
55
- - LICENSE
56
62
  - AUTHORS.md
63
+ - LICENSE
57
64
  - README.md
65
+ - bin/innodb_log
66
+ - bin/innodb_space
58
67
  - lib/innodb.rb
59
68
  - lib/innodb/checksum.rb
60
69
  - lib/innodb/data_dictionary.rb
@@ -68,12 +77,12 @@ files:
68
77
  - lib/innodb/index.rb
69
78
  - lib/innodb/inode.rb
70
79
  - lib/innodb/list.rb
71
- - lib/innodb/lsn.rb
72
80
  - lib/innodb/log.rb
73
81
  - lib/innodb/log_block.rb
74
82
  - lib/innodb/log_group.rb
75
- - lib/innodb/log_record.rb
76
83
  - lib/innodb/log_reader.rb
84
+ - lib/innodb/log_record.rb
85
+ - lib/innodb/lsn.rb
77
86
  - lib/innodb/page.rb
78
87
  - lib/innodb/page/blob.rb
79
88
  - lib/innodb/page/fsp_hdr_xdes.rb
@@ -98,31 +107,28 @@ files:
98
107
  - lib/innodb/util/read_bits_at_offset.rb
99
108
  - lib/innodb/version.rb
100
109
  - lib/innodb/xdes.rb
101
- - bin/innodb_log
102
- - bin/innodb_space
103
110
  homepage: https://github.com/jeremycole/innodb_ruby
104
111
  licenses:
105
- - New BSD (3-clause)
112
+ - BSD-3-Clause
113
+ metadata: {}
106
114
  post_install_message:
107
115
  rdoc_options: []
108
116
  require_paths:
109
117
  - lib
110
118
  required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
119
  requirements:
113
- - - ! '>='
120
+ - - ">="
114
121
  - !ruby/object:Gem::Version
115
122
  version: '0'
116
123
  required_rubygems_version: !ruby/object:Gem::Requirement
117
- none: false
118
124
  requirements:
119
- - - ! '>='
125
+ - - ">="
120
126
  - !ruby/object:Gem::Version
121
127
  version: '0'
122
128
  requirements: []
123
129
  rubyforge_project:
124
- rubygems_version: 1.8.23
130
+ rubygems_version: 2.5.2.3
125
131
  signing_key:
126
- specification_version: 3
132
+ specification_version: 4
127
133
  summary: InnoDB data file parser
128
134
  test_files: []