Class: Aerospike::CDT::MapPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/cdt/map_policy.rb

Constant Summary collapse

DEFAULT =
MapPolicy.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order: nil, write_mode: nil, persist_index: false, flags: nil) ⇒ MapPolicy

Returns a new instance of MapPolicy.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def attributes
  @attributes
end

#flagsObject

Returns the value of attribute flags.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def flags
  @flags
end

#item_commandObject

Returns the value of attribute item_command.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def item_command
  @item_command
end

#items_commandObject

Returns the value of attribute items_command.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def items_command
  @items_command
end

#orderObject

Returns the value of attribute order.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def order
  @order
end

#persist_indexObject

Returns the value of attribute persist_index.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def persist_index
  @persist_index
end

#write_modeObject

Returns the value of attribute write_mode.



20
21
22
# File 'lib/aerospike/cdt/map_policy.rb', line 20

def write_mode
  @write_mode
end