class Aerospike::CDT::MapPolicy

Constants

DEFAULT

Attributes

attributes[RW]
flags[RW]
item_command[RW]
items_command[RW]
order[RW]
persist_index[RW]
write_mode[RW]

Public Class Methods

new(order: nil, write_mode: nil, persist_index: false, flags: nil) click to toggle source
# File lib/aerospike/cdt/map_policy.rb, line 22
def initialize(order: nil, write_mode: nil, persist_index: false, flags: nil)
  if write_mode && flags
    raise ArgumentError, "Use write mode for server versions < 4.3; use write flags for server versions >= 4.3."
  end

  @order = order || MapOrder::DEFAULT
  @write_mode = write_mode || MapWriteMode::DEFAULT
  @flags = flags || MapWriteFlags::DEFAULT
  @attributes = order ? order[:attr] : 0

  if @persist_index
    @attributes |= 0x10
  end

  case @write_mode
  when CDT::MapWriteMode::DEFAULT
    @item_command = CDT::MapOperation::PUT
    @items_command = CDT::MapOperation::PUT_ITEMS
  when CDT::MapWriteMode::UPDATE_ONLY
    @item_command = CDT::MapOperation::REPLACE
    @items_command = CDT::MapOperation::REPLACE_ITEMS
  when CDT::MapWriteMode::CREATE_ONLY
    @item_command = CDT::MapOperation::ADD
    @items_command = CDT::MapOperation::ADD_ITEMS
  else
    raise Exceptions.new(ResultCode::PARAMETER_ERROR, "invalid value for MapWriteMode #{write_mode}")
  end
end