aerospike 2.11.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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -1
  3. data/README.md +1 -1
  4. data/lib/aerospike.rb +17 -4
  5. data/lib/aerospike/aerospike_exception.rb +7 -1
  6. data/lib/aerospike/atomic/atomic.rb +1 -1
  7. data/lib/aerospike/bin.rb +1 -1
  8. data/lib/aerospike/cdt/bit_operation.rb +376 -0
  9. data/lib/aerospike/cdt/bit_overflow_action.rb +46 -0
  10. data/lib/aerospike/cdt/bit_policy.rb +36 -0
  11. data/lib/aerospike/cdt/bit_resize_flags.rb +44 -0
  12. data/lib/aerospike/cdt/bit_write_flags.rb +51 -0
  13. data/lib/aerospike/cdt/context.rb +101 -0
  14. data/lib/aerospike/cdt/hll_operation.rb +200 -0
  15. data/lib/aerospike/cdt/hll_policy.rb +34 -0
  16. data/lib/aerospike/cdt/hll_write_flags.rb +53 -0
  17. data/lib/aerospike/cdt/list_operation.rb +127 -97
  18. data/lib/aerospike/cdt/list_sort_flags.rb +10 -2
  19. data/lib/aerospike/cdt/map_operation.rb +154 -93
  20. data/lib/aerospike/cdt/map_order.rb +1 -1
  21. data/lib/aerospike/cdt/map_policy.rb +1 -1
  22. data/lib/aerospike/cdt/map_return_type.rb +1 -1
  23. data/lib/aerospike/cdt/map_write_mode.rb +1 -1
  24. data/lib/aerospike/client.rb +33 -17
  25. data/lib/aerospike/cluster.rb +139 -17
  26. data/lib/aerospike/cluster/partition.rb +1 -1
  27. data/lib/aerospike/cluster/partition_parser.rb +169 -0
  28. data/lib/aerospike/cluster/rack_parser.rb +117 -0
  29. data/lib/aerospike/command/admin_command.rb +1 -1
  30. data/lib/aerospike/command/batch_direct_command.rb +2 -1
  31. data/lib/aerospike/command/batch_direct_exists_command.rb +1 -1
  32. data/lib/aerospike/command/batch_direct_node.rb +3 -3
  33. data/lib/aerospike/command/batch_index_command.rb +11 -2
  34. data/lib/aerospike/command/batch_index_node.rb +2 -2
  35. data/lib/aerospike/command/batch_item.rb +1 -1
  36. data/lib/aerospike/command/command.rb +168 -12
  37. data/lib/aerospike/command/delete_command.rb +21 -5
  38. data/lib/aerospike/command/execute_command.rb +1 -1
  39. data/lib/aerospike/command/exists_command.rb +21 -5
  40. data/lib/aerospike/command/field_type.rb +2 -1
  41. data/lib/aerospike/command/multi_command.rb +55 -5
  42. data/lib/aerospike/command/operate_command.rb +6 -1
  43. data/lib/aerospike/command/read_command.rb +63 -20
  44. data/lib/aerospike/command/read_header_command.rb +18 -6
  45. data/lib/aerospike/command/roles.rb +1 -1
  46. data/lib/aerospike/command/single_command.rb +9 -3
  47. data/lib/aerospike/command/touch_command.rb +48 -4
  48. data/lib/aerospike/command/unsupported_particle_type_validator.rb +1 -1
  49. data/lib/aerospike/command/write_command.rb +13 -4
  50. data/lib/aerospike/connection/create.rb +1 -1
  51. data/lib/aerospike/features.rb +6 -1
  52. data/lib/aerospike/geo_json.rb +1 -1
  53. data/lib/aerospike/host.rb +1 -1
  54. data/lib/aerospike/info.rb +1 -1
  55. data/lib/aerospike/key.rb +1 -1
  56. data/lib/aerospike/language.rb +1 -1
  57. data/lib/aerospike/node.rb +21 -7
  58. data/lib/aerospike/node/rebalance.rb +50 -0
  59. data/lib/aerospike/node/refresh/info.rb +4 -1
  60. data/lib/aerospike/node/refresh/partitions.rb +6 -15
  61. data/lib/aerospike/node/refresh/racks.rb +47 -0
  62. data/lib/aerospike/node/refresh/reset.rb +1 -0
  63. data/lib/aerospike/node/verify/rebalance_generation.rb +43 -0
  64. data/lib/aerospike/node_validator.rb +4 -19
  65. data/lib/aerospike/operation.rb +13 -3
  66. data/lib/aerospike/policy/admin_policy.rb +1 -1
  67. data/lib/aerospike/policy/batch_policy.rb +1 -1
  68. data/lib/aerospike/policy/client_policy.rb +16 -1
  69. data/lib/aerospike/policy/commit_level.rb +1 -1
  70. data/lib/aerospike/policy/consistency_level.rb +1 -1
  71. data/lib/aerospike/policy/generation_policy.rb +1 -1
  72. data/lib/aerospike/policy/operate_policy.rb +1 -1
  73. data/lib/aerospike/policy/policy.rb +64 -2
  74. data/lib/aerospike/policy/priority.rb +1 -1
  75. data/lib/aerospike/policy/query_policy.rb +8 -1
  76. data/lib/aerospike/policy/record_bin_multiplicity.rb +1 -1
  77. data/lib/aerospike/policy/record_exists_action.rb +1 -1
  78. data/lib/aerospike/policy/replica.rb +45 -0
  79. data/lib/aerospike/policy/scan_policy.rb +8 -1
  80. data/lib/aerospike/policy/write_policy.rb +1 -1
  81. data/lib/aerospike/query/filter.rb +1 -1
  82. data/lib/aerospike/query/query_command.rb +16 -5
  83. data/lib/aerospike/query/recordset.rb +1 -1
  84. data/lib/aerospike/query/scan_command.rb +1 -1
  85. data/lib/aerospike/query/statement.rb +9 -2
  86. data/lib/aerospike/query/stream_command.rb +1 -1
  87. data/lib/aerospike/record.rb +1 -1
  88. data/lib/aerospike/result_code.rb +26 -7
  89. data/lib/aerospike/socket/base.rb +4 -3
  90. data/lib/aerospike/task/execute_task.rb +1 -1
  91. data/lib/aerospike/task/index_task.rb +1 -1
  92. data/lib/aerospike/task/task.rb +1 -1
  93. data/lib/aerospike/task/udf_register_task.rb +1 -1
  94. data/lib/aerospike/task/udf_remove_task.rb +1 -1
  95. data/lib/aerospike/ttl.rb +1 -1
  96. data/lib/aerospike/udf.rb +1 -1
  97. data/lib/aerospike/user_role.rb +1 -1
  98. data/lib/aerospike/utils/buffer.rb +14 -4
  99. data/lib/aerospike/utils/packer.rb +1 -1
  100. data/lib/aerospike/utils/pool.rb +1 -1
  101. data/lib/aerospike/utils/unpacker.rb +1 -1
  102. data/lib/aerospike/value/particle_type.rb +2 -2
  103. data/lib/aerospike/value/value.rb +165 -33
  104. data/lib/aerospike/version.rb +1 -1
  105. metadata +20 -8
  106. data/lib/aerospike/cluster/partition_tokenizer_new.rb +0 -130
  107. data/lib/aerospike/cluster/partition_tokenizer_old.rb +0 -135
@@ -0,0 +1,34 @@
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
+ class HLLPolicy
23
+
24
+ attr_accessor :flags
25
+
26
+ def initialize(write_flags: HLLWriteFlags::DEFAULT)
27
+ @flags = write_flags
28
+ end
29
+
30
+ DEFAULT = HLLPolicy.new
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ # Copyright 2020 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ module Aerospike
18
+ module CDT
19
+
20
+ ##
21
+ # Map write bit flags.
22
+ # Requires server versions >= 4.3.
23
+ module HLLWriteFlags
24
+
25
+ ##
26
+ # Default is Default. Allow create or update.
27
+ DEFAULT = 0
28
+
29
+ ##
30
+ # CREATE_ONLY behaves like the following:
31
+ # If the bin already exists, the operation will be denied.
32
+ # If the bin does not exist, a new bin will be created.
33
+ CREATE_ONLY = 1
34
+
35
+ ##
36
+ # UPDATE_ONLY behaves like the following:
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
+ # NO_FAIL does not raise error if operation is denied.
43
+ NO_FAIL = 4
44
+
45
+ ##
46
+ # ALLOW_FOLD allows the resulting set to be the minimum of provided index bits.
47
+ # Also, allow the usage of less precise HLL algorithms when minHash bits
48
+ # of all participating sets do not match.
49
+ ALLOW_FOLD = 8
50
+
51
+ end
52
+ end
53
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2018 Aerospike, Inc.
3
+ # Copyright 2016-2020 Aerospike, Inc.
4
4
  #
5
5
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
6
  # license agreements.
@@ -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