Class: IncrementalCacheSQLResolver
- Inherits:
-
SQLResolver
- Object
- SQLResolver
- IncrementalCacheSQLResolver
- Defined in:
- lib/etl/transform/foreign_key_lookup_transform.rb
Instance Method Summary collapse
-
#initialize(atable, afield, connection = nil) ⇒ IncrementalCacheSQLResolver
constructor
A new instance of IncrementalCacheSQLResolver.
- #load_cache ⇒ Object
- #resolve(value) ⇒ Object
Methods inherited from SQLResolver
Constructor Details
#initialize(atable, afield, connection = nil) ⇒ IncrementalCacheSQLResolver
Returns a new instance of IncrementalCacheSQLResolver.
157 158 159 |
# File 'lib/etl/transform/foreign_key_lookup_transform.rb', line 157 def initialize(atable, afield, connection=nil) super end |
Instance Method Details
#load_cache ⇒ Object
174 175 176 |
# File 'lib/etl/transform/foreign_key_lookup_transform.rb', line 174 def load_cache @cache = {} end |
#resolve(value) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/etl/transform/foreign_key_lookup_transform.rb', line 161 def resolve(value) return nil if value.nil? r = cache[value] unless r q = "SELECT id FROM #{table_name} WHERE #{wheres(value)}" r = @connection.select_value(q) if r cache[value] = r end end r end |