Class: Aerospike::OperateArgs

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/command/operate_args.rb

Constant Summary collapse

RESPOND_ALL_OPS_READ_CMDS =
[Operation::BIT_READ, Operation::EXP_READ, Operation::HLL_READ, Operation::CDT_READ]
READ_CMDS =
[Operation::BIT_READ, Operation::EXP_READ, Operation::HLL_READ, Operation::CDT_READ, Operation::CDT_READ, Operation::READ]
MODIFY_CMDS =
[Operation::BIT_MODIFY, Operation::EXP_MODIFY, Operation::HLL_MODIFY, Operation::CDT_MODIFY]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster, policy, write_default, read_default, key, operations) ⇒ OperateArgs

Returns a new instance of OperateArgs.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# 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

Instance Attribute Details

#has_writeObject (readonly)

Returns the value of attribute has_write.



24
25
26
# File 'lib/aerospike/command/operate_args.rb', line 24

def has_write
  @has_write
end

#operationsObject (readonly)

Returns the value of attribute operations.



23
24
25
# File 'lib/aerospike/command/operate_args.rb', line 23

def operations
  @operations
end

#partitionObject (readonly)

Returns the value of attribute partition.



23
24
25
# File 'lib/aerospike/command/operate_args.rb', line 23

def partition
  @partition
end

#read_attrObject (readonly)

Returns the value of attribute read_attr.



24
25
26
# File 'lib/aerospike/command/operate_args.rb', line 24

def read_attr
  @read_attr
end

#sizeObject (readonly)

Returns the value of attribute size.



24
25
26
# File 'lib/aerospike/command/operate_args.rb', line 24

def size
  @size
end

#write_attrObject (readonly)

Returns the value of attribute write_attr.



24
25
26
# File 'lib/aerospike/command/operate_args.rb', line 24

def write_attr
  @write_attr
end

#write_policyObject (readonly)

Returns the value of attribute write_policy.



23
24
25
# File 'lib/aerospike/command/operate_args.rb', line 23

def write_policy
  @write_policy
end