Class: ConceptQL::Database
- Inherits:
-
Object
- Object
- ConceptQL::Database
- Defined in:
- lib/conceptql/database.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #db_opts ⇒ Object
- #extensions ⇒ Object
-
#initialize(db, opts = {}) ⇒ Database
constructor
A new instance of Database.
- #query(statement, opts = {}) ⇒ Object
Constructor Details
#initialize(db, opts = {}) ⇒ Database
Returns a new instance of Database.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/conceptql/database.rb', line 7 def initialize(db, opts={}) @db = db db_type = :impala if db extensions.each do |extension| db.extension extension end db_type = db.database_type.to_sym end @opts = opts.revalue { |v| v ? v.to_sym : v } @opts[:data_model] ||= :omopv4 @opts[:database_type] ||= db_type db.set(db_opts) if db.respond_to?(:set) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
5 6 7 |
# File 'lib/conceptql/database.rb', line 5 def db @db end |
Instance Method Details
#db_opts ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/conceptql/database.rb', line 27 def db_opts db_opts = {} if opts[:database_type] == :impala db_opts.merge!(runtime_filter_mode: "OFF") if mem_limit = (opts[:impala_mem_limit] || ENV['IMPALA_MEM_LIMIT']) db_opts.merge!(mem_limit: mem_limit) end end db_opts end |
#extensions ⇒ Object
38 39 40 |
# File 'lib/conceptql/database.rb', line 38 def extensions [:date_arithmetic, :error_sql] end |