Class: RR::ProxyRowCursor

Inherits:
ProxyCursor show all
Defined in:
lib/rubyrep/proxy_row_cursor.rb

Overview

This class is used to scan a given table range Can return rows either themselves or only their checksum

Instance Attribute Summary collapse

Attributes inherited from ProxyCursor

#connection, #cursor, #primary_key_names, #table

Instance Method Summary collapse

Methods inherited from ProxyCursor

#destroy, #prepare_fetch

Constructor Details

#initialize(session, table) ⇒ ProxyRowCursor

Creates a new cursor

* session: the current proxy session
* table: table_name


19
20
21
# File 'lib/rubyrep/proxy_row_cursor.rb', line 19

def initialize(session, table)
  super
end

Instance Attribute Details

#current_rowObject

The column_name => value hash of the current row.



14
15
16
# File 'lib/rubyrep/proxy_row_cursor.rb', line 14

def current_row
  @current_row
end

Instance Method Details

#next?Boolean

Returns true if there are unprocessed rows in the table range

Returns:

  • (Boolean)


24
25
26
# File 'lib/rubyrep/proxy_row_cursor.rb', line 24

def next?
  cursor.next?
end

#next_rowObject

Returns the next row in cursor



29
30
31
# File 'lib/rubyrep/proxy_row_cursor.rb', line 29

def next_row
  cursor.next_row
end

#next_row_keys_and_checksumObject

Returns for the next row

* a hash of :column_name => value pairs of the primary keys
* checksum string for that row


36
37
38
39
40
41
# File 'lib/rubyrep/proxy_row_cursor.rb', line 36

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