Sha256: 264796cef1b1a83d4d0040f499632f1a8c6c4a2a15513719a1c4c946b49560d1

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

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

require 'digest/sha1'

require 'rubyrep'

module RR
  
  # This class is used to scan a given table range 
  # Can return rows either themselves or only their checksum
  class ProxyRowCursor < ProxyCursor
    
    # The column_name => value hash of the current row.
    attr_accessor :current_row
    
    # Creates a new cursor
    #   * session: the current proxy session
    #   * table: table_name
    def initialize(session, table)
      super
    end
    
    # Returns true if there are unprocessed rows in the table range
    def next?
      cursor.next?
    end
    
    # Returns the next row in cursor
    def next_row
      cursor.next_row
    end
    
    # Returns for the next row
    #   * a hash of :column_name => value pairs of the primary keys
    #   * checksum string for that row
    def next_row_keys_and_checksum
      self.current_row = cursor.next_row
      keys = self.current_row.reject {|key, | not primary_key_names.include? key}
      checksum = Digest::SHA1.hexdigest(Marshal.dump(self.current_row))
      return keys, checksum
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rubyrep-2.0.1 lib/rubyrep/proxy_row_cursor.rb
rubyrep-2.0.0 lib/rubyrep/proxy_row_cursor.rb
andyjeffries-rubyrep-1.2.1 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.2.0 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.1.2 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.1.1 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.1.0 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.9 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.8 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.3 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.4 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.5 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.6 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.7 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.0 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.1 lib/rubyrep/proxy_row_cursor.rb
rubyrep-1.0.2 lib/rubyrep/proxy_row_cursor.rb