Class: StructuredDataToSql::Json::TableProfile
- Inherits:
-
Object
- Object
- StructuredDataToSql::Json::TableProfile
- Defined in:
- lib/structured_data_to_sql/json/schema_inferrer.rb
Overview
Column profiles for one table, in first-observation order.
Instance Attribute Summary collapse
-
#row_count ⇒ Object
readonly
Returns the value of attribute row_count.
-
#table_rel ⇒ Object
readonly
Returns the value of attribute table_rel.
Instance Method Summary collapse
- #child? ⇒ Boolean
- #finalize ⇒ Object
-
#initialize(table_rel, raw_dates: false) ⇒ TableProfile
constructor
A new instance of TableProfile.
- #observe_row(columns) ⇒ Object
Constructor Details
#initialize(table_rel, raw_dates: false) ⇒ TableProfile
Returns a new instance of TableProfile.
105 106 107 108 109 110 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 105 def initialize(table_rel, raw_dates: false) @table_rel = table_rel @raw_dates = raw_dates @columns = {} @row_count = 0 end |
Instance Attribute Details
#row_count ⇒ Object (readonly)
Returns the value of attribute row_count.
103 104 105 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 103 def row_count @row_count end |
#table_rel ⇒ Object (readonly)
Returns the value of attribute table_rel.
103 104 105 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 103 def table_rel @table_rel end |
Instance Method Details
#child? ⇒ Boolean
121 122 123 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 121 def child? !@table_rel.empty? end |
#finalize ⇒ Object
125 126 127 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 125 def finalize @columns.map { |name, profile| profile.finalize(name, @row_count) } end |
#observe_row(columns) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 112 def observe_row(columns) @row_count += 1 columns.each do |name, value| (@columns[name] ||= ColumnProfile.new(raw_dates: @raw_dates)).observe( value ) end end |