Module: Voltdb::VoltTableRowUtils

Defined in:
lib/voltdb/volt_table_row_utils.rb

Instance Method Summary collapse

Instance Method Details

#get_long_as_boolean(column_index_or_name) ⇒ Boolean

Get a long value from a VoltTableRow as a boolean value

Parameters:

  • column_index_or_name (Fixnum, String)

Returns:

  • (Boolean)


8
9
10
# File 'lib/voltdb/volt_table_row_utils.rb', line 8

def get_long_as_boolean(column_index_or_name)
  self.get_long(column_index_or_name) == 1
end

#get_long_or_nil(column_index_or_name) ⇒ VoltType, Boolean

Get the value of the column or nil

Parameters:

  • column_index_or_name (Fixnum, String)

Returns:

  • (VoltType, Boolean)


16
17
18
19
20
# File 'lib/voltdb/volt_table_row_utils.rb', line 16

def get_long_or_nil(column_index_or_name)
  value = self.get_long(column_index_or_name)

  self.was_null? ? nil : value
end

#get_timestamp_as_ruby_date(column_index_or_name) ⇒ Date

Get a Ruby Date from a VoltTableRow timestamp type value

Parameters:

  • column_index_or_name (Fixnum, String)

Returns:

  • (Date)


36
37
38
39
40
# File 'lib/voltdb/volt_table_row_utils.rb', line 36

def get_timestamp_as_ruby_date(column_index_or_name)
  timestamp = get_timestamp_for_ruby(column_index_or_name)

  timestamp ? Date.parse(timestamp.to_s) : timestamp
end

#get_timestamp_as_ruby_date_time(column_index_or_name) ⇒ DateTime

Get a Ruby DateTime from a VoltTableRow timestamp type value

Parameters:

  • column_index_or_name (Fixnum, String)

Returns:

  • (DateTime)


26
27
28
29
30
# File 'lib/voltdb/volt_table_row_utils.rb', line 26

def get_timestamp_as_ruby_date_time(column_index_or_name)
  timestamp = get_timestamp_for_ruby(column_index_or_name)

  timestamp ? DateTime.parse(timestamp.to_s) : timestamp
end

#get_timestamp_as_ruby_time(column_index_or_name) ⇒ Time

Get a Ruby Time from a VoltTableRow timestamp type value

Parameters:

  • column_index_or_name (Fixnum, String)

Returns:

  • (Time)


46
47
48
49
50
# File 'lib/voltdb/volt_table_row_utils.rb', line 46

def get_timestamp_as_ruby_time(column_index_or_name)
  timestamp = get_timestamp_for_ruby(column_index_or_name)

  timestamp ? Time.parse(timestamp.to_s) : timestamp
end