Class: Aerospike::CDT::MapOperation

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

Constant Summary collapse

SET_TYPE =
64
ADD =
65
ADD_ITEMS =
66
PUT =
67
PUT_ITEMS =
68
REPLACE =
69
REPLACE_ITEMS =
70
INCREMENT =
73
DECREMENT =
74
CLEAR =
75
REMOVE_BY_KEY =
76
REMOVE_BY_INDEX =
77
REMOVE_BY_RANK =
79
REMOVE_BY_KEY_LIST =
81
REMOVE_BY_VALUE =
82
REMOVE_BY_VALUE_LIST =
83
REMOVE_BY_KEY_INTERVAL =
84
REMOVE_BY_INDEX_RANGE =
85
REMOVE_BY_VALUE_INTERVAL =
86
REMOVE_BY_RANK_RANGE =
87
REMOVE_BY_KEY_REL_INDEX_RANGE =
88
REMOVE_BY_VALUE_REL_RANK_RANGE =
89
SIZE =
96
GET_BY_KEY =
97
GET_BY_INDEX =
98
GET_BY_RANK =
100
GET_BY_VALUE =
102
GET_BY_KEY_INTERVAL =
103
GET_BY_INDEX_RANGE =
104
GET_BY_VALUE_INTERVAL =
105
GET_BY_RANK_RANGE =
106
GET_BY_KEY_LIST =
107
GET_BY_VALUE_LIST =
108
GET_BY_KEY_REL_INDEX_RANGE =
109
GET_BY_VALUE_REL_RANK_RANGE =
110

Constants inherited from Operation

Operation::APPEND, Operation::CDT_MODIFY, Operation::CDT_READ, Operation::PREPEND, Operation::READ, Operation::READ_HEADER, Operation::TOUCH, Operation::WRITE

Instance Attribute Summary collapse

Attributes inherited from Operation

#bin_name, #op_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operation

add, append, #bin, get, get_header, prepend, touch

Constructor Details

#initialize(op_type, map_op, bin_name, *arguments, return_type: nil) ⇒ MapOperation

Returns a new instance of MapOperation.



60
61
62
63
64
65
66
67
68
# File 'lib/aerospike/cdt/map_operation.rb', line 60

def initialize(op_type, map_op, bin_name, *arguments, return_type: nil)
  @op_type = op_type
  @bin_name = bin_name
  @bin_value = nil
  @map_op = map_op
  @arguments = arguments
  @return_type = return_type
  self
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



58
59
60
# File 'lib/aerospike/cdt/map_operation.rb', line 58

def arguments
  @arguments
end

#map_opObject (readonly)

Returns the value of attribute map_op.



58
59
60
# File 'lib/aerospike/cdt/map_operation.rb', line 58

def map_op
  @map_op
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



58
59
60
# File 'lib/aerospike/cdt/map_operation.rb', line 58

def return_type
  @return_type
end

Class Method Details

.clear(bin_name) ⇒ Object

Create map clear operation. Server removes all items in map. Server returns null.



148
149
150
# File 'lib/aerospike/cdt/map_operation.rb', line 148

def self.clear(bin_name)
  MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name)
end

.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT) ⇒ Object

Create map decrement operation. Server decrements values by decr for all items identified by key and returns final result. Valid only for numbers.

The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.



141
142
143
# File 'lib/aerospike/cdt/map_operation.rb', line 141

def self.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT)
  MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order)
end

.get_by_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object

Create map get by index operation.

Server selects map item identified by index.

Server returns selected data specified by return_type.



519
520
521
# File 'lib/aerospike/cdt/map_operation.rb', line 519

def self.get_by_index(bin_name, index, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type)
end

.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map get by index range operation.

Server selects “count” map items starting at specified index. If “count” is not specified, server selects map items starting at specified index to the end of map.

Server returns selected data specified by return_type.



531
532
533
534
535
536
537
# File 'lib/aerospike/cdt/map_operation.rb', line 531

def self.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
  if count
    MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
  end
end

.get_by_key(bin_name, key, return_type: MapReturnType::NONE) ⇒ Object

Create map get by key operation. Server selects map item identified by key and returns selected data specified by return_type.



383
384
385
# File 'lib/aerospike/cdt/map_operation.rb', line 383

def self.get_by_key(bin_name, key, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, return_type: return_type)
end

.get_by_key_list(bin_name, keys, return_type: MapReturnType::NONE) ⇒ Object

Create map get by key list operation.

Server selects map items identified by keys.

Server returns selected data specified by return_type.



394
395
396
# File 'lib/aerospike/cdt/map_operation.rb', line 394

def self.get_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, return_type: return_type)
end

.get_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map get by key range operation.

Server selects map items identified by key range (key_begin inclusive, key_end exclusive). If key_begin is null, the range is less than key_end. If key_end is null, the range is greater than equal to key_begin.

Server returns selected data specified by return_type.



406
407
408
409
410
411
412
# File 'lib/aerospike/cdt/map_operation.rb', line 406

def self.get_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
  if key_end
    MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
  end
end

.get_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil) ⇒ Object

Create map get by key relative to index range operation.

Server selects “count” map items nearest to key and greater by relative index. If “count” is not specified, server selects map items nearest to key and greater by relative index, until the end of the map.

Server returns selected data specified by return_type.

Examples for map [0=17,4=2,5=15,9=10]:

  • (value, index, count) = [selected items]

  • (5, 0, 1) = [5=15]

  • (5, 1, 2) = [9=10]

  • (5, -1, 1) = [4=2]

  • (3, 2, 1) = [9=10]

  • (3, -2, 2) = [0=17]

Without count:

  • (value, index) = [selected items]

  • (5, 0) = [5=15, 9=10]

  • (5, 1) = [9=10]

  • (5, -1) = [4=2, 5=15, 9=10]

  • (3, 2) = [9=10]

  • (3, -2) = [0=17, 4=2, 5=15, 9=10]



441
442
443
444
445
446
447
# File 'lib/aerospike/cdt/map_operation.rb', line 441

def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
  if count
    MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
  end
end

.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object

Create map get by rank operation.

Server selects map item identified by rank.

Server returns selected data specified by return_type.



545
546
547
# File 'lib/aerospike/cdt/map_operation.rb', line 545

def self.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type)
end

.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map get by rank range operation.

Server selects “count” map items starting at specified rank. If “count” is not specified, server selects map items starting at specified rank to the last ranked item.

Server returns selected data specified by return_type.



556
557
558
559
560
561
562
# File 'lib/aerospike/cdt/map_operation.rb', line 556

def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
  if count
    MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
  end
end

.get_by_value(bin_name, value, return_type: MapReturnType::NONE) ⇒ Object

Create map get by value operation.

Server selects map items identified by value.

Server returns selected data specified by return_type.



454
455
456
# File 'lib/aerospike/cdt/map_operation.rb', line 454

def self.get_by_value(bin_name, value, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type)
end

.get_by_value_list(bin_name, values, return_type: MapReturnType::NONE) ⇒ Object

Create map get by value list operation.

Server selects map items identified by value list.

Server returns selected data specified by return_type.



464
465
466
# File 'lib/aerospike/cdt/map_operation.rb', line 464

def self.get_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, return_type: return_type)
end

.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map get by value range operation.

Server selects map items identified by value range (value_begin inclusive, value_end exclusive). If value_begin is null, the range is less than value_end. If value_end is null, the range is greater than equal to value_begin.

Server returns selected data specified by return_type.



476
477
478
479
480
481
482
# File 'lib/aerospike/cdt/map_operation.rb', line 476

def self.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
  if value_end
    MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
  end
end

.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil) ⇒ Object

Create map get by value relative to rank range operation.

Server selects “count” map items nearest to value and greater by relative rank. If “count” is not specified, server selects map items nearest to value and greater by relative rank, until the end of the map.

Server returns selected data specified by return_type.

Examples for map [4=2,9=10,5=15,0=17]:

  • (value, rank, count) = [selected items]

  • (11, 1, 1) = [0=17]

  • (11, -1, 1) = [9=10]

Without count:

  • (value, rank) = [selected items]

  • (11, 1) = [0=17]

  • (11, -1) = [9=10, 5=15, 0=17]



505
506
507
508
509
510
511
# File 'lib/aerospike/cdt/map_operation.rb', line 505

def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
  if count
    MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
  end
end

.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT) ⇒ Object

Create map increment operation. Server increments values by incr for all items identified by key and returns final result. Valid only for numbers.

The map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map.



130
131
132
# File 'lib/aerospike/cdt/map_operation.rb', line 130

def self.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT)
  MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order)
end

.put(bin_name, key, value, policy: MapPolicy::DEFAULT) ⇒ Object

Create map put operation. Server writes key/value item to map bin and returns map size.

The map policy dictates the type of map to create when it does not exist. The map policy also specifies the flags used when writing items to the map.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/aerospike/cdt/map_operation.rb', line 85

def self.put(bin_name, key, value, policy: MapPolicy::DEFAULT)
  if policy.flags != MapWriteFlags::DEFAULT
    MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags)
  else
    case policy.write_mode
    when MapWriteMode::UPDATE_ONLY
      # Replace doesn't allow map order because it does not create on non-existing key.
      MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value)
    when MapWriteMode::CREATE_ONLY
      MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order)
    else
      MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order)
    end
  end
end

.put_items(bin_name, values, policy: MapPolicy::DEFAULT) ⇒ Object

Create map put items operation Server writes each map item to map bin and returns map size.

The map policy dictates the type of map to create when it does not exist. The map policy also specifies the flags used when writing items to the map.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/aerospike/cdt/map_operation.rb', line 107

def self.put_items(bin_name, values, policy: MapPolicy::DEFAULT)
  if policy.flags != MapWriteFlags::DEFAULT
    MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags)
  else
    case policy.write_mode
    when MapWriteMode::UPDATE_ONLY
      # Replace doesn't allow map order because it does not create on non-existing key.
      MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values)
    when MapWriteMode::CREATE_ONLY
      MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order)
    else
      MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order)
    end
  end
end

.remove_by_index(bin_name, index, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map item identified by index.

Server returns removed data specified by return_type.



325
326
327
# File 'lib/aerospike/cdt/map_operation.rb', line 325

def self.remove_by_index(bin_name, index, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type)
end

.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes “count” map items starting at specified index. If “count” is not specified, the server selects map items starting at specified index to the end of map.

Server returns removed data specified by return_type.



338
339
340
341
342
343
344
# File 'lib/aerospike/cdt/map_operation.rb', line 338

def self.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
  if count
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
  end
end

.remove_by_key(bin_name, key, return_type: nil) ⇒ Object

Create map remove operation.

Server removes map item identified by key and returns removed data specified by return_type.



157
158
159
# File 'lib/aerospike/cdt/map_operation.rb', line 157

def self.remove_by_key(bin_name, key, return_type: nil)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, return_type: return_type)
end

.remove_by_key_list(bin_name, keys, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by keys.

Server returns removed data specified by return_type.



167
168
169
# File 'lib/aerospike/cdt/map_operation.rb', line 167

def self.remove_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type)
end

.remove_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by key range (key_begin inclusive, key_end exclusive). If key_begin is null, the range is less than key_end. If key_end is null, the range is greater than equal to key_begin.

Server returns removed data specified by return_type.



195
196
197
198
199
200
201
# File 'lib/aerospike/cdt/map_operation.rb', line 195

def self.remove_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
  if key_end
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
  end
end

.remove_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil) ⇒ Object

Create map remove by key relative to index range operation.

Server removes map items nearest to key and greater by relative index, with a count limit.

Server returns removed data specified by return_type.

Examples for map [0=17,4=2,5=15,9=10]:

  • (value, index, count) = [removed items]

  • (5, 0, 1) = [5=15]

  • (5, 1, 2) = [9=10]

  • (5, -1, 1) = [4=2]

  • (3, 2, 1) = [9=10]

  • (3, -2, 2) = [0=17]

Without count:

  • (value, index) = [removed items]

  • (5, 0) = [5=15, 9=10]

  • (5, 1) = [9=10]

  • (5, -1) = [4=2, 5=15, 9=10]

  • (3, 2) = [9=10]

  • (3, -2) = [0=17, 4=2, 5=15, 9=10]



229
230
231
232
233
234
235
# File 'lib/aerospike/cdt/map_operation.rb', line 229

def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
  if count
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
  end
end

.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map item identified by rank.

Server returns removed data specified by return_type.



353
354
355
# File 'lib/aerospike/cdt/map_operation.rb', line 353

def self.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type)
end

.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server selects “count” map items starting at specified rank. If “count” is not specified, server removes map items starting at specified rank to the last ranked.

Server returns removed data specified by return_type.



365
366
367
368
369
370
371
# File 'lib/aerospike/cdt/map_operation.rb', line 365

def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
  if count
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
  end
end

.remove_by_value(bin_name, value, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map item identified by value.

Server returns removed data specified by return_type.



243
244
245
# File 'lib/aerospike/cdt/map_operation.rb', line 243

def self.remove_by_value(bin_name, value, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, return_type: return_type)
end

.remove_by_value_list(bin_name, values, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by value.

Server returns removed data specified by return_type.



253
254
255
# File 'lib/aerospike/cdt/map_operation.rb', line 253

def self.remove_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
end

.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by value range (value_begin inclusive, value_end exclusive). If value_begin is null, the range is less than value_end. If value_end is null, the range is greater than equal to value_begin.

Server returns removed data specified by return_type.



282
283
284
285
286
287
288
# File 'lib/aerospike/cdt/map_operation.rb', line 282

def self.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
  if value_end
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
  end
end

.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil) ⇒ Object

Create map remove by value relative to rank range operation.

Server removes “count” map items nearest to value and greater by relative rank. If “count” is not specified, server removes map items nearest to value and greater by relative rank, until the end of the map.

Server returns removed data specified by return_type.

Examples for map [4=2,9=10,5=15,0=17]:

  • (value, rank, count) = [removed items]

  • (11, 1, 1) = [0=17]

  • (11, -1, 1) = [9=10]

Without count:

  • (value, rank) = [removed items]

  • (11, 1) = [0=17]

  • (11, -1) = [9=10, 5=15, 0=17]



311
312
313
314
315
316
317
# File 'lib/aerospike/cdt/map_operation.rb', line 311

def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
  if count
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
  else
    MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
  end
end

.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by keys.

Server returns removed data specified by return_type.

Deprecated. Use remove_by_key / remove_by_key_list instead.



179
180
181
182
183
184
185
# File 'lib/aerospike/cdt/map_operation.rb', line 179

def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE)
  if keys.length > 1
    remove_by_key_list(bin_name, keys, return_type: return_type)
  else
    remove_by_key(bin_name, keys.first, return_type: return_type)
  end
end

.remove_values(bin_name, *values, return_type: MapReturnType::NONE) ⇒ Object

Create map remove operation.

Server removes map items identified by value.

Server returns removed data specified by return_type.

Deprecated. Use remove_by_value / remove_by_value_list instead.



265
266
267
268
269
270
271
# File 'lib/aerospike/cdt/map_operation.rb', line 265

def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE)
  if values.length > 1
    remove_by_value_list(bin_name, values, return_type: return_type)
  else
    remove_by_value(bin_name, values.first, return_type: return_type)
  end
end

.set_policy(bin_name, policy) ⇒ Object

Create set map policy operation. Server sets map policy attributes. Server returns null.

The required map policy attributes can be changed after the map is created.



75
76
77
# File 'lib/aerospike/cdt/map_operation.rb', line 75

def self.set_policy(bin_name, policy)
  MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order)
end

.size(bin_name) ⇒ Object

Create map size operation. Server returns size of map.



376
377
378
# File 'lib/aerospike/cdt/map_operation.rb', line 376

def self.size(bin_name)
  MapOperation.new(Operation::CDT_READ, SIZE, bin_name)
end

Instance Method Details

#and_return(return_type) ⇒ Object



564
565
566
567
568
# File 'lib/aerospike/cdt/map_operation.rb', line 564

def and_return(return_type)
  @return_type = return_type
  @bin_value = nil
  self
end

#bin_valueObject



570
571
572
# File 'lib/aerospike/cdt/map_operation.rb', line 570

def bin_value
  @bin_value ||= pack_bin_value
end