Class: NoSE::Loader::MysqlLoader
- Inherits:
-
LoaderBase
- Object
- LoaderBase
- NoSE::Loader::MysqlLoader
- Defined in:
- lib/nose/loader/mysql.rb
Overview
Load data from a MySQL database into a backend
Instance Method Summary collapse
-
#initialize(workload = nil, backend = nil) ⇒ MysqlLoader
constructor
A new instance of MysqlLoader.
-
#load(indexes, config, show_progress = false, limit = nil, skip_existing = true) ⇒ Object
Load a generated set of indexes with data from MySQL.
-
#workload(config) ⇒ Object
Read all tables in the database and construct a workload object.
Methods inherited from LoaderBase
Constructor Details
#initialize(workload = nil, backend = nil) ⇒ MysqlLoader
Returns a new instance of MysqlLoader.
15 16 17 18 19 20 |
# File 'lib/nose/loader/mysql.rb', line 15 def initialize(workload = nil, backend = nil) @logger = Logging.logger['nose::loader::mysqlloader'] @workload = workload @backend = backend end |
Instance Method Details
#load(indexes, config, show_progress = false, limit = nil, skip_existing = true) ⇒ Object
Load a generated set of indexes with data from MySQL
23 24 25 26 27 28 29 30 31 |
# File 'lib/nose/loader/mysql.rb', line 23 def load(indexes, config, show_progress = false, limit = nil, skip_existing = true) indexes.map!(&:to_id_graph).uniq! if @backend.by_id_graph # XXX Assuming backend is thread-safe Parallel.each(indexes, in_threads: 2) do |index| load_index index, config, show_progress, limit, skip_existing end end |
#workload(config) ⇒ Object
Read all tables in the database and construct a workload object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nose/loader/mysql.rb', line 34 def workload(config) client = new_client config workload = Workload.new results = if @array_options client.query('SHOW TABLES').each(**@array_options) else client.query('SHOW TABLES').each end results.each do |table, *| # TODO: Handle foreign keys workload << entity_for_table(client, table) end workload end |