Class: Shiba::Fuzzer
- Inherits:
-
Object
- Object
- Shiba::Fuzzer
- Defined in:
- lib/shiba/fuzzer.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #fetch_index ⇒ Object
- #fuzz! ⇒ Object
-
#initialize(connection) ⇒ Fuzzer
constructor
A new instance of Fuzzer.
Constructor Details
#initialize(connection) ⇒ Fuzzer
Returns a new instance of Fuzzer.
6 7 8 |
# File 'lib/shiba/fuzzer.rb', line 6 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/shiba/fuzzer.rb', line 10 def connection @connection end |
Instance Method Details
#fetch_index ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/shiba/fuzzer.rb', line 28 def fetch_index stats = Shiba::IndexStats.new records = connection.fetch_indexes tables = {} records.each do |h| h.keys.each { |k| h[k.downcase] = h.delete(k) } h["cardinality"] = h["cardinality"].to_i stats.add_index_column(h['table_name'], h['index_name'], h['column_name'], h['cardinality'], h['non_unique'] == 0) end connection.each_column_size do |table, column, size| stats.set_column_size(table, column, size) end stats end |
#fuzz! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shiba/fuzzer.rb', line 12 def fuzz! @index_stats = fetch_index table_sizes = guess_table_sizes @index_stats.tables.each do |name, table| table.count = table_sizes[name] table.indexes.each do |name, index| index.columns.each do |column| column.rows_per = index.unique ? 1 : 2 end end end @index_stats end |