Class: Chicago::ETL::HashingKeyBuilder Private

Inherits:
KeyBuilder
  • Object
show all
Defined in:
lib/chicago/etl/key_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Key builder for dimensions with natuaral keys, but no simple key.

This should not be instantiated directly, use KeyBuilder.for_dimension.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from KeyBuilder

for_table, #key

Constructor Details

#initialize(key_table, columns) ⇒ HashingKeyBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of HashingKeyBuilder.



166
167
168
169
170
# File 'lib/chicago/etl/key_builder.rb', line 166

def initialize(key_table, columns)
  super(key_table)
  @columns = columns
  @hash_preparation = lambda {|column| column.to_s.upcase }
end

Instance Attribute Details

#columnsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



163
164
165
# File 'lib/chicago/etl/key_builder.rb', line 163

def columns
  @columns
end

#hash_preparationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



164
165
166
# File 'lib/chicago/etl/key_builder.rb', line 164

def hash_preparation
  @hash_preparation
end

Instance Method Details

#original_key(row) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



172
173
174
175
# File 'lib/chicago/etl/key_builder.rb', line 172

def original_key(row)
  str = columns.map {|column| hash_preparation.call(row[column]) }.join
  Digest::MD5.hexdigest(str).upcase
end

#original_key_select_fragmentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



177
178
179
# File 'lib/chicago/etl/key_builder.rb', line 177

def original_key_select_fragment
  :hex.sql_function(:original_id).as(:original_id)
end