Method: Aerospike::BatchWrite#size

Defined in:
lib/aerospike/batch_write.rb

#sizeObject

Return wire protocol size. For internal use only.

[View source]

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
# File 'lib/aerospike/batch_write.rb', line 53

def size # :nodoc:
  size = 6 # gen(2) + exp(4) = 6

  size += @policy&.filter_exp&.size if @policy&.filter_exp

  if @policy&.send_key
    size += @key.user_key.estimate_size + Aerospike::FIELD_HEADER_SIZE + 1
  end

  has_write = false
  @ops&.each do |op|
    if op.is_write?
      has_write = true
    end

    size += op.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE if op.bin_name
    size += op.bin_value.estimate_size if op.bin_value
  end

  unless has_write
    raise AerospikeException.new(ResultCode::PARAMETER_ERROR, "Batch write operations do not contain a write")
  end

  size
end