aerospike 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,12 +22,20 @@ module Aerospike
22
22
  module ListSortFlags
23
23
 
24
24
  ##
25
- # Default. Preserve duplicate values when sorting list.
26
- DEFAULT = 0
25
+ # Preserve duplicate values when sorting list, and sort in ascending order
26
+ ASCENDING = 0
27
+
28
+ ##
29
+ # Sort the contents of the list in descending order.
30
+ DESCENDING = 1
27
31
 
28
32
  ##
29
33
  # Drop duplicate values when sorting list.
30
34
  DROP_DUPLICATES = 2
35
+
36
+ ##
37
+ # Default behavior
38
+ DEFAULT = ASCENDING
31
39
  end
32
40
  end
33
41
  end
@@ -17,6 +17,47 @@
17
17
  module Aerospike
18
18
  module CDT
19
19
 
20
+ ##
21
+ # Unique key map bin operations. Create map operations used by the client operate command.
22
+ # The default unique key map is unordered.
23
+ #
24
+ # All maps maintain an index and a rank. The index is the item offset from the start of the map,
25
+ # for both unordered and ordered maps. The rank is the sorted index of the value component.
26
+ # Map supports negative indexing for index and rank.
27
+ #
28
+ # Index examples:
29
+ #
30
+ # Index 0: First item in map.
31
+ # Index 4: Fifth item in map.
32
+ # Index -1: Last item in map.
33
+ # Index -3: Third to last item in map.
34
+ # Index 1 Count 2: Second and third items in map.
35
+ # Index -3 Count 3: Last three items in map.
36
+ # Index -5 Count 4: Range between fifth to last item to second to last item inclusive.
37
+ #
38
+ #
39
+ # Rank examples:
40
+ #
41
+ # Rank 0: Item with lowest value rank in map.
42
+ # Rank 4: Fifth lowest ranked item in map.
43
+ # Rank -1: Item with highest ranked value in map.
44
+ # Rank -3: Item with third highest ranked value in map.
45
+ # Rank 1 Count 2: Second and third lowest ranked items in map.
46
+ # Rank -3 Count 3: Top three ranked items in map.
47
+ #
48
+ #
49
+ # Nested CDT operations are supported by optional CTX context arguments. Examples:
50
+ #
51
+ # bin = {key1:{key11:9,key12:4}, key2:{key21:3,key22:5}}
52
+ # Set map value to 11 for map key "key21" inside of map key "key2".
53
+ # MapOperation.put("bin", "key21", 11, ctx: [Context.map_key("key2")])
54
+ # bin result = {key1:{key11:9,key12:4},key2:{key21:11,key22:5}}
55
+ #
56
+ # bin : {key1:{key11:{key111:1},key12:{key121:5}}, key2:{key21:{"key211":7}}}
57
+ # Set map value to 11 in map key "key121" for highest ranked map ("key12") inside of map key "key1".
58
+ # MapOperation.put("bin", "key121", 11, ctx: [Context.map_key("key1"), Context.map_rank(-1)])
59
+ # bin result = {key1:{key11:{key111:1},key12:{key121:11}}, key2:{key21:{"key211":7}}}
60
+
20
61
  class MapOperation < Operation
21
62
 
22
63
  SET_TYPE = 64
@@ -55,13 +96,14 @@ module Aerospike
55
96
  GET_BY_KEY_REL_INDEX_RANGE = 109
56
97
  GET_BY_VALUE_REL_RANK_RANGE = 110
57
98
 
58
- attr_reader :map_op, :arguments, :return_type
99
+ attr_reader :map_op, :arguments, :return_type, :ctx
59
100
 
60
- def initialize(op_type, map_op, bin_name, *arguments, return_type: nil)
101
+ def initialize(op_type, map_op, bin_name, *arguments, ctx: nil, return_type: nil)
61
102
  @op_type = op_type
62
103
  @bin_name = bin_name
63
104
  @bin_value = nil
64
105
  @map_op = map_op
106
+ @ctx = ctx
65
107
  @arguments = arguments
66
108
  @return_type = return_type
67
109
  self
@@ -72,8 +114,8 @@ module Aerospike
72
114
  # Server sets map policy attributes. Server returns null.
73
115
  #
74
116
  # The required map policy attributes can be changed after the map is created.
75
- def self.set_policy(bin_name, policy)
76
- MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order)
117
+ def self.set_policy(bin_name, policy, ctx: nil)
118
+ MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order, ctx: ctx)
77
119
  end
78
120
 
79
121
  ##
@@ -82,18 +124,18 @@ module Aerospike
82
124
  #
83
125
  # The map policy dictates the type of map to create when it does not exist.
84
126
  # The map policy also specifies the flags used when writing items to the map.
85
- def self.put(bin_name, key, value, policy: MapPolicy::DEFAULT)
127
+ def self.put(bin_name, key, value, ctx: nil, policy: MapPolicy::DEFAULT)
86
128
  if policy.flags != MapWriteFlags::DEFAULT
87
- MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags)
129
+ MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags, ctx: ctx)
88
130
  else
89
131
  case policy.write_mode
90
132
  when MapWriteMode::UPDATE_ONLY
91
133
  # Replace doesn't allow map order because it does not create on non-existing key.
92
- MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value)
134
+ MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value, ctx: ctx)
93
135
  when MapWriteMode::CREATE_ONLY
94
- MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order)
136
+ MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order, ctx: ctx)
95
137
  else
96
- MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order)
138
+ MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, ctx: ctx)
97
139
  end
98
140
  end
99
141
  end
@@ -104,18 +146,18 @@ module Aerospike
104
146
  #
105
147
  # The map policy dictates the type of map to create when it does not exist.
106
148
  # The map policy also specifies the flags used when writing items to the map.
107
- def self.put_items(bin_name, values, policy: MapPolicy::DEFAULT)
149
+ def self.put_items(bin_name, values, ctx: nil, policy: MapPolicy::DEFAULT)
108
150
  if policy.flags != MapWriteFlags::DEFAULT
109
- MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags)
151
+ MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags, ctx: ctx)
110
152
  else
111
153
  case policy.write_mode
112
154
  when MapWriteMode::UPDATE_ONLY
113
155
  # Replace doesn't allow map order because it does not create on non-existing key.
114
- MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values)
156
+ MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values, ctx: ctx)
115
157
  when MapWriteMode::CREATE_ONLY
116
- MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order)
158
+ MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order, ctx: ctx)
117
159
  else
118
- MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order)
160
+ MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, ctx: ctx)
119
161
  end
120
162
  end
121
163
  end
@@ -127,8 +169,8 @@ module Aerospike
127
169
  #
128
170
  # The map policy dictates the type of map to create when it does not exist.
129
171
  # The map policy also specifies the mode used when writing items to the map.
130
- def self.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT)
131
- MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order)
172
+ def self.increment(bin_name, key, incr, ctx: nil, policy: MapPolicy::DEFAULT)
173
+ MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order, ctx: ctx)
132
174
  end
133
175
 
134
176
  ##
@@ -138,15 +180,15 @@ module Aerospike
138
180
  #
139
181
  # The map policy dictates the type of map to create when it does not exist.
140
182
  # The map policy also specifies the mode used when writing items to the map.
141
- def self.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT)
142
- MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order)
183
+ def self.decrement(bin_name, key, decr, ctx: nil, policy: MapPolicy::DEFAULT)
184
+ MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order, ctx: ctx)
143
185
  end
144
186
 
145
187
  ##
146
188
  # Create map clear operation.
147
189
  # Server removes all items in map. Server returns null.
148
- def self.clear(bin_name)
149
- MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name)
190
+ def self.clear(bin_name, ctx: nil)
191
+ MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name, ctx: ctx)
150
192
  end
151
193
 
152
194
  ##
@@ -154,8 +196,8 @@ module Aerospike
154
196
  #
155
197
  # Server removes map item identified by key and returns removed data
156
198
  # specified by return_type.
157
- def self.remove_by_key(bin_name, key, return_type: nil)
158
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, return_type: return_type)
199
+ def self.remove_by_key(bin_name, key, ctx: nil, return_type: nil)
200
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, ctx: ctx, return_type: return_type)
159
201
  end
160
202
 
161
203
  ##
@@ -164,8 +206,8 @@ module Aerospike
164
206
  # Server removes map items identified by keys.
165
207
  #
166
208
  # Server returns removed data specified by return_type.
167
- def self.remove_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
168
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type)
209
+ def self.remove_by_key_list(bin_name, keys, ctx: nil, return_type: MapReturnType::NONE)
210
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, ctx: ctx, return_type: return_type)
169
211
  end
170
212
 
171
213
  ##
@@ -176,11 +218,11 @@ module Aerospike
176
218
  # Server returns removed data specified by return_type.
177
219
  #
178
220
  # Deprecated. Use remove_by_key / remove_by_key_list instead.
179
- def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE)
221
+ def self.remove_keys(bin_name, *keys, ctx: nil, return_type: MapReturnType::NONE)
180
222
  if keys.length > 1
181
- remove_by_key_list(bin_name, keys, return_type: return_type)
223
+ remove_by_key_list(bin_name, keys, ctx: ctx, return_type: return_type)
182
224
  else
183
- remove_by_key(bin_name, keys.first, return_type: return_type)
225
+ remove_by_key(bin_name, keys.first, ctx: ctx, return_type: return_type)
184
226
  end
185
227
  end
186
228
 
@@ -192,11 +234,11 @@ module Aerospike
192
234
  # If key_end is null, the range is greater than equal to key_begin.
193
235
  #
194
236
  # Server returns removed data specified by return_type.
195
- def self.remove_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
237
+ def self.remove_by_key_range(bin_name, key_begin, key_end = nil, ctx: nil, return_type: MapReturnType::NONE)
196
238
  if key_end
197
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
239
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, ctx: ctx, return_type: return_type)
198
240
  else
199
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
241
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, ctx: ctx, return_type: return_type)
200
242
  end
201
243
  end
202
244
  singleton_class.send(:alias_method, :remove_key_range, :remove_by_key_range)
@@ -226,11 +268,11 @@ module Aerospike
226
268
  # * (5, -1) = [{4=2}, {5=15}, {9=10}]
227
269
  # * (3, 2) = [{9=10}]
228
270
  # * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
229
- def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
271
+ def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, ctx: nil, return_type: nil)
230
272
  if count
231
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
273
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, ctx: ctx, return_type: return_type)
232
274
  else
233
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
275
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, ctx: ctx, return_type: return_type)
234
276
  end
235
277
  end
236
278
 
@@ -240,8 +282,8 @@ module Aerospike
240
282
  # Server removes map item identified by value.
241
283
  #
242
284
  # Server returns removed data specified by return_type.
243
- def self.remove_by_value(bin_name, value, return_type: MapReturnType::NONE)
244
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, return_type: return_type)
285
+ def self.remove_by_value(bin_name, value, ctx: nil, return_type: MapReturnType::NONE)
286
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
245
287
  end
246
288
 
247
289
  ##
@@ -250,8 +292,8 @@ module Aerospike
250
292
  # Server removes map items identified by value.
251
293
  #
252
294
  # Server returns removed data specified by return_type.
253
- def self.remove_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
254
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
295
+ def self.remove_by_value_list(bin_name, values, ctx: nil, return_type: MapReturnType::NONE)
296
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
255
297
  end
256
298
 
257
299
  ##
@@ -262,11 +304,11 @@ module Aerospike
262
304
  # Server returns removed data specified by return_type.
263
305
  #
264
306
  # Deprecated. Use remove_by_value / remove_by_value_list instead.
265
- def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE)
307
+ def self.remove_values(bin_name, *values, ctx: nil, return_type: MapReturnType::NONE)
266
308
  if values.length > 1
267
- remove_by_value_list(bin_name, values, return_type: return_type)
309
+ remove_by_value_list(bin_name, values, ctx: ctx, return_type: return_type)
268
310
  else
269
- remove_by_value(bin_name, values.first, return_type: return_type)
311
+ remove_by_value(bin_name, values.first, ctx: ctx, return_type: return_type)
270
312
  end
271
313
  end
272
314
 
@@ -279,11 +321,11 @@ module Aerospike
279
321
  # equal to value_begin.
280
322
  #
281
323
  # Server returns removed data specified by return_type.
282
- def self.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
324
+ def self.remove_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: MapReturnType::NONE)
283
325
  if value_end
284
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
326
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
285
327
  else
286
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
328
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
287
329
  end
288
330
  end
289
331
  singleton_class.send(:alias_method, :remove_value_range, :remove_by_value_range)
@@ -308,11 +350,11 @@ module Aerospike
308
350
  # * (value, rank) = [removed items]
309
351
  # * (11, 1) = [{0=17}]
310
352
  # * (11, -1) = [{9=10}, {5=15}, {0=17}]
311
- def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
353
+ def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: nil)
312
354
  if count
313
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
355
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
314
356
  else
315
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
357
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
316
358
  end
317
359
  end
318
360
 
@@ -322,8 +364,8 @@ module Aerospike
322
364
  # Server removes map item identified by index.
323
365
  #
324
366
  # Server returns removed data specified by return_type.
325
- def self.remove_by_index(bin_name, index, return_type: MapReturnType::NONE)
326
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type)
367
+ def self.remove_by_index(bin_name, index, ctx: nil, return_type: MapReturnType::NONE)
368
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
327
369
  end
328
370
  singleton_class.send(:alias_method, :remove_index, :remove_by_index)
329
371
 
@@ -335,11 +377,11 @@ module Aerospike
335
377
  # specified index to the end of map.
336
378
  #
337
379
  # Server returns removed data specified by return_type.
338
- def self.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
380
+ def self.remove_by_index_range(bin_name, index, count = nil, ctx: nil, return_type: MapReturnType::NONE)
339
381
  if count
340
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
382
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
341
383
  else
342
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
384
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
343
385
  end
344
386
  end
345
387
  singleton_class.send(:alias_method, :remove_index_range, :remove_by_index_range)
@@ -350,8 +392,8 @@ module Aerospike
350
392
  # Server removes map item identified by rank.
351
393
  #
352
394
  # Server returns removed data specified by return_type.
353
- def self.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
354
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type)
395
+ def self.remove_by_rank(bin_name, rank, ctx: nil, return_type: MapReturnType::NONE)
396
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
355
397
  end
356
398
 
357
399
  ##
@@ -362,26 +404,26 @@ module Aerospike
362
404
  # to the last ranked.
363
405
  #
364
406
  # Server returns removed data specified by return_type.
365
- def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
407
+ def self.remove_by_rank_range(bin_name, rank, count = nil, ctx: nil, return_type: MapReturnType::NONE)
366
408
  if count
367
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
409
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
368
410
  else
369
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
411
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
370
412
  end
371
413
  end
372
414
 
373
415
  ##
374
416
  # Create map size operation.
375
417
  # Server returns size of map.
376
- def self.size(bin_name)
377
- MapOperation.new(Operation::CDT_READ, SIZE, bin_name)
418
+ def self.size(bin_name, ctx: nil)
419
+ MapOperation.new(Operation::CDT_READ, SIZE, bin_name, ctx: ctx)
378
420
  end
379
421
 
380
422
  ##
381
423
  # Create map get by key operation.
382
424
  # Server selects map item identified by key and returns selected data specified by return_type.
383
- def self.get_by_key(bin_name, key, return_type: MapReturnType::NONE)
384
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, return_type: return_type)
425
+ def self.get_by_key(bin_name, key, ctx: nil, return_type: MapReturnType::NONE)
426
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, ctx: ctx, return_type: return_type)
385
427
  end
386
428
  singleton_class.send(:alias_method, :get_key, :get_by_key)
387
429
 
@@ -391,8 +433,8 @@ module Aerospike
391
433
  # Server selects map items identified by keys.
392
434
  #
393
435
  # Server returns selected data specified by return_type.
394
- def self.get_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
395
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, return_type: return_type)
436
+ def self.get_by_key_list(bin_name, keys, ctx: nil, return_type: MapReturnType::NONE)
437
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, ctx: ctx, return_type: return_type)
396
438
  end
397
439
 
398
440
  # Create map get by key range operation.
@@ -403,11 +445,11 @@ module Aerospike
403
445
  # key_begin.
404
446
  #
405
447
  # Server returns selected data specified by return_type.
406
- def self.get_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
448
+ def self.get_by_key_range(bin_name, key_begin, key_end = nil, ctx: nil, return_type: MapReturnType::NONE)
407
449
  if key_end
408
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
450
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, ctx: ctx, return_type: return_type)
409
451
  else
410
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
452
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, ctx: ctx, return_type: return_type)
411
453
  end
412
454
  end
413
455
  singleton_class.send(:alias_method, :get_key_range, :get_by_key_range)
@@ -438,11 +480,11 @@ module Aerospike
438
480
  # * (5, -1) = [{4=2}, {5=15}, {9=10}]
439
481
  # * (3, 2) = [{9=10}]
440
482
  # * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
441
- def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
483
+ def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, ctx: nil, return_type: nil)
442
484
  if count
443
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
485
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, ctx: ctx, return_type: return_type)
444
486
  else
445
- MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
487
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, ctx: ctx, return_type: return_type)
446
488
  end
447
489
  end
448
490
 
@@ -451,8 +493,8 @@ module Aerospike
451
493
  # Server selects map items identified by value.
452
494
  #
453
495
  # Server returns selected data specified by return_type.
454
- def self.get_by_value(bin_name, value, return_type: MapReturnType::NONE)
455
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type)
496
+ def self.get_by_value(bin_name, value, ctx: nil, return_type: MapReturnType::NONE)
497
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
456
498
  end
457
499
  singleton_class.send(:alias_method, :get_value, :get_by_value)
458
500
 
@@ -461,8 +503,8 @@ module Aerospike
461
503
  # Server selects map items identified by value list.
462
504
  #
463
505
  # Server returns selected data specified by return_type.
464
- def self.get_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
465
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, return_type: return_type)
506
+ def self.get_by_value_list(bin_name, values, ctx: nil, return_type: MapReturnType::NONE)
507
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
466
508
  end
467
509
 
468
510
  # Create map get by value range operation.
@@ -473,11 +515,11 @@ module Aerospike
473
515
  # equal to value_begin.
474
516
  #
475
517
  # Server returns selected data specified by return_type.
476
- def self.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
518
+ def self.get_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: MapReturnType::NONE)
477
519
  if value_end
478
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
520
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
479
521
  else
480
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
522
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
481
523
  end
482
524
  end
483
525
  singleton_class.send(:alias_method, :get_value_range, :get_by_value_range)
@@ -502,11 +544,11 @@ module Aerospike
502
544
  # * (value, rank) = [selected items]
503
545
  # * (11, 1) = [{0=17}]
504
546
  # * (11, -1) = [{9=10}, {5=15}, {0=17}]
505
- def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
547
+ def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: nil)
506
548
  if count
507
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
549
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
508
550
  else
509
- MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
551
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
510
552
  end
511
553
  end
512
554
 
@@ -516,8 +558,8 @@ module Aerospike
516
558
  # Server selects map item identified by index.
517
559
  #
518
560
  # Server returns selected data specified by return_type.
519
- def self.get_by_index(bin_name, index, return_type: MapReturnType::NONE)
520
- MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type)
561
+ def self.get_by_index(bin_name, index, ctx: nil, return_type: MapReturnType::NONE)
562
+ MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
521
563
  end
522
564
  singleton_class.send(:alias_method, :get_index, :get_by_index)
523
565
 
@@ -528,11 +570,11 @@ module Aerospike
528
570
  # specified index to the end of map.
529
571
  #
530
572
  # Server returns selected data specified by return_type.
531
- def self.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
573
+ def self.get_by_index_range(bin_name, index, count = nil, ctx: nil, return_type: MapReturnType::NONE)
532
574
  if count
533
- MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
575
+ MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
534
576
  else
535
- MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
577
+ MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
536
578
  end
537
579
  end
538
580
  singleton_class.send(:alias_method, :get_index_range, :get_by_index_range)
@@ -542,8 +584,8 @@ module Aerospike
542
584
  # Server selects map item identified by rank.
543
585
  #
544
586
  # Server returns selected data specified by return_type.
545
- def self.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
546
- MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type)
587
+ def self.get_by_rank(bin_name, rank, ctx: nil, return_type: MapReturnType::NONE)
588
+ MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
547
589
  end
548
590
 
549
591
  # Create map get by rank range operation.
@@ -553,11 +595,11 @@ module Aerospike
553
595
  # to the last ranked item.
554
596
  #
555
597
  # Server returns selected data specified by return_type.
556
- def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
598
+ def self.get_by_rank_range(bin_name, rank, count = nil, ctx: nil, return_type: MapReturnType::NONE)
557
599
  if count
558
- MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
600
+ MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
559
601
  else
560
- MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
602
+ MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
561
603
  end
562
604
  end
563
605
 
@@ -575,12 +617,31 @@ module Aerospike
575
617
 
576
618
  def pack_bin_value
577
619
  bytes = nil
620
+
621
+ args = arguments.dup
622
+ args.unshift(return_type) if return_type
623
+
578
624
  Packer.use do |packer|
579
- packer.write_raw_short(map_op)
580
- args = arguments.dup
581
- args.unshift(return_type) if return_type
625
+ if @ctx != nil && @ctx.length > 0
626
+ packer.write_array_header(3)
627
+ Value.of(0xff).pack(packer)
628
+
629
+ packer.write_array_header(@ctx.length*2)
630
+ @ctx.each do |ctx|
631
+ Value.of(ctx.id).pack(packer)
632
+ Value.of(ctx.value).pack(packer)
633
+ end
634
+
635
+ packer.write_array_header(args.length+1)
636
+ Value.of(@map_op).pack(packer)
637
+ else
638
+ packer.write_raw_short(@map_op)
639
+ if args.length > 0
640
+ packer.write_array_header(args.length)
641
+ end
642
+ end
643
+
582
644
  if args.length > 0
583
- packer.write_array_header(args.length)
584
645
  args.each do |value|
585
646
  Value.of(value).pack(packer)
586
647
  end