Module: Voltdb::ClientResponseUtils

Defined in:
lib/voltdb/client_response_utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.map_client_response_result(client_response, index, validate_status = true) {|VoltTableRow| ... } ⇒ Array<Object, Object>

This method is used for mapping VoltTableRows to an object. It receives the index of the VoltTable that we want to map and a block that will be executed in that context

Parameters:

  • client_response (ClientResponseImpl)

    a voltdb ClientResponse interface implementation

  • index (Fixnum)

    VoltTable index

  • validate_status (Boolean) (defaults to: true)

    validate status of the client response

Yields:

  • (VoltTableRow)

Returns:

  • (Array<Object, Object>)


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

def self.map_client_response_result(client_response, index, validate_status = true, &block)
  validate_client_response_status(client_response) if (validate_status)
  VoltTableUtils.map_volt_table(client_response.get_results[index], &block)
end

.map_first_row_from_client_response_result(client_response, index, validate_status = true) {|VoltTableRow| ... } ⇒ Array<Object>

This method is used for mapping the first row from a VoltTableRow to an object. It receives the index of the VoltTable that we want to map and a block that will be executed in that context

Parameters:

  • client_response (ClientResponseImpl)

    a voltdb ClientResponse interface implementation

  • index (Fixnum)

    VoltTable index

  • validate_status (Boolean) (defaults to: true)

    validate status of the client response

Yields:

  • (VoltTableRow)

Returns:

  • (Array<Object>)


32
33
34
35
# File 'lib/voltdb/client_response_utils.rb', line 32

def self.map_first_row_from_client_response_result(client_response, index, validate_status = true, &block)
  validate_client_response_status(client_response) if (validate_status)
  VoltTableUtils.map_first_row_from_volt_table(client_response.get_results[index], &block)
end

.validate_client_response_status(client_response) ⇒ Object

Checks that the status of the client response is SUCCESS. If not, it throws an exception

Parameters:

  • client_response (ClientResponseImpl)

    a voltdb ClientResponse interface implementation

Returns:

  • the same client response passed in when its status is equal to ClientResponse.SUCCESS

Raises:



45
46
47
48
49
50
51
# File 'lib/voltdb/client_response_utils.rb', line 45

def self.validate_client_response_status(client_response)
  unless ClientResponse.SUCCESS == client_response.get_status
    raise ClientResponseStatusError.new(client_response)
  end

  client_response
end

Instance Method Details

#map(index, validate_status = true) {|VoltTableRow| ... } ⇒ Array<Object, Object>

This method is used when we extend the Voltdb ClientResponse interface and it’s used for mapping VoltTableRows to an object. It receives the index of the VoltTable that we want to map and a block that will be executed in that context

Parameters:

  • index (Fixnum)

    VoltTable index

Yields:

  • (VoltTableRow)

Returns:

  • (Array<Object, Object>)


61
62
63
# File 'lib/voltdb/client_response_utils.rb', line 61

def map(index, validate_status = true, &block)
  ClientResponseUtils.map_client_response_result(self, index, validate_status, &block)
end

#map_first_row(index, validate_status = true) {|VoltTableRow| ... } ⇒ Array<Object>

This method is used when we extend the Voltdb ClientResponse interface and it’s used for mapping the first row from a VoltTableRow to an object. It receives the index of the VoltTable that we want to map and a block that will be executed in that context

Parameters:

  • index (Fixnum)

    VoltTable index

Yields:

  • (VoltTableRow)

Returns:

  • (Array<Object>)


73
74
75
# File 'lib/voltdb/client_response_utils.rb', line 73

def map_first_row(index, validate_status = true, &block)
  ClientResponseUtils.map_first_row_from_client_response_result(self, index, validate_status, &block)
end

#validate_statusclient_response

This method is used when we extend the Voltdb ClientResponse interface and it’s used for valitation on the client response

Returns:

  • (client_response)


81
82
83
# File 'lib/voltdb/client_response_utils.rb', line 81

def validate_status
  ClientResponseUtils.validate_client_response_status(self)
end