Class: Aerospike::ServerCommand

Inherits:
MultiCommand show all
Defined in:
lib/aerospike/query/server_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MultiCommand

#compressed?, #get_node, #parse_group, #parse_key, #parse_record, #parse_result, #read_bytes, #skip_key, #stop, #valid?

Methods inherited from Command

#execute, #set_delete, #set_exists, #set_operate, #set_query, #set_read, #set_read_for_key_only, #set_read_header, #set_scan, #set_touch, #set_udf, #set_write, #write_bins

Constructor Details

#initialize(cluster, node, policy, statement, background, task_id) ⇒ ServerCommand

Returns a new instance of ServerCommand.



22
23
24
25
26
27
28
29
# File 'lib/aerospike/query/server_command.rb', line 22

def initialize(cluster, node, policy, statement, background, task_id)
  super(node)
  @statement = statement
  @task_id = task_id
  @cluster = cluster
  @policy = policy
  @background = background
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



20
21
22
# File 'lib/aerospike/query/server_command.rb', line 20

def background
  @background
end

#clusterObject

Returns the value of attribute cluster.



20
21
22
# File 'lib/aerospike/query/server_command.rb', line 20

def cluster
  @cluster
end

#statementObject

Returns the value of attribute statement.



20
21
22
# File 'lib/aerospike/query/server_command.rb', line 20

def statement
  @statement
end

#task_idObject

Returns the value of attribute task_id.



20
21
22
# File 'lib/aerospike/query/server_command.rb', line 20

def task_id
  @task_id
end

#write_policyObject

Returns the value of attribute write_policy.



20
21
22
# File 'lib/aerospike/query/server_command.rb', line 20

def write_policy
  @write_policy
end

Instance Method Details

#parse_row(result_code) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/aerospike/query/server_command.rb', line 39

def parse_row(result_code)
  field_count = @data_buffer.read_int16(18)
  result_code = @data_buffer.read(5).ord & 0xFF
  skip_key(field_count)

  if result_code != 0
    if result_code == Aerospike::ResultCode::KEY_NOT_FOUND_ERROR
      return false
    end
    raise Aerospike::Exceptions::Aerospike.new(result_code)
  end
  op_count = @data_buffer.read_int16(20)
  if op_count <= 0
    return Record.new(@node, key, bins, generation, expiration)
  end

  unless valid?
    raise Aerospike::Exceptions::QueryTerminated
  end
end

#write?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/aerospike/query/server_command.rb', line 31

def write?
  true
end

#write_bufferObject



35
36
37
# File 'lib/aerospike/query/server_command.rb', line 35

def write_buffer
  set_query(@cluster, @policy, @statement, true, nil)
end