aerospike 2.14.0 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -4
- data/lib/aerospike.rb +9 -0
- data/lib/aerospike/cdt/bit_operation.rb +376 -0
- data/lib/aerospike/cdt/bit_overflow_action.rb +46 -0
- data/lib/aerospike/cdt/bit_policy.rb +36 -0
- data/lib/aerospike/cdt/bit_resize_flags.rb +44 -0
- data/lib/aerospike/cdt/bit_write_flags.rb +51 -0
- data/lib/aerospike/cdt/context.rb +113 -0
- data/lib/aerospike/cdt/hll_operation.rb +200 -0
- data/lib/aerospike/cdt/hll_policy.rb +34 -0
- data/lib/aerospike/cdt/hll_write_flags.rb +53 -0
- data/lib/aerospike/cdt/list_operation.rb +155 -96
- data/lib/aerospike/cdt/list_order.rb +7 -0
- data/lib/aerospike/cdt/list_sort_flags.rb +10 -2
- data/lib/aerospike/cdt/map_operation.rb +179 -92
- data/lib/aerospike/cdt/map_order.rb +3 -3
- data/lib/aerospike/client.rb +4 -2
- data/lib/aerospike/cluster.rb +9 -9
- data/lib/aerospike/command/command.rb +21 -7
- data/lib/aerospike/features.rb +3 -0
- data/lib/aerospike/operation.rb +7 -2
- data/lib/aerospike/policy/replica.rb +1 -1
- data/lib/aerospike/result_code.rb +108 -0
- data/lib/aerospike/utils/unpacker.rb +2 -2
- data/lib/aerospike/value/particle_type.rb +1 -1
- data/lib/aerospike/value/value.rb +107 -5
- data/lib/aerospike/version.rb +1 -1
- metadata +11 -2
@@ -22,12 +22,20 @@ module Aerospike
|
|
22
22
|
module ListSortFlags
|
23
23
|
|
24
24
|
##
|
25
|
-
#
|
26
|
-
|
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,25 +96,39 @@ 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, :flag
|
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, flag: 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
|
107
|
+
@flag = flag
|
65
108
|
@arguments = arguments
|
66
109
|
@return_type = return_type
|
67
110
|
self
|
68
111
|
end
|
69
112
|
|
113
|
+
##
|
114
|
+
# Creates a map create operation.
|
115
|
+
# Server creates map at given context level.
|
116
|
+
def self.create(bin_name, order, ctx: nil)
|
117
|
+
if !ctx || ctx.length == 0
|
118
|
+
# If context not defined, the set order for top-level bin map.
|
119
|
+
self.set_policy(MapPolicy.new(order: order, flag: 0), bin_name)
|
120
|
+
else
|
121
|
+
MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order[:attr], ctx: ctx, flag: order[:flag])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
70
125
|
##
|
71
126
|
# Create set map policy operation.
|
72
127
|
# Server sets map policy attributes. Server returns null.
|
73
128
|
#
|
74
129
|
# 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)
|
130
|
+
def self.set_policy(bin_name, policy, ctx: nil)
|
131
|
+
MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order[:attr], ctx: ctx)
|
77
132
|
end
|
78
133
|
|
79
134
|
##
|
@@ -82,18 +137,18 @@ module Aerospike
|
|
82
137
|
#
|
83
138
|
# The map policy dictates the type of map to create when it does not exist.
|
84
139
|
# 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)
|
140
|
+
def self.put(bin_name, key, value, ctx: nil, policy: MapPolicy::DEFAULT)
|
86
141
|
if policy.flags != MapWriteFlags::DEFAULT
|
87
|
-
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags)
|
142
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order[:attr], policy.flags, ctx: ctx)
|
88
143
|
else
|
89
144
|
case policy.write_mode
|
90
145
|
when MapWriteMode::UPDATE_ONLY
|
91
146
|
# 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)
|
147
|
+
MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value, ctx: ctx)
|
93
148
|
when MapWriteMode::CREATE_ONLY
|
94
|
-
MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order)
|
149
|
+
MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order[:attr], ctx: ctx)
|
95
150
|
else
|
96
|
-
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order)
|
151
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order[:attr], ctx: ctx)
|
97
152
|
end
|
98
153
|
end
|
99
154
|
end
|
@@ -104,18 +159,18 @@ module Aerospike
|
|
104
159
|
#
|
105
160
|
# The map policy dictates the type of map to create when it does not exist.
|
106
161
|
# 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)
|
162
|
+
def self.put_items(bin_name, values, ctx: nil, policy: MapPolicy::DEFAULT)
|
108
163
|
if policy.flags != MapWriteFlags::DEFAULT
|
109
|
-
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags)
|
164
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order[:attr], policy.flags, ctx: ctx)
|
110
165
|
else
|
111
166
|
case policy.write_mode
|
112
167
|
when MapWriteMode::UPDATE_ONLY
|
113
168
|
# 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)
|
169
|
+
MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values, ctx: ctx)
|
115
170
|
when MapWriteMode::CREATE_ONLY
|
116
|
-
MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order)
|
171
|
+
MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order[:attr], ctx: ctx)
|
117
172
|
else
|
118
|
-
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order)
|
173
|
+
MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order[:attr], ctx: ctx)
|
119
174
|
end
|
120
175
|
end
|
121
176
|
end
|
@@ -127,8 +182,8 @@ module Aerospike
|
|
127
182
|
#
|
128
183
|
# The map policy dictates the type of map to create when it does not exist.
|
129
184
|
# 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)
|
185
|
+
def self.increment(bin_name, key, incr, ctx: nil, policy: MapPolicy::DEFAULT)
|
186
|
+
MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order[:attr], ctx: ctx)
|
132
187
|
end
|
133
188
|
|
134
189
|
##
|
@@ -138,15 +193,15 @@ module Aerospike
|
|
138
193
|
#
|
139
194
|
# The map policy dictates the type of map to create when it does not exist.
|
140
195
|
# 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)
|
196
|
+
def self.decrement(bin_name, key, decr, ctx: nil, policy: MapPolicy::DEFAULT)
|
197
|
+
MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order[:attr], ctx: ctx)
|
143
198
|
end
|
144
199
|
|
145
200
|
##
|
146
201
|
# Create map clear operation.
|
147
202
|
# Server removes all items in map. Server returns null.
|
148
|
-
def self.clear(bin_name)
|
149
|
-
MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name)
|
203
|
+
def self.clear(bin_name, ctx: nil)
|
204
|
+
MapOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name, ctx: ctx)
|
150
205
|
end
|
151
206
|
|
152
207
|
##
|
@@ -154,8 +209,8 @@ module Aerospike
|
|
154
209
|
#
|
155
210
|
# Server removes map item identified by key and returns removed data
|
156
211
|
# 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)
|
212
|
+
def self.remove_by_key(bin_name, key, ctx: nil, return_type: nil)
|
213
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, ctx: ctx, return_type: return_type)
|
159
214
|
end
|
160
215
|
|
161
216
|
##
|
@@ -164,8 +219,8 @@ module Aerospike
|
|
164
219
|
# Server removes map items identified by keys.
|
165
220
|
#
|
166
221
|
# 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)
|
222
|
+
def self.remove_by_key_list(bin_name, keys, ctx: nil, return_type: MapReturnType::NONE)
|
223
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, ctx: ctx, return_type: return_type)
|
169
224
|
end
|
170
225
|
|
171
226
|
##
|
@@ -176,11 +231,11 @@ module Aerospike
|
|
176
231
|
# Server returns removed data specified by return_type.
|
177
232
|
#
|
178
233
|
# Deprecated. Use remove_by_key / remove_by_key_list instead.
|
179
|
-
def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE)
|
234
|
+
def self.remove_keys(bin_name, *keys, ctx: nil, return_type: MapReturnType::NONE)
|
180
235
|
if keys.length > 1
|
181
|
-
remove_by_key_list(bin_name, keys, return_type: return_type)
|
236
|
+
remove_by_key_list(bin_name, keys, ctx: ctx, return_type: return_type)
|
182
237
|
else
|
183
|
-
remove_by_key(bin_name, keys.first, return_type: return_type)
|
238
|
+
remove_by_key(bin_name, keys.first, ctx: ctx, return_type: return_type)
|
184
239
|
end
|
185
240
|
end
|
186
241
|
|
@@ -192,11 +247,11 @@ module Aerospike
|
|
192
247
|
# If key_end is null, the range is greater than equal to key_begin.
|
193
248
|
#
|
194
249
|
# 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)
|
250
|
+
def self.remove_by_key_range(bin_name, key_begin, key_end = nil, ctx: nil, return_type: MapReturnType::NONE)
|
196
251
|
if key_end
|
197
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
|
252
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, ctx: ctx, return_type: return_type)
|
198
253
|
else
|
199
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
|
254
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, ctx: ctx, return_type: return_type)
|
200
255
|
end
|
201
256
|
end
|
202
257
|
singleton_class.send(:alias_method, :remove_key_range, :remove_by_key_range)
|
@@ -226,11 +281,11 @@ module Aerospike
|
|
226
281
|
# * (5, -1) = [{4=2}, {5=15}, {9=10}]
|
227
282
|
# * (3, 2) = [{9=10}]
|
228
283
|
# * (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)
|
284
|
+
def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, ctx: nil, return_type: nil)
|
230
285
|
if count
|
231
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
|
286
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, ctx: ctx, return_type: return_type)
|
232
287
|
else
|
233
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
|
288
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, ctx: ctx, return_type: return_type)
|
234
289
|
end
|
235
290
|
end
|
236
291
|
|
@@ -240,8 +295,8 @@ module Aerospike
|
|
240
295
|
# Server removes map item identified by value.
|
241
296
|
#
|
242
297
|
# 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)
|
298
|
+
def self.remove_by_value(bin_name, value, ctx: nil, return_type: MapReturnType::NONE)
|
299
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
|
245
300
|
end
|
246
301
|
|
247
302
|
##
|
@@ -250,8 +305,8 @@ module Aerospike
|
|
250
305
|
# Server removes map items identified by value.
|
251
306
|
#
|
252
307
|
# 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)
|
308
|
+
def self.remove_by_value_list(bin_name, values, ctx: nil, return_type: MapReturnType::NONE)
|
309
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
|
255
310
|
end
|
256
311
|
|
257
312
|
##
|
@@ -262,11 +317,11 @@ module Aerospike
|
|
262
317
|
# Server returns removed data specified by return_type.
|
263
318
|
#
|
264
319
|
# Deprecated. Use remove_by_value / remove_by_value_list instead.
|
265
|
-
def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE)
|
320
|
+
def self.remove_values(bin_name, *values, ctx: nil, return_type: MapReturnType::NONE)
|
266
321
|
if values.length > 1
|
267
|
-
remove_by_value_list(bin_name, values, return_type: return_type)
|
322
|
+
remove_by_value_list(bin_name, values, ctx: ctx, return_type: return_type)
|
268
323
|
else
|
269
|
-
remove_by_value(bin_name, values.first, return_type: return_type)
|
324
|
+
remove_by_value(bin_name, values.first, ctx: ctx, return_type: return_type)
|
270
325
|
end
|
271
326
|
end
|
272
327
|
|
@@ -279,11 +334,11 @@ module Aerospike
|
|
279
334
|
# equal to value_begin.
|
280
335
|
#
|
281
336
|
# 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)
|
337
|
+
def self.remove_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: MapReturnType::NONE)
|
283
338
|
if value_end
|
284
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
339
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
|
285
340
|
else
|
286
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
341
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
|
287
342
|
end
|
288
343
|
end
|
289
344
|
singleton_class.send(:alias_method, :remove_value_range, :remove_by_value_range)
|
@@ -308,11 +363,11 @@ module Aerospike
|
|
308
363
|
# * (value, rank) = [removed items]
|
309
364
|
# * (11, 1) = [{0=17}]
|
310
365
|
# * (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)
|
366
|
+
def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: nil)
|
312
367
|
if count
|
313
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
368
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
|
314
369
|
else
|
315
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
370
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
|
316
371
|
end
|
317
372
|
end
|
318
373
|
|
@@ -322,8 +377,8 @@ module Aerospike
|
|
322
377
|
# Server removes map item identified by index.
|
323
378
|
#
|
324
379
|
# 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)
|
380
|
+
def self.remove_by_index(bin_name, index, ctx: nil, return_type: MapReturnType::NONE)
|
381
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
|
327
382
|
end
|
328
383
|
singleton_class.send(:alias_method, :remove_index, :remove_by_index)
|
329
384
|
|
@@ -335,11 +390,11 @@ module Aerospike
|
|
335
390
|
# specified index to the end of map.
|
336
391
|
#
|
337
392
|
# Server returns removed data specified by return_type.
|
338
|
-
def self.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
|
393
|
+
def self.remove_by_index_range(bin_name, index, count = nil, ctx: nil, return_type: MapReturnType::NONE)
|
339
394
|
if count
|
340
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
395
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
|
341
396
|
else
|
342
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
397
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
|
343
398
|
end
|
344
399
|
end
|
345
400
|
singleton_class.send(:alias_method, :remove_index_range, :remove_by_index_range)
|
@@ -350,8 +405,8 @@ module Aerospike
|
|
350
405
|
# Server removes map item identified by rank.
|
351
406
|
#
|
352
407
|
# 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)
|
408
|
+
def self.remove_by_rank(bin_name, rank, ctx: nil, return_type: MapReturnType::NONE)
|
409
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
|
355
410
|
end
|
356
411
|
|
357
412
|
##
|
@@ -362,26 +417,26 @@ module Aerospike
|
|
362
417
|
# to the last ranked.
|
363
418
|
#
|
364
419
|
# Server returns removed data specified by return_type.
|
365
|
-
def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
|
420
|
+
def self.remove_by_rank_range(bin_name, rank, count = nil, ctx: nil, return_type: MapReturnType::NONE)
|
366
421
|
if count
|
367
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
422
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
|
368
423
|
else
|
369
|
-
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
|
424
|
+
MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
|
370
425
|
end
|
371
426
|
end
|
372
427
|
|
373
428
|
##
|
374
429
|
# Create map size operation.
|
375
430
|
# Server returns size of map.
|
376
|
-
def self.size(bin_name)
|
377
|
-
MapOperation.new(Operation::CDT_READ, SIZE, bin_name)
|
431
|
+
def self.size(bin_name, ctx: nil)
|
432
|
+
MapOperation.new(Operation::CDT_READ, SIZE, bin_name, ctx: ctx)
|
378
433
|
end
|
379
434
|
|
380
435
|
##
|
381
436
|
# Create map get by key operation.
|
382
437
|
# 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)
|
438
|
+
def self.get_by_key(bin_name, key, ctx: nil, return_type: MapReturnType::NONE)
|
439
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, ctx: ctx, return_type: return_type)
|
385
440
|
end
|
386
441
|
singleton_class.send(:alias_method, :get_key, :get_by_key)
|
387
442
|
|
@@ -391,8 +446,8 @@ module Aerospike
|
|
391
446
|
# Server selects map items identified by keys.
|
392
447
|
#
|
393
448
|
# 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)
|
449
|
+
def self.get_by_key_list(bin_name, keys, ctx: nil, return_type: MapReturnType::NONE)
|
450
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, ctx: ctx, return_type: return_type)
|
396
451
|
end
|
397
452
|
|
398
453
|
# Create map get by key range operation.
|
@@ -403,11 +458,11 @@ module Aerospike
|
|
403
458
|
# key_begin.
|
404
459
|
#
|
405
460
|
# 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)
|
461
|
+
def self.get_by_key_range(bin_name, key_begin, key_end = nil, ctx: nil, return_type: MapReturnType::NONE)
|
407
462
|
if key_end
|
408
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
|
463
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, ctx: ctx, return_type: return_type)
|
409
464
|
else
|
410
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
|
465
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, ctx: ctx, return_type: return_type)
|
411
466
|
end
|
412
467
|
end
|
413
468
|
singleton_class.send(:alias_method, :get_key_range, :get_by_key_range)
|
@@ -438,11 +493,11 @@ module Aerospike
|
|
438
493
|
# * (5, -1) = [{4=2}, {5=15}, {9=10}]
|
439
494
|
# * (3, 2) = [{9=10}]
|
440
495
|
# * (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)
|
496
|
+
def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, ctx: nil, return_type: nil)
|
442
497
|
if count
|
443
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
|
498
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, ctx: ctx, return_type: return_type)
|
444
499
|
else
|
445
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
|
500
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, ctx: ctx, return_type: return_type)
|
446
501
|
end
|
447
502
|
end
|
448
503
|
|
@@ -451,8 +506,8 @@ module Aerospike
|
|
451
506
|
# Server selects map items identified by value.
|
452
507
|
#
|
453
508
|
# 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)
|
509
|
+
def self.get_by_value(bin_name, value, ctx: nil, return_type: MapReturnType::NONE)
|
510
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
|
456
511
|
end
|
457
512
|
singleton_class.send(:alias_method, :get_value, :get_by_value)
|
458
513
|
|
@@ -461,8 +516,8 @@ module Aerospike
|
|
461
516
|
# Server selects map items identified by value list.
|
462
517
|
#
|
463
518
|
# 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)
|
519
|
+
def self.get_by_value_list(bin_name, values, ctx: nil, return_type: MapReturnType::NONE)
|
520
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
|
466
521
|
end
|
467
522
|
|
468
523
|
# Create map get by value range operation.
|
@@ -473,11 +528,11 @@ module Aerospike
|
|
473
528
|
# equal to value_begin.
|
474
529
|
#
|
475
530
|
# 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)
|
531
|
+
def self.get_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: MapReturnType::NONE)
|
477
532
|
if value_end
|
478
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
533
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
|
479
534
|
else
|
480
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
535
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
|
481
536
|
end
|
482
537
|
end
|
483
538
|
singleton_class.send(:alias_method, :get_value_range, :get_by_value_range)
|
@@ -502,11 +557,11 @@ module Aerospike
|
|
502
557
|
# * (value, rank) = [selected items]
|
503
558
|
# * (11, 1) = [{0=17}]
|
504
559
|
# * (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)
|
560
|
+
def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: nil)
|
506
561
|
if count
|
507
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
562
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
|
508
563
|
else
|
509
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
564
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
|
510
565
|
end
|
511
566
|
end
|
512
567
|
|
@@ -516,8 +571,8 @@ module Aerospike
|
|
516
571
|
# Server selects map item identified by index.
|
517
572
|
#
|
518
573
|
# 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)
|
574
|
+
def self.get_by_index(bin_name, index, ctx: nil, return_type: MapReturnType::NONE)
|
575
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
|
521
576
|
end
|
522
577
|
singleton_class.send(:alias_method, :get_index, :get_by_index)
|
523
578
|
|
@@ -528,11 +583,11 @@ module Aerospike
|
|
528
583
|
# specified index to the end of map.
|
529
584
|
#
|
530
585
|
# Server returns selected data specified by return_type.
|
531
|
-
def self.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
|
586
|
+
def self.get_by_index_range(bin_name, index, count = nil, ctx: nil, return_type: MapReturnType::NONE)
|
532
587
|
if count
|
533
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
588
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
|
534
589
|
else
|
535
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
590
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
|
536
591
|
end
|
537
592
|
end
|
538
593
|
singleton_class.send(:alias_method, :get_index_range, :get_by_index_range)
|
@@ -542,8 +597,8 @@ module Aerospike
|
|
542
597
|
# Server selects map item identified by rank.
|
543
598
|
#
|
544
599
|
# 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)
|
600
|
+
def self.get_by_rank(bin_name, rank, ctx: nil, return_type: MapReturnType::NONE)
|
601
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
|
547
602
|
end
|
548
603
|
|
549
604
|
# Create map get by rank range operation.
|
@@ -553,11 +608,11 @@ module Aerospike
|
|
553
608
|
# to the last ranked item.
|
554
609
|
#
|
555
610
|
# Server returns selected data specified by return_type.
|
556
|
-
def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
|
611
|
+
def self.get_by_rank_range(bin_name, rank, count = nil, ctx: nil, return_type: MapReturnType::NONE)
|
557
612
|
if count
|
558
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
613
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
|
559
614
|
else
|
560
|
-
MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
|
615
|
+
MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
|
561
616
|
end
|
562
617
|
end
|
563
618
|
|
@@ -575,12 +630,27 @@ module Aerospike
|
|
575
630
|
|
576
631
|
def pack_bin_value
|
577
632
|
bytes = nil
|
633
|
+
|
634
|
+
args = arguments.dup
|
635
|
+
args.unshift(return_type) if return_type
|
636
|
+
|
578
637
|
Packer.use do |packer|
|
579
|
-
|
580
|
-
|
581
|
-
|
638
|
+
if @ctx != nil && @ctx.length > 0
|
639
|
+
packer.write_array_header(3)
|
640
|
+
Value.of(0xff).pack(packer)
|
641
|
+
|
642
|
+
pack_context(packer)
|
643
|
+
|
644
|
+
packer.write_array_header(args.length+1)
|
645
|
+
Value.of(@map_op).pack(packer)
|
646
|
+
else
|
647
|
+
packer.write_raw_short(@map_op)
|
648
|
+
if args.length > 0
|
649
|
+
packer.write_array_header(args.length)
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
582
653
|
if args.length > 0
|
583
|
-
packer.write_array_header(args.length)
|
584
654
|
args.each do |value|
|
585
655
|
Value.of(value).pack(packer)
|
586
656
|
end
|
@@ -590,6 +660,23 @@ module Aerospike
|
|
590
660
|
BytesValue.new(bytes)
|
591
661
|
end
|
592
662
|
|
663
|
+
def pack_context(packer)
|
664
|
+
packer.write_array_header(@ctx.length*2)
|
665
|
+
if @flag
|
666
|
+
(1...@ctx.length).each do |i|
|
667
|
+
Value.of(@ctx[i].id).pack(packer)
|
668
|
+
Value.of(@ctx[i].value).pack(packer)
|
669
|
+
end
|
670
|
+
|
671
|
+
Value.of(@ctx[-1].id | @flag).pack(packer)
|
672
|
+
Value.of(@ctx[-1].value).pack(packer)
|
673
|
+
else
|
674
|
+
@ctx.each do |ctx|
|
675
|
+
Value.of(ctx.id).pack(packer)
|
676
|
+
Value.of(ctx.value).pack(packer)
|
677
|
+
end
|
678
|
+
end
|
679
|
+
end
|
593
680
|
end
|
594
681
|
|
595
682
|
end
|