Class: Cql::Protocol::ExecuteRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/cql/protocol/requests/execute_request.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#opcode

Instance Method Summary collapse

Methods inherited from Request

#encode_frame

Methods included from Encoding

#write_bytes, #write_consistency, #write_decimal, #write_double, #write_float, #write_int, #write_long, #write_long_string, #write_short, #write_short_bytes, #write_string, #write_string_list, #write_string_map, #write_uuid, #write_varint

Constructor Details

#initialize(id, metadata, values, consistency) ⇒ ExecuteRequest

Returns a new instance of ExecuteRequest.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
# File 'lib/cql/protocol/requests/execute_request.rb', line 8

def initialize(id, , values, consistency)
  raise ArgumentError, "Metadata for #{.size} columns, but #{values.size} values given" if .size != values.size
  super(10)
  @id = id
  @metadata = 
  @values = values
  @consistency = consistency
  @bytes = encode_body
end

Instance Attribute Details

#consistencyObject (readonly)

Returns the value of attribute consistency.



6
7
8
# File 'lib/cql/protocol/requests/execute_request.rb', line 6

def consistency
  @consistency
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/cql/protocol/requests/execute_request.rb', line 6

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/cql/protocol/requests/execute_request.rb', line 6

def 
  @metadata
end

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/cql/protocol/requests/execute_request.rb', line 6

def values
  @values
end

Instance Method Details

#eql?(rq) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


27
28
29
# File 'lib/cql/protocol/requests/execute_request.rb', line 27

def eql?(rq)
  self.class === rq && rq.id == self.id && rq. == self. && rq.values == self.values && rq.consistency == self.consistency
end

#hashObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/cql/protocol/requests/execute_request.rb', line 32

def hash
  @h ||= begin
    h = 0
    h = ((h & 33554431) * 31) ^ @id.hash
    h = ((h & 33554431) * 31) ^ @metadata.hash
    h = ((h & 33554431) * 31) ^ @values.hash
    h = ((h & 33554431) * 31) ^ @consistency.hash
    h
  end
end

#to_sObject



22
23
24
25
# File 'lib/cql/protocol/requests/execute_request.rb', line 22

def to_s
  id = @id.each_byte.map { |x| x.to_s(16) }.join('')
  %(EXECUTE #{id} #@values #{@consistency.to_s.upcase})
end

#write(io) ⇒ Object



18
19
20
# File 'lib/cql/protocol/requests/execute_request.rb', line 18

def write(io)
  io << @bytes
end