class Aerospike::OperateArgs
Constants
- MODIFY_CMDS
- READ_CMDS
- RESPOND_ALL_OPS_READ_CMDS
Attributes
has_write[R]
operations[R]
partition[R]
read_attr[R]
size[R]
write_attr[R]
write_policy[R]
Public Class Methods
new(cluster, policy, write_default, read_default, key, operations)
click to toggle source
# File lib/aerospike/command/operate_args.rb, line 30 def initialize(cluster, policy, write_default, read_default, key, operations) @operations = operations data_offset = 0 rattr = 0 wattr = 0 write = false read_bin = false read_header = false respond_all_ops = false @operations.each do |operation| if READ_CMDS.include?(operation.op_type) if RESPOND_ALL_OPS_READ_CMDS.include?(operation.op_type) # Map @operations require respond_all_ops to be true. respond_all_ops = true end rattr |= Aerospike::INFO1_READ # Read all bins if no bin is specified. rattr |= Aerospike::INFO1_GET_ALL if operation.bin_name.nil? read_bin = true elsif operation.op_type == Operation::READ_HEADER rattr |= Aerospike::INFO1_READ read_header = true elsif MODIFY_CMDS.include?(operation.op_type) # Map @operations require respond_all_ops to be true. respond_all_ops = true wattr = Aerospike::INFO2_WRITE write = true else wattr = Aerospike::INFO2_WRITE write = true end data_offset += operation.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE unless operation.bin_name.nil? data_offset += operation.bin_value.estimate_size end @size = data_offset @has_write = write if read_header && !read_bin rattr |= Aerospike::INFO1_NOBINDATA end @read_attr = rattr if policy.nil? @write_policy = write ? write_default : read_default else @write_policy = policy end # When GET_ALL is specified, RESPOND_ALL_OPS must be disabled. if (respond_all_ops && policy.record_bin_multiplicity) && (rattr & Aerospike::INFO1_GET_ALL) == 0 wattr |= Aerospike::INFO2_RESPOND_ALL_OPS end @write_attr = wattr if write # @partition = Partition.write(cluster, @write_policy, key) @partition = Partition.new_by_key(key) else # @partition = Partition.read(cluster, @write_policy, key) @partition = Partition.new_by_key(key) end end