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.
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Aerospike, Inc.
4
+ #
5
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
+ # license agreements.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
+ # use this file except in compliance with the License. You may obtain a copy of
10
+ # the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+ # License for the specific language governing permissions and limitations under
18
+ # the License.
19
+
20
+ module Aerospike
21
+ module CDT
22
+
23
+ # BitPolicy determines the Bit operation policy.
24
+ class BitPolicy
25
+
26
+ attr_accessor :flags
27
+
28
+ def initialize(flags = BitWriteFlags::DEFAULT)
29
+ @flags = flags
30
+ end
31
+
32
+ DEFAULT = BitPolicy.new
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Aerospike, Inc.
4
+ #
5
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
+ # license agreements.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
+ # use this file except in compliance with the License. You may obtain a copy of
10
+ # the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+ # License for the specific language governing permissions and limitations under
18
+ # the License.
19
+
20
+ module Aerospike
21
+ module CDT
22
+
23
+ ##
24
+ # BitResizeFlags specifies the bitwise operation flags for resize.
25
+ module BitResizeFlags
26
+
27
+ ##
28
+ # Default specifies the defalt flag.
29
+ DEFAULT = 0
30
+
31
+ ##
32
+ # Adds/removes bytes from the beginning instead of the end.
33
+ FROM_FRONT = 1
34
+
35
+ ##
36
+ # only allow the byte array size to increase.
37
+ GROW_ONLY = 2
38
+
39
+ ##
40
+ # only allow the byte array size to decrease.
41
+ SHRINK_ONLY = 4
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Aerospike, Inc.
4
+ #
5
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
+ # license agreements.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
+ # use this file except in compliance with the License. You may obtain a copy of
10
+ # the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+ # License for the specific language governing permissions and limitations under
18
+ # the License.
19
+
20
+ module Aerospike
21
+ module CDT
22
+
23
+ ##
24
+ # BitWriteFlags specify bitwise operation policy write flags.
25
+ module BitWriteFlags
26
+
27
+ ##
28
+ # Default allows create or update.
29
+ DEFAULT = 0
30
+
31
+ ##
32
+ # If the bin already exists, the operation will be denied.
33
+ # If the bin does not exist, a new bin will be created.
34
+ CREATE_ONLY = 1
35
+
36
+ ##
37
+ # If the bin already exists, the bin will be overwritten.
38
+ # If the bin does not exist, the operation will be denied.
39
+ UPDATE_ONLY = 2
40
+
41
+ ##
42
+ # Will not raise error if operation is denied.
43
+ NO_FAIL = 4
44
+
45
+ ##
46
+ # Partial allows other valid operations to be committed if this operations is
47
+ # denied due to flag constraints.
48
+ PARTIAL = 8
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Aerospike, Inc.
4
+ #
5
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
+ # license agreements.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
+ # use this file except in compliance with the License. You may obtain a copy of
10
+ # the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+ # License for the specific language governing permissions and limitations under
18
+ # the License.
19
+
20
+ module Aerospike
21
+ module CDT
22
+
23
+ ##
24
+ # Nested CDT context. Identifies the location of nested list/map to apply the operation.
25
+ # for the current level.
26
+ # An array of CTX identifies location of the list/map on multiple
27
+ # levels on nesting.
28
+ class Context
29
+
30
+ attr_accessor :id, :value
31
+
32
+ def initialize(id, value)
33
+ @id = id
34
+ @value = value
35
+ end
36
+
37
+ ##
38
+ # Lookup list by index offset.
39
+ # If the index is negative, the resolved index starts backwards from end of list.
40
+ # If an index is out of bounds, a parameter error will be returned.
41
+ # Examples:
42
+ # 0: First item.
43
+ # 4: Fifth item.
44
+ # -1: Last item.
45
+ # -3: Third to last item.
46
+ def self.list_index(index)
47
+ Context.new(0x10, index)
48
+ end
49
+
50
+ ##
51
+ # Lookup list by rank.
52
+ # 0 = smallest value
53
+ # N = Nth smallest value
54
+ # -1 = largest value
55
+ def self.list_rank(rank)
56
+ Context.new(0x11, rank)
57
+ end
58
+
59
+ ##
60
+ # Lookup list by value.
61
+ def self.list_value(key)
62
+ Context.new(0x13, key)
63
+ end
64
+
65
+ ##
66
+ # Lookup map by index offset.
67
+ # If the index is negative, the resolved index starts backwards from end of list.
68
+ # If an index is out of bounds, a parameter error will be returned.
69
+ # Examples:
70
+ # 0: First item.
71
+ # 4: Fifth item.
72
+ # -1: Last item.
73
+ # -3: Third to last item.
74
+ def self.map_index(index)
75
+ Context.new(0x20, index)
76
+ end
77
+
78
+ ##
79
+ # Lookup map by rank.
80
+ # 0 = smallest value
81
+ # N = Nth smallest value
82
+ # -1 = largest value
83
+ def self.map_rank(rank)
84
+ Context.new(0x21, rank)
85
+ end
86
+
87
+ ##
88
+ # Lookup map by key.
89
+ def self.map_key(key)
90
+ Context.new(0x22, key)
91
+ end
92
+
93
+ ##
94
+ # Lookup map by value.
95
+ def self.map_value(key)
96
+ Context.new(0x23, key)
97
+ end
98
+
99
+ end
100
+ end
101
+ end
@@ -21,23 +21,32 @@ module Aerospike
21
21
  module CDT
22
22
 
23
23
  ##
24
- # List bin operations. Create list operations used by the Client#operate
25
- # command. List operations support negative indexing. If the index is
26
- # negative, the resolved index starts backwards from end of list.
24
+ # List operations support negative indexing. If the index is negative, the
25
+ # resolved index starts backwards from end of list. If an index is out of bounds,
26
+ # a parameter error will be returned. If a range is partially out of bounds, the
27
+ # valid part of the range will be returned. Index/Range examples:
27
28
  #
28
29
  # Index/Range examples:
29
- # * Index 0: First item in list.
30
- # * Index 4: Fifth item in list.
31
- # * Index -1: Last item in list.
32
- # * Index -3: Third to last item in list.
33
- # * Index 1 Count 2: Second and third items in list.
34
- # * Index -3 Count 3: Last three items in list.
35
- # * Index -5 Count 4: Range between fifth to last item to second to last
36
- # item inclusive.
37
30
  #
38
- # If an index is out of bounds, a parameter error will be returned. If a
39
- # range is partially out of bounds, the valid part of the range will be
40
- # returned.
31
+ # Index 0: First item in list.
32
+ # Index 4: Fifth item in list.
33
+ # Index -1: Last item in list.
34
+ # Index -3: Third to last item in list.
35
+ # Index 1 Count 2: Second and third items in list.
36
+ # Index -3 Count 3: Last three items in list.
37
+ # Index -5 Count 4: Range between fifth to last item to second to last item inclusive.
38
+ #
39
+ # Nested CDT operations are supported by optional Ctx context arguments. Examples:
40
+ #
41
+ # bin = [[7,9,5],[1,2,3],[6,5,4,1]]
42
+ # Append 11 to last list.
43
+ # ListOperation.append("bin", 11, ctx: [Context.list_index(-1)])
44
+ # bin result = [[7,9,5],[1,2,3],[6,5,4,1,11]]
45
+ #
46
+ # bin = {key1:[[7,9,5],[13]], key2:[[9],[2,4],[6,1,9]], key3:[[6,5]]}
47
+ # Append 11 to lowest ranked list in map identified by "key2".
48
+ # ListOperation.append("bin", 11, ctx: [Context.map_key("key2"), Context.list_rank(0)])
49
+ # bin result = {key1:[[7,9,5],[13]], key2:[[9],[2,4,11],[6,1,9]], key3:[[6,5]]}
41
50
 
42
51
  class ListOperation < Operation
43
52
 
@@ -75,13 +84,14 @@ module Aerospike
75
84
  REMOVE_BY_RANK_RANGE = 39
76
85
  REMOVE_BY_VALUE_REL_RANK_RANGE = 40
77
86
 
78
- attr_reader :list_op, :arguments, :policy, :return_type
87
+ attr_reader :list_op, :arguments, :policy, :return_type, :ctx
79
88
 
80
- def initialize(op_type, list_op, bin_name, *arguments, return_type: nil)
89
+ def initialize(op_type, list_op, bin_name, *arguments, return_type: nil, ctx: nil)
81
90
  @op_type = op_type
82
91
  @bin_name = bin_name
83
92
  @bin_value = nil
84
93
  @list_op = list_op
94
+ @ctx = ctx
85
95
  @arguments = arguments
86
96
  @return_type = return_type
87
97
  end
@@ -90,19 +100,19 @@ module Aerospike
90
100
  # Create a set list order operation.
91
101
  # Server sets list order.
92
102
  # Server returns null.
93
- def self.set_order(bin_name, order)
94
- ListOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order)
103
+ def self.set_order(bin_name, order, ctx: nil)
104
+ ListOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order, ctx: ctx)
95
105
  end
96
106
 
97
107
  ##
98
108
  # Create list append operation.
99
109
  # Server appends value(s) to end of the list bin.
100
110
  # Server returns list size.
101
- def self.append(bin_name, *values, policy: ListPolicy::DEFAULT)
111
+ def self.append(bin_name, *values, ctx: nil, policy: ListPolicy::DEFAULT)
102
112
  if values.length > 1
103
- ListOperation.new(Operation::CDT_MODIFY, APPEND_ITEMS, bin_name, values, policy.order, policy.flags)
113
+ ListOperation.new(Operation::CDT_MODIFY, APPEND_ITEMS, bin_name, values, policy.order, policy.flags, ctx: ctx)
104
114
  else
105
- ListOperation.new(Operation::CDT_MODIFY, APPEND, bin_name, values.first, policy.order, policy.flags)
115
+ ListOperation.new(Operation::CDT_MODIFY, APPEND, bin_name, values.first, policy.order, policy.flags, ctx: ctx)
106
116
  end
107
117
  end
108
118
 
@@ -110,19 +120,19 @@ module Aerospike
110
120
  # Create list insert operation.
111
121
  # Server inserts value(s) at the specified index of the list bin.
112
122
  # Server returns list size.
113
- def self.insert(bin_name, index, *values, policy: ListPolicy::DEFAULT)
123
+ def self.insert(bin_name, index, *values, ctx: nil, policy: ListPolicy::DEFAULT)
114
124
  if values.length > 1
115
- ListOperation.new(Operation::CDT_MODIFY, INSERT_ITEMS, bin_name, index, values, policy.flags)
125
+ ListOperation.new(Operation::CDT_MODIFY, INSERT_ITEMS, bin_name, index, values, policy.flags, ctx: ctx)
116
126
  else
117
- ListOperation.new(Operation::CDT_MODIFY, INSERT, bin_name, index, values.first, policy.flags)
127
+ ListOperation.new(Operation::CDT_MODIFY, INSERT, bin_name, index, values.first, policy.flags, ctx: ctx)
118
128
  end
119
129
  end
120
130
 
121
131
  ##
122
132
  # Create list pop operation.
123
133
  # Server returns item at specified index and removes item from list bin.
124
- def self.pop(bin_name, index)
125
- ListOperation.new(Operation::CDT_MODIFY, POP, bin_name, index)
134
+ def self.pop(bin_name, index, ctx: nil)
135
+ ListOperation.new(Operation::CDT_MODIFY, POP, bin_name, index, ctx: ctx)
126
136
  end
127
137
 
128
138
  ##
@@ -131,11 +141,11 @@ module Aerospike
131
141
  # items from list bin. If "count" is not specified, the server returns
132
142
  # items starting at the specified index to the end of the list and
133
143
  # removes those items from the list bin.
134
- def self.pop_range(bin_name, index, count=nil)
144
+ def self.pop_range(bin_name, index, count=nil, ctx: nil)
135
145
  if count
136
- ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, count)
146
+ ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, count, ctx: ctx)
137
147
  else
138
- ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index)
148
+ ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, ctx: ctx)
139
149
  end
140
150
  end
141
151
 
@@ -143,8 +153,8 @@ module Aerospike
143
153
  # Create list remove operation.
144
154
  # Server removes item at specified index from list bin.
145
155
  # Server returns number of items removed.
146
- def self.remove(bin_name, index)
147
- ListOperation.new(Operation::CDT_MODIFY, REMOVE, bin_name, index)
156
+ def self.remove(bin_name, index, ctx: nil)
157
+ ListOperation.new(Operation::CDT_MODIFY, REMOVE, bin_name, index, ctx: ctx)
148
158
  end
149
159
 
150
160
  ##
@@ -153,11 +163,11 @@ module Aerospike
153
163
  # "count" is not specified, the server removes all items starting at the
154
164
  # specified index to the end of the list.
155
165
  # Server returns number of items removed.
156
- def self.remove_range(bin_name, index, count=nil)
166
+ def self.remove_range(bin_name, index, count=nil, ctx: nil)
157
167
  if count
158
- ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, count)
168
+ ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, count, ctx: ctx)
159
169
  else
160
- ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index)
170
+ ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, ctx: ctx)
161
171
  end
162
172
  end
163
173
 
@@ -165,8 +175,8 @@ module Aerospike
165
175
  # Create list set operation.
166
176
  # Server sets item value at specified index in list bin.
167
177
  # Server does not return a result by default.
168
- def self.set(bin_name, index, value, policy: ListPolicy::DEFAULT)
169
- ListOperation.new(Operation::CDT_MODIFY, SET, bin_name, index, value, policy.flags)
178
+ def self.set(bin_name, index, value, ctx: nil, policy: ListPolicy::DEFAULT)
179
+ ListOperation.new(Operation::CDT_MODIFY, SET, bin_name, index, value, policy.flags, ctx: ctx)
170
180
  end
171
181
 
172
182
  ##
@@ -176,24 +186,24 @@ module Aerospike
176
186
  # by index and count.
177
187
  #
178
188
  # Server returns number of items removed.
179
- def self.trim(bin_name, index, count)
180
- ListOperation.new(Operation::CDT_MODIFY, TRIM, bin_name, index, count)
189
+ def self.trim(bin_name, index, count, ctx: nil)
190
+ ListOperation.new(Operation::CDT_MODIFY, TRIM, bin_name, index, count, ctx: ctx)
181
191
  end
182
192
 
183
193
  ##
184
194
  # Create list clear operation.
185
195
  # Server removes all items in the list bin.
186
196
  # Server does not return a result by default.
187
- def self.clear(bin_name)
188
- ListOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name)
197
+ def self.clear(bin_name, ctx: nil)
198
+ ListOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name, ctx: ctx)
189
199
  end
190
200
 
191
201
  ##
192
202
  # Create list increment operation.
193
203
  # Server increments list[index] by value. If not specified, value defaults to 1.
194
204
  # Server returns the value of list[index] after the operation.
195
- def self.increment(bin_name, index, value = 1, policy: ListPolicy::DEFAULT)
196
- ListOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, index, value, policy.order, policy.flags)
205
+ def self.increment(bin_name, index, value = 1, ctx: nil, policy: ListPolicy::DEFAULT)
206
+ ListOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, index, value, policy.order, policy.flags, ctx: ctx)
197
207
  end
198
208
 
199
209
  ##
@@ -207,15 +217,15 @@ module Aerospike
207
217
  ##
208
218
  # Create list size operation.
209
219
  # Server returns size of list.
210
- def self.size(bin_name)
211
- ListOperation.new(Operation::CDT_READ, SIZE, bin_name)
220
+ def self.size(bin_name, ctx: nil)
221
+ ListOperation.new(Operation::CDT_READ, SIZE, bin_name, ctx: ctx)
212
222
  end
213
223
 
214
224
  ##
215
225
  # Create list get operation.
216
226
  # Server returns the item at the specified index in the list bin.
217
- def self.get(bin_name, index)
218
- ListOperation.new(Operation::CDT_READ, GET, bin_name, index)
227
+ def self.get(bin_name, index, ctx: nil)
228
+ ListOperation.new(Operation::CDT_READ, GET, bin_name, index, ctx: ctx)
219
229
  end
220
230
 
221
231
  ##
@@ -223,11 +233,11 @@ module Aerospike
223
233
  # Server returns "count" items starting at the specified index in the
224
234
  # list bin. If "count" is not specified, the server returns all items
225
235
  # starting at the specified index to the end of the list.
226
- def self.get_range(bin_name, index, count=nil)
236
+ def self.get_range(bin_name, index, count=nil, ctx: nil)
227
237
  if count
228
- ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, count)
238
+ ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, count, ctx: ctx)
229
239
  else
230
- ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index)
240
+ ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, ctx: ctx)
231
241
  end
232
242
  end
233
243
 
@@ -236,8 +246,8 @@ module Aerospike
236
246
  # Server selects list item identified by index.
237
247
  #
238
248
  # Server returns selected data specified by return_type.
239
- def self.get_by_index(bin_name, index, return_type: ListReturnType::NONE)
240
- ListOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type)
249
+ def self.get_by_index(bin_name, index, ctx: nil, return_type: ListReturnType::NONE)
250
+ ListOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type, ctx: ctx)
241
251
  end
242
252
 
243
253
  # Create list get by index range operation.
@@ -245,11 +255,11 @@ module Aerospike
245
255
  # Server selects list item identified by index range
246
256
  #
247
257
  # Server returns selected data specified by return_type.
248
- def self.get_by_index_range(bin_name, index, count=nil, return_type: ListReturnType::NONE)
258
+ def self.get_by_index_range(bin_name, index, count=nil, ctx: nil, return_type: ListReturnType::NONE)
249
259
  if count
250
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
260
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
251
261
  else
252
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
262
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
253
263
  end
254
264
  end
255
265
 
@@ -258,8 +268,8 @@ module Aerospike
258
268
  # Server selects list item identified by rank.
259
269
  #
260
270
  # Server returns selected data specified by return_type.
261
- def self.get_by_rank(bin_name, rank, return_type: ListReturnType::NONE)
262
- ListOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type)
271
+ def self.get_by_rank(bin_name, rank, ctx: nil, return_type: ListReturnType::NONE)
272
+ ListOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
263
273
  end
264
274
 
265
275
  # Create list get by rank range operation.
@@ -267,11 +277,11 @@ module Aerospike
267
277
  # Server selects list item identified by rank range.
268
278
  #
269
279
  # Server returns selected data specified by return_type.
270
- def self.get_by_rank_range(bin_name, rank, count=nil, return_type: ListReturnType::NONE)
280
+ def self.get_by_rank_range(bin_name, rank, count=nil, ctx: nil, return_type: ListReturnType::NONE)
271
281
  if count
272
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
282
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
273
283
  else
274
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
284
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
275
285
  end
276
286
  end
277
287
 
@@ -280,8 +290,8 @@ module Aerospike
280
290
  # Server selects list items identified by value.
281
291
  #
282
292
  # Server returns selected data specified by return_type.
283
- def self.get_by_value(bin_name, value, return_type: ListReturnType::NONE)
284
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type)
293
+ def self.get_by_value(bin_name, value, ctx: nil, return_type: ListReturnType::NONE)
294
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
285
295
  end
286
296
 
287
297
  # Create list get by value range operation.
@@ -292,11 +302,11 @@ module Aerospike
292
302
  # equal to value_begin.
293
303
  #
294
304
  # Server returns selected data specified by return_type.
295
- def self.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: ListReturnType::NONE)
305
+ def self.get_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: ListReturnType::NONE)
296
306
  if value_end
297
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
307
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
298
308
  else
299
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
309
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
300
310
  end
301
311
  end
302
312
 
@@ -305,8 +315,8 @@ module Aerospike
305
315
  # Server selects list items identified by values.
306
316
  #
307
317
  # Server returns selected data specified by return_type.
308
- def self.get_by_value_list(bin_name, values, return_type: ListReturnType::NONE)
309
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, return_type: return_type)
318
+ def self.get_by_value_list(bin_name, values, ctx: nil, return_type: ListReturnType::NONE)
319
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
310
320
  end
311
321
 
312
322
  # Create list get by value relative to rank range list operation.
@@ -339,11 +349,11 @@ module Aerospike
339
349
  # <li>(3, 3) = [11, 15]</li>
340
350
  # <li>(3, -3) = [0, 4, 5, 9, 11, 15]</li>
341
351
  # </ul>
342
- def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: ListReturnType::NONE)
352
+ def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: ListReturnType::NONE)
343
353
  if count
344
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
354
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
345
355
  else
346
- InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
356
+ InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
347
357
  end
348
358
  end
349
359
 
@@ -352,8 +362,8 @@ module Aerospike
352
362
  # Server removes list item identified by index.
353
363
  #
354
364
  # Server returns selected data specified by return_type.
355
- def self.remove_by_index(bin_name, index, return_type: ListReturnType::NONE)
356
- ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type)
365
+ def self.remove_by_index(bin_name, index, ctx: nil, return_type: ListReturnType::NONE)
366
+ ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
357
367
  end
358
368
 
359
369
  # Create list remove by index range operation.
@@ -361,11 +371,11 @@ module Aerospike
361
371
  # Server removes list item identified by index range
362
372
  #
363
373
  # Server returns selected data specified by return_type.
364
- def self.remove_by_index_range(bin_name, index, count=nil, return_type: ListReturnType::NONE)
374
+ def self.remove_by_index_range(bin_name, index, count=nil, ctx: nil, return_type: ListReturnType::NONE)
365
375
  if count
366
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
376
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
367
377
  else
368
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
378
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
369
379
  end
370
380
  end
371
381
 
@@ -374,8 +384,8 @@ module Aerospike
374
384
  # Server removes list item identified by rank.
375
385
  #
376
386
  # Server returns selected data specified by return_type.
377
- def self.remove_by_rank(bin_name, rank, return_type: ListReturnType::NONE)
378
- ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type)
387
+ def self.remove_by_rank(bin_name, rank, ctx: nil, return_type: ListReturnType::NONE)
388
+ ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
379
389
  end
380
390
 
381
391
  # Create list remove by rank range operation.
@@ -383,11 +393,11 @@ module Aerospike
383
393
  # Server removes list item identified by rank range.
384
394
  #
385
395
  # Server returns selected data specified by return_type.
386
- def self.remove_by_rank_range(bin_name, rank, count=nil, return_type: ListReturnType::NONE)
396
+ def self.remove_by_rank_range(bin_name, rank, count=nil, ctx: nil, return_type: ListReturnType::NONE)
387
397
  if count
388
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
398
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
389
399
  else
390
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
400
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
391
401
  end
392
402
  end
393
403
 
@@ -396,8 +406,8 @@ module Aerospike
396
406
  # Server removes list items identified by value.
397
407
  #
398
408
  # Server returns selected data specified by return_type.
399
- def self.remove_by_value(bin_name, value, return_type: ListReturnType::NONE)
400
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, return_type: return_type)
409
+ def self.remove_by_value(bin_name, value, ctx: nil, return_type: ListReturnType::NONE)
410
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
401
411
  end
402
412
 
403
413
  # Create list remove by value range operation.
@@ -408,11 +418,11 @@ module Aerospike
408
418
  # equal to value_begin.
409
419
  #
410
420
  # Server returns selected data specified by return_type.
411
- def self.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: ListReturnType::NONE)
421
+ def self.remove_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: ListReturnType::NONE)
412
422
  if value_end
413
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
423
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
414
424
  else
415
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
425
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
416
426
  end
417
427
  end
418
428
 
@@ -421,8 +431,8 @@ module Aerospike
421
431
  # Server removes list items identified by values.
422
432
  #
423
433
  # Server returns selected data specified by return_type.
424
- def self.remove_by_value_list(bin_name, values, return_type: ListReturnType::NONE)
425
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
434
+ def self.remove_by_value_list(bin_name, values, ctx: nil, return_type: ListReturnType::NONE)
435
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
426
436
  end
427
437
 
428
438
  # Create list remove by value relative to rank range list operation.
@@ -455,11 +465,11 @@ module Aerospike
455
465
  # <li>(3, 3) = [11, 15]</li>
456
466
  # <li>(3, -3) = [0, 4, 5, 9, 11, 15]</li>
457
467
  # </ul>
458
- def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: ListReturnType::NONE)
468
+ def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: ListReturnType::NONE)
459
469
  if count
460
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
470
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
461
471
  else
462
- InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
472
+ InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
463
473
  end
464
474
  end
465
475
 
@@ -481,16 +491,36 @@ module Aerospike
481
491
 
482
492
  def pack_bin_value
483
493
  bytes = nil
494
+
495
+ args = arguments.dup
496
+ if return_type
497
+ rt = return_type
498
+ rt |= ListReturnType::INVERTED if invert_selection?
499
+ args.unshift(rt)
500
+ end
501
+
484
502
  Packer.use do |packer|
485
- packer.write_raw_short(list_op)
486
- args = arguments.dup
487
- if return_type
488
- rt = return_type
489
- rt |= ListReturnType::INVERTED if invert_selection?
490
- args.unshift(rt)
503
+ if @ctx != nil && @ctx.length > 0
504
+ packer.write_array_header(3)
505
+ Value.of(0xff).pack(packer)
506
+
507
+ packer.write_array_header(@ctx.length*2)
508
+ @ctx.each do |ctx|
509
+ Value.of(ctx.id).pack(packer)
510
+ Value.of(ctx.value).pack(packer)
511
+ end
512
+
513
+ packer.write_array_header(args.length+1)
514
+ Value.of(@list_op).pack(packer)
515
+ else
516
+ packer.write_raw_short(@list_op)
517
+
518
+ if args.length > 0
519
+ packer.write_array_header(args.length)
520
+ end
491
521
  end
522
+
492
523
  if args.length > 0
493
- packer.write_array_header(args.length)
494
524
  args.each do |value|
495
525
  Value.of(value).pack(packer)
496
526
  end