<commit_before>require 'benchmark'

require File.dirname(__FILE__) + '/../../spec/spec_helper.rb'
require File.dirname(__FILE__) + '/../sim_helper'

include RR

describe "Big Scan" do
  before(:each) do
  end

  # Runs a scan of the big_scan table using the provided Scanner class
  def run_scan(table_scan_class)
    session = Session.new
    expected_result = {}
    expected_result[:conflict] = session.left.select_one( \
        "select count(id) as count from big_scan where diff_type = 'conflict'")['count'].to_i
    expected_result[:left] = session.left.select_one( \
        "select count(id) as count from big_scan where diff_type = 'left'")['count'].to_i
    expected_result[:right] = session.right.select_one( \
        "select count(id) as count from big_scan where diff_type = 'right'")['count'].to_i
    
    number_records = session.left.select_one( \
        "select count(id) as count from big_scan")['count'].to_i \
      + expected_result[:right]
    number_differences = expected_result.values.inject {|sum, n| sum + n }
    received_result = {:conflict => 0, :left => 0, :right => 0}
      
    puts "\nScanning table big_scan (#{number_differences} differences in #{number_records} records) using #{table_scan_class.name}"
    progress_bar = ProgressBar.new number_differences

    scan = table_scan_class.new session, 'big_scan'
    benchmark = Benchmark.measure {
      scan.run do |diff_type, row|
        progress_bar.step
        received_result[diff_type] += 1
      end
    }
    puts "  time required: #{benchmark}"
    
    received_result.should == expected_result
  end
  
  it "ProxiedTableScan should identify differences between big_scan tables correctly" do
    Initializer.configuration = deep_copy(proxied_config)
    Initializer.configuration.proxy_options[:block_size] = 100
    ensure_proxy
    
    run_scan ProxiedTableScan
  end

  it "DirectTableScan should identify differences between big_scan tables correctly" do
    Initializer.configuration = standard_config
    
    run_scan DirectTableScan
  end
end<commit_msg>Dried up big_scan to use TableScanHelper.scan_class.<commit_after>require 'benchmark'

require File.dirname(__FILE__) + '/../../spec/spec_helper.rb'
require File.dirname(__FILE__) + '/../sim_helper'

include RR

describe "Big Scan" do
  before(:each) do
  end

  # Runs a scan of the big_scan table
  def run_scan
    session = Session.new
    expected_result = {}
    expected_result[:conflict] = session.left.select_one( \
        "select count(id) as count from big_scan where diff_type = 'conflict'")['count'].to_i
    expected_result[:left] = session.left.select_one( \
        "select count(id) as count from big_scan where diff_type = 'left'")['count'].to_i
    expected_result[:right] = session.right.select_one( \
        "select count(id) as count from big_scan where diff_type = 'right'")['count'].to_i
    
    number_records = session.left.select_one( \
        "select count(id) as count from big_scan")['count'].to_i \
      + expected_result[:right]
    number_differences = expected_result.values.inject {|sum, n| sum + n }
    received_result = {:conflict => 0, :left => 0, :right => 0}

    table_scan_class = TableScanHelper.scan_class(session)
    puts "\nScanning table big_scan (#{number_differences} differences in #{number_records} records) using #{table_scan_class.name}"
    progress_bar = ProgressBar.new number_differences

    scan = table_scan_class.new session, 'big_scan'
    benchmark = Benchmark.measure {
      scan.run do |diff_type, row|
        progress_bar.step
        received_result[diff_type] += 1
      end
    }
    puts "  time required: #{benchmark}"
    
    received_result.should == expected_result
  end
  
  it "ProxiedTableScan should identify differences between big_scan tables correctly" do
    Initializer.configuration = deep_copy(proxied_config)
    Initializer.configuration.proxy_options[:block_size] = 100
    ensure_proxy
    
    run_scan
  end

  it "DirectTableScan should identify differences between big_scan tables correctly" do
    Initializer.configuration = standard_config
    
    run_scan
  end
end
{'fraction_non_alphanumeric': 0.10193236714975845, 'fraction_numerical': 0.003381642512077295, 'mean_word_length': 3.6268156424581006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2989273', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1251, 'n_words': 315}