Sha256: ce431a6d7ec9c755279edb905f3d5c81d2a750e98acc3190a722e346cc4b434c

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

$LOAD_PATH.unshift File.dirname(__FILE__) + '/..'

require 'rubyrep'

module RR
  
  # Some helper functions that are of use to all TableScan classes
  module TableScanHelper
    # Compares the primary keys of left_row and right_row to determine their rank.
    # Assumes there is a function primary_key_names returning the array of primary keys
    # that are relevant for this comparison
    # 
    # Assumes that at least one of left_row and right_row is not nil
    # A nil row counts as infinite. 
    # E. g. left_row is something and right_row is nil ==> left_row is smaller ==> return -1
    def rank_rows(left_row, right_row)
      raise "At least one of left_row and right_row must not be nil!" unless left_row or right_row
      return -1 unless right_row
      return 1 unless left_row 
      rank = 0
      primary_key_names.any? do |key|
        rank = left_row[key] <=> right_row[key]
        rank != 0
      end
      rank
    end

    # Returns the correct class for the table scan based on the type of the
    # session (proxied or direct).
    def self.scan_class(session)
      if session.proxied?
        ProxiedTableScan
      else
        DirectTableScan
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubyrep-1.1.2 lib/rubyrep/table_scan_helper.rb
rubyrep-1.1.1 lib/rubyrep/table_scan_helper.rb
rubyrep-1.1.0 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.9 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.8 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.3 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.4 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.5 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.6 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.7 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.2 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.1 lib/rubyrep/table_scan_helper.rb
rubyrep-1.0.0 lib/rubyrep/table_scan_helper.rb