Class: Shiba::IndexStats::Table
- Inherits:
-
Struct
- Object
- Struct
- Shiba::IndexStats::Table
- Defined in:
- lib/shiba/index_stats.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#indexes ⇒ Object
Returns the value of attribute indexes.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add_index_column(index_name, column_name, rows_per, cardinality, is_unique) ⇒ Object
- #build_index(index_name, is_unique) ⇒ Object
- #column_sizes ⇒ Object
- #encode_with(coder) ⇒ Object
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count
25 26 27 |
# File 'lib/shiba/index_stats.rb', line 25 def count @count end |
#indexes ⇒ Object
Returns the value of attribute indexes
25 26 27 |
# File 'lib/shiba/index_stats.rb', line 25 def indexes @indexes end |
#name ⇒ Object
Returns the value of attribute name
25 26 27 |
# File 'lib/shiba/index_stats.rb', line 25 def name @name end |
Instance Method Details
#add_index_column(index_name, column_name, rows_per, cardinality, is_unique) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/shiba/index_stats.rb', line 43 def add_index_column(index_name, column_name, rows_per, cardinality, is_unique) index = build_index(index_name, is_unique) index.columns << Column.new(column_name, index, rows_per, cardinality) if is_unique && !self.count # set row count from unique index self.count = cardinality end end |
#build_index(index_name, is_unique) ⇒ Object
39 40 41 |
# File 'lib/shiba/index_stats.rb', line 39 def build_index(index_name, is_unique) self.indexes[index_name] ||= Index.new(self, index_name, [], is_unique) end |
#column_sizes ⇒ Object
53 54 55 |
# File 'lib/shiba/index_stats.rb', line 53 def column_sizes @column_sizes ||= {} end |
#encode_with(coder) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shiba/index_stats.rb', line 26 def encode_with(coder) if self.count.nil? #uuuugly. No unique keys. we'll take our best guess. self.count = indexes.map { |i, parts| parts.columns.map { |v| v.raw_cardinality } }.flatten.max end coder.map = self.to_h.stringify_keys coder.map.delete('name') coder.map['column_sizes'] = column_sizes coder.tag = nil end |