Class: RR::TableScan
- Inherits:
-
Object
- Object
- RR::TableScan
- Includes:
- TableScanHelper
- Defined in:
- lib/rubyrep/table_scan.rb
Overview
Shared functionality for DirectTableScan and ProxiedTableScan
Direct Known Subclasses
Instance Attribute Summary collapse
-
#left_table ⇒ Object
Name of the left table.
-
#primary_key_names ⇒ Object
Cached array of primary key names.
-
#progress_printer ⇒ Object
Receives the active ScanProgressPrinters class.
-
#right_table ⇒ Object
Name of the right table.
-
#session ⇒ Object
The current Session object.
Instance Method Summary collapse
-
#initialize(session, left_table, right_table = nil) ⇒ TableScan
constructor
Creates a new DirectTableScan instance * session: a Session object representing the current database session * left_table: name of the table in the left database * right_table: name of the table in the right database.
-
#scan_options ⇒ Object
Returns a hash of scan options for this table scan.
-
#update_progress(steps) ⇒ Object
Inform new progress to progress printer
steps
is the number of processed records.
Methods included from TableScanHelper
Constructor Details
#initialize(session, left_table, right_table = nil) ⇒ TableScan
Creates a new DirectTableScan instance
* session: a Session object representing the current database session
* left_table: name of the table in the left database
* right_table: name of the table in the right database. If not given, same like left_table
44 45 46 47 48 49 50 51 52 |
# File 'lib/rubyrep/table_scan.rb', line 44 def initialize(session, left_table, right_table = nil) if session.left.primary_key_names(left_table).empty? raise "Table '#{left_table}' doesn't have a primary key. Cannot scan." end self.session, self.left_table, self.right_table = session, left_table, right_table self.right_table ||= self.left_table self.primary_key_names = session.left.primary_key_names left_table end |
Instance Attribute Details
#left_table ⇒ Object
Name of the left table
11 12 13 |
# File 'lib/rubyrep/table_scan.rb', line 11 def left_table @left_table end |
#primary_key_names ⇒ Object
Cached array of primary key names
17 18 19 |
# File 'lib/rubyrep/table_scan.rb', line 17 def primary_key_names @primary_key_names end |
#progress_printer ⇒ Object
Receives the active ScanProgressPrinters class
20 21 22 |
# File 'lib/rubyrep/table_scan.rb', line 20 def progress_printer @progress_printer end |
#right_table ⇒ Object
Name of the right table
14 15 16 |
# File 'lib/rubyrep/table_scan.rb', line 14 def right_table @right_table end |
#session ⇒ Object
The current Session object
8 9 10 |
# File 'lib/rubyrep/table_scan.rb', line 8 def session @session end |
Instance Method Details
#scan_options ⇒ Object
Returns a hash of scan options for this table scan.
23 24 25 |
# File 'lib/rubyrep/table_scan.rb', line 23 def @scan_options ||= session.configuration.(left_table) end |
#update_progress(steps) ⇒ Object
Inform new progress to progress printer steps
is the number of processed records.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubyrep/table_scan.rb', line 29 def update_progress(steps) return unless progress_printer unless @progress_printer_instance total_records = session.left.select_one("select count(*) as n from #{session.left.quote_table_name(left_table)}")['n'].to_i + session.right.select_one("select count(*) as n from #{session.right.quote_table_name(right_table)}")['n'].to_i @progress_printer_instance = progress_printer.new(total_records, session, left_table, right_table) end @progress_printer_instance.step(steps) end |