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
@@ -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
|
@@ -21,23 +21,32 @@ module Aerospike
|
|
21
21
|
module CDT
|
22
22
|
|
23
23
|
##
|
24
|
-
# List
|
25
|
-
#
|
26
|
-
#
|
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
|
-
#
|
39
|
-
#
|
40
|
-
#
|
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,34 +84,50 @@ 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, :flag
|
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, flag: 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
|
95
|
+
@flag = flag
|
85
96
|
@arguments = arguments
|
86
97
|
@return_type = return_type
|
87
98
|
end
|
88
99
|
|
100
|
+
##
|
101
|
+
# creates list create operation.
|
102
|
+
# Server creates list at given context level. The context is allowed to be beyond list
|
103
|
+
# boundaries only if pad is set to true. In that case, nil list entries will be inserted to
|
104
|
+
# satisfy the context position.
|
105
|
+
def self.create(bin_name, order, pad, ctx: nil)
|
106
|
+
# If context not defined, the set order for top-level bin list.
|
107
|
+
if !ctx || ctx.length == 0
|
108
|
+
self.set_order(bin_name, order)
|
109
|
+
else
|
110
|
+
ListOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order, ctx: ctx, flag: ListOrder.flag(order, pad))
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
89
114
|
##
|
90
115
|
# Create a set list order operation.
|
91
116
|
# Server sets list order.
|
92
117
|
# Server returns null.
|
93
|
-
def self.set_order(bin_name, order)
|
94
|
-
ListOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order)
|
118
|
+
def self.set_order(bin_name, order, ctx: nil)
|
119
|
+
ListOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order, ctx: ctx)
|
95
120
|
end
|
96
121
|
|
97
122
|
##
|
98
123
|
# Create list append operation.
|
99
124
|
# Server appends value(s) to end of the list bin.
|
100
125
|
# Server returns list size.
|
101
|
-
def self.append(bin_name, *values, policy: ListPolicy::DEFAULT)
|
126
|
+
def self.append(bin_name, *values, ctx: nil, policy: ListPolicy::DEFAULT)
|
102
127
|
if values.length > 1
|
103
|
-
ListOperation.new(Operation::CDT_MODIFY, APPEND_ITEMS, bin_name, values, policy.order, policy.flags)
|
128
|
+
ListOperation.new(Operation::CDT_MODIFY, APPEND_ITEMS, bin_name, values, policy.order, policy.flags, ctx: ctx)
|
104
129
|
else
|
105
|
-
ListOperation.new(Operation::CDT_MODIFY, APPEND, bin_name, values.first, policy.order, policy.flags)
|
130
|
+
ListOperation.new(Operation::CDT_MODIFY, APPEND, bin_name, values.first, policy.order, policy.flags, ctx: ctx)
|
106
131
|
end
|
107
132
|
end
|
108
133
|
|
@@ -110,19 +135,19 @@ module Aerospike
|
|
110
135
|
# Create list insert operation.
|
111
136
|
# Server inserts value(s) at the specified index of the list bin.
|
112
137
|
# Server returns list size.
|
113
|
-
def self.insert(bin_name, index, *values, policy: ListPolicy::DEFAULT)
|
138
|
+
def self.insert(bin_name, index, *values, ctx: nil, policy: ListPolicy::DEFAULT)
|
114
139
|
if values.length > 1
|
115
|
-
ListOperation.new(Operation::CDT_MODIFY, INSERT_ITEMS, bin_name, index, values, policy.flags)
|
140
|
+
ListOperation.new(Operation::CDT_MODIFY, INSERT_ITEMS, bin_name, index, values, policy.flags, ctx: ctx)
|
116
141
|
else
|
117
|
-
ListOperation.new(Operation::CDT_MODIFY, INSERT, bin_name, index, values.first, policy.flags)
|
142
|
+
ListOperation.new(Operation::CDT_MODIFY, INSERT, bin_name, index, values.first, policy.flags, ctx: ctx)
|
118
143
|
end
|
119
144
|
end
|
120
145
|
|
121
146
|
##
|
122
147
|
# Create list pop operation.
|
123
148
|
# 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)
|
149
|
+
def self.pop(bin_name, index, ctx: nil)
|
150
|
+
ListOperation.new(Operation::CDT_MODIFY, POP, bin_name, index, ctx: ctx)
|
126
151
|
end
|
127
152
|
|
128
153
|
##
|
@@ -131,11 +156,11 @@ module Aerospike
|
|
131
156
|
# items from list bin. If "count" is not specified, the server returns
|
132
157
|
# items starting at the specified index to the end of the list and
|
133
158
|
# removes those items from the list bin.
|
134
|
-
def self.pop_range(bin_name, index, count=nil)
|
159
|
+
def self.pop_range(bin_name, index, count=nil, ctx: nil)
|
135
160
|
if count
|
136
|
-
ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, count)
|
161
|
+
ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, count, ctx: ctx)
|
137
162
|
else
|
138
|
-
ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index)
|
163
|
+
ListOperation.new(Operation::CDT_MODIFY, POP_RANGE, bin_name, index, ctx: ctx)
|
139
164
|
end
|
140
165
|
end
|
141
166
|
|
@@ -143,8 +168,8 @@ module Aerospike
|
|
143
168
|
# Create list remove operation.
|
144
169
|
# Server removes item at specified index from list bin.
|
145
170
|
# Server returns number of items removed.
|
146
|
-
def self.remove(bin_name, index)
|
147
|
-
ListOperation.new(Operation::CDT_MODIFY, REMOVE, bin_name, index)
|
171
|
+
def self.remove(bin_name, index, ctx: nil)
|
172
|
+
ListOperation.new(Operation::CDT_MODIFY, REMOVE, bin_name, index, ctx: ctx)
|
148
173
|
end
|
149
174
|
|
150
175
|
##
|
@@ -153,11 +178,11 @@ module Aerospike
|
|
153
178
|
# "count" is not specified, the server removes all items starting at the
|
154
179
|
# specified index to the end of the list.
|
155
180
|
# Server returns number of items removed.
|
156
|
-
def self.remove_range(bin_name, index, count=nil)
|
181
|
+
def self.remove_range(bin_name, index, count=nil, ctx: nil)
|
157
182
|
if count
|
158
|
-
ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, count)
|
183
|
+
ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, count, ctx: ctx)
|
159
184
|
else
|
160
|
-
ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index)
|
185
|
+
ListOperation.new(Operation::CDT_MODIFY, REMOVE_RANGE, bin_name, index, ctx: ctx)
|
161
186
|
end
|
162
187
|
end
|
163
188
|
|
@@ -165,8 +190,8 @@ module Aerospike
|
|
165
190
|
# Create list set operation.
|
166
191
|
# Server sets item value at specified index in list bin.
|
167
192
|
# 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)
|
193
|
+
def self.set(bin_name, index, value, ctx: nil, policy: ListPolicy::DEFAULT)
|
194
|
+
ListOperation.new(Operation::CDT_MODIFY, SET, bin_name, index, value, policy.flags, ctx: ctx)
|
170
195
|
end
|
171
196
|
|
172
197
|
##
|
@@ -176,24 +201,24 @@ module Aerospike
|
|
176
201
|
# by index and count.
|
177
202
|
#
|
178
203
|
# 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)
|
204
|
+
def self.trim(bin_name, index, count, ctx: nil)
|
205
|
+
ListOperation.new(Operation::CDT_MODIFY, TRIM, bin_name, index, count, ctx: ctx)
|
181
206
|
end
|
182
207
|
|
183
208
|
##
|
184
209
|
# Create list clear operation.
|
185
210
|
# Server removes all items in the list bin.
|
186
211
|
# Server does not return a result by default.
|
187
|
-
def self.clear(bin_name)
|
188
|
-
ListOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name)
|
212
|
+
def self.clear(bin_name, ctx: nil)
|
213
|
+
ListOperation.new(Operation::CDT_MODIFY, CLEAR, bin_name, ctx: ctx)
|
189
214
|
end
|
190
215
|
|
191
216
|
##
|
192
217
|
# Create list increment operation.
|
193
218
|
# Server increments list[index] by value. If not specified, value defaults to 1.
|
194
219
|
# 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)
|
220
|
+
def self.increment(bin_name, index, value = 1, ctx: nil, policy: ListPolicy::DEFAULT)
|
221
|
+
ListOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, index, value, policy.order, policy.flags, ctx: ctx)
|
197
222
|
end
|
198
223
|
|
199
224
|
##
|
@@ -207,15 +232,15 @@ module Aerospike
|
|
207
232
|
##
|
208
233
|
# Create list size operation.
|
209
234
|
# Server returns size of list.
|
210
|
-
def self.size(bin_name)
|
211
|
-
ListOperation.new(Operation::CDT_READ, SIZE, bin_name)
|
235
|
+
def self.size(bin_name, ctx: nil)
|
236
|
+
ListOperation.new(Operation::CDT_READ, SIZE, bin_name, ctx: ctx)
|
212
237
|
end
|
213
238
|
|
214
239
|
##
|
215
240
|
# Create list get operation.
|
216
241
|
# 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)
|
242
|
+
def self.get(bin_name, index, ctx: nil)
|
243
|
+
ListOperation.new(Operation::CDT_READ, GET, bin_name, index, ctx: ctx)
|
219
244
|
end
|
220
245
|
|
221
246
|
##
|
@@ -223,11 +248,11 @@ module Aerospike
|
|
223
248
|
# Server returns "count" items starting at the specified index in the
|
224
249
|
# list bin. If "count" is not specified, the server returns all items
|
225
250
|
# starting at the specified index to the end of the list.
|
226
|
-
def self.get_range(bin_name, index, count=nil)
|
251
|
+
def self.get_range(bin_name, index, count=nil, ctx: nil)
|
227
252
|
if count
|
228
|
-
ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, count)
|
253
|
+
ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, count, ctx: ctx)
|
229
254
|
else
|
230
|
-
ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index)
|
255
|
+
ListOperation.new(Operation::CDT_READ, GET_RANGE, bin_name, index, ctx: ctx)
|
231
256
|
end
|
232
257
|
end
|
233
258
|
|
@@ -236,8 +261,8 @@ module Aerospike
|
|
236
261
|
# Server selects list item identified by index.
|
237
262
|
#
|
238
263
|
# 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)
|
264
|
+
def self.get_by_index(bin_name, index, ctx: nil, return_type: ListReturnType::NONE)
|
265
|
+
ListOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type, ctx: ctx)
|
241
266
|
end
|
242
267
|
|
243
268
|
# Create list get by index range operation.
|
@@ -245,11 +270,11 @@ module Aerospike
|
|
245
270
|
# Server selects list item identified by index range
|
246
271
|
#
|
247
272
|
# Server returns selected data specified by return_type.
|
248
|
-
def self.get_by_index_range(bin_name, index, count=nil, return_type: ListReturnType::NONE)
|
273
|
+
def self.get_by_index_range(bin_name, index, count=nil, ctx: nil, return_type: ListReturnType::NONE)
|
249
274
|
if count
|
250
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
275
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
|
251
276
|
else
|
252
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
277
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
|
253
278
|
end
|
254
279
|
end
|
255
280
|
|
@@ -258,8 +283,8 @@ module Aerospike
|
|
258
283
|
# Server selects list item identified by rank.
|
259
284
|
#
|
260
285
|
# 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)
|
286
|
+
def self.get_by_rank(bin_name, rank, ctx: nil, return_type: ListReturnType::NONE)
|
287
|
+
ListOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
|
263
288
|
end
|
264
289
|
|
265
290
|
# Create list get by rank range operation.
|
@@ -267,11 +292,11 @@ module Aerospike
|
|
267
292
|
# Server selects list item identified by rank range.
|
268
293
|
#
|
269
294
|
# Server returns selected data specified by return_type.
|
270
|
-
def self.get_by_rank_range(bin_name, rank, count=nil, return_type: ListReturnType::NONE)
|
295
|
+
def self.get_by_rank_range(bin_name, rank, count=nil, ctx: nil, return_type: ListReturnType::NONE)
|
271
296
|
if count
|
272
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
297
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
|
273
298
|
else
|
274
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
|
299
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
|
275
300
|
end
|
276
301
|
end
|
277
302
|
|
@@ -280,8 +305,8 @@ module Aerospike
|
|
280
305
|
# Server selects list items identified by value.
|
281
306
|
#
|
282
307
|
# 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)
|
308
|
+
def self.get_by_value(bin_name, value, ctx: nil, return_type: ListReturnType::NONE)
|
309
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
|
285
310
|
end
|
286
311
|
|
287
312
|
# Create list get by value range operation.
|
@@ -292,11 +317,11 @@ module Aerospike
|
|
292
317
|
# equal to value_begin.
|
293
318
|
#
|
294
319
|
# 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)
|
320
|
+
def self.get_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: ListReturnType::NONE)
|
296
321
|
if value_end
|
297
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
322
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
|
298
323
|
else
|
299
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
324
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
|
300
325
|
end
|
301
326
|
end
|
302
327
|
|
@@ -305,8 +330,8 @@ module Aerospike
|
|
305
330
|
# Server selects list items identified by values.
|
306
331
|
#
|
307
332
|
# 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)
|
333
|
+
def self.get_by_value_list(bin_name, values, ctx: nil, return_type: ListReturnType::NONE)
|
334
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
|
310
335
|
end
|
311
336
|
|
312
337
|
# Create list get by value relative to rank range list operation.
|
@@ -339,11 +364,11 @@ module Aerospike
|
|
339
364
|
# <li>(3, 3) = [11, 15]</li>
|
340
365
|
# <li>(3, -3) = [0, 4, 5, 9, 11, 15]</li>
|
341
366
|
# </ul>
|
342
|
-
def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: ListReturnType::NONE)
|
367
|
+
def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: ListReturnType::NONE)
|
343
368
|
if count
|
344
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
369
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
|
345
370
|
else
|
346
|
-
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
371
|
+
InvertibleListOp.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
|
347
372
|
end
|
348
373
|
end
|
349
374
|
|
@@ -352,8 +377,8 @@ module Aerospike
|
|
352
377
|
# Server removes list item identified by index.
|
353
378
|
#
|
354
379
|
# 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)
|
380
|
+
def self.remove_by_index(bin_name, index, ctx: nil, return_type: ListReturnType::NONE)
|
381
|
+
ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, ctx: ctx, return_type: return_type)
|
357
382
|
end
|
358
383
|
|
359
384
|
# Create list remove by index range operation.
|
@@ -361,11 +386,11 @@ module Aerospike
|
|
361
386
|
# Server removes list item identified by index range
|
362
387
|
#
|
363
388
|
# Server returns selected data specified by return_type.
|
364
|
-
def self.remove_by_index_range(bin_name, index, count=nil, return_type: ListReturnType::NONE)
|
389
|
+
def self.remove_by_index_range(bin_name, index, count=nil, ctx: nil, return_type: ListReturnType::NONE)
|
365
390
|
if count
|
366
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
|
391
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, ctx: ctx, return_type: return_type)
|
367
392
|
else
|
368
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
|
393
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, ctx: ctx, return_type: return_type)
|
369
394
|
end
|
370
395
|
end
|
371
396
|
|
@@ -374,8 +399,8 @@ module Aerospike
|
|
374
399
|
# Server removes list item identified by rank.
|
375
400
|
#
|
376
401
|
# 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)
|
402
|
+
def self.remove_by_rank(bin_name, rank, ctx: nil, return_type: ListReturnType::NONE)
|
403
|
+
ListOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, ctx: ctx, return_type: return_type)
|
379
404
|
end
|
380
405
|
|
381
406
|
# Create list remove by rank range operation.
|
@@ -383,11 +408,11 @@ module Aerospike
|
|
383
408
|
# Server removes list item identified by rank range.
|
384
409
|
#
|
385
410
|
# Server returns selected data specified by return_type.
|
386
|
-
def self.remove_by_rank_range(bin_name, rank, count=nil, return_type: ListReturnType::NONE)
|
411
|
+
def self.remove_by_rank_range(bin_name, rank, count=nil, ctx: nil, return_type: ListReturnType::NONE)
|
387
412
|
if count
|
388
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
|
413
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, ctx: ctx, return_type: return_type)
|
389
414
|
else
|
390
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, return_type: return_type)
|
415
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, ctx: ctx, return_type: return_type)
|
391
416
|
end
|
392
417
|
end
|
393
418
|
|
@@ -396,8 +421,8 @@ module Aerospike
|
|
396
421
|
# Server removes list items identified by value.
|
397
422
|
#
|
398
423
|
# 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)
|
424
|
+
def self.remove_by_value(bin_name, value, ctx: nil, return_type: ListReturnType::NONE)
|
425
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, ctx: ctx, return_type: return_type)
|
401
426
|
end
|
402
427
|
|
403
428
|
# Create list remove by value range operation.
|
@@ -408,11 +433,11 @@ module Aerospike
|
|
408
433
|
# equal to value_begin.
|
409
434
|
#
|
410
435
|
# 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)
|
436
|
+
def self.remove_by_value_range(bin_name, value_begin, value_end = nil, ctx: nil, return_type: ListReturnType::NONE)
|
412
437
|
if value_end
|
413
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
|
438
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, ctx: ctx, return_type: return_type)
|
414
439
|
else
|
415
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
|
440
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, ctx: ctx, return_type: return_type)
|
416
441
|
end
|
417
442
|
end
|
418
443
|
|
@@ -421,8 +446,8 @@ module Aerospike
|
|
421
446
|
# Server removes list items identified by values.
|
422
447
|
#
|
423
448
|
# 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)
|
449
|
+
def self.remove_by_value_list(bin_name, values, ctx: nil, return_type: ListReturnType::NONE)
|
450
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, ctx: ctx, return_type: return_type)
|
426
451
|
end
|
427
452
|
|
428
453
|
# Create list remove by value relative to rank range list operation.
|
@@ -455,11 +480,11 @@ module Aerospike
|
|
455
480
|
# <li>(3, 3) = [11, 15]</li>
|
456
481
|
# <li>(3, -3) = [0, 4, 5, 9, 11, 15]</li>
|
457
482
|
# </ul>
|
458
|
-
def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: ListReturnType::NONE)
|
483
|
+
def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, ctx: nil, return_type: ListReturnType::NONE)
|
459
484
|
if count
|
460
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
|
485
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, ctx: ctx, return_type: return_type)
|
461
486
|
else
|
462
|
-
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
|
487
|
+
InvertibleListOp.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, ctx: ctx, return_type: return_type)
|
463
488
|
end
|
464
489
|
end
|
465
490
|
|
@@ -481,16 +506,32 @@ module Aerospike
|
|
481
506
|
|
482
507
|
def pack_bin_value
|
483
508
|
bytes = nil
|
509
|
+
|
510
|
+
args = arguments.dup
|
511
|
+
if return_type
|
512
|
+
rt = return_type
|
513
|
+
rt |= ListReturnType::INVERTED if invert_selection?
|
514
|
+
args.unshift(rt)
|
515
|
+
end
|
516
|
+
|
484
517
|
Packer.use do |packer|
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
518
|
+
if @ctx != nil && @ctx.length > 0
|
519
|
+
packer.write_array_header(3)
|
520
|
+
Value.of(0xff).pack(packer)
|
521
|
+
|
522
|
+
pack_context(packer)
|
523
|
+
|
524
|
+
packer.write_array_header(args.length+1)
|
525
|
+
Value.of(@list_op).pack(packer)
|
526
|
+
else
|
527
|
+
packer.write_raw_short(@list_op)
|
528
|
+
|
529
|
+
if args.length > 0
|
530
|
+
packer.write_array_header(args.length)
|
531
|
+
end
|
491
532
|
end
|
533
|
+
|
492
534
|
if args.length > 0
|
493
|
-
packer.write_array_header(args.length)
|
494
535
|
args.each do |value|
|
495
536
|
Value.of(value).pack(packer)
|
496
537
|
end
|
@@ -499,6 +540,24 @@ module Aerospike
|
|
499
540
|
end
|
500
541
|
BytesValue.new(bytes)
|
501
542
|
end
|
543
|
+
|
544
|
+
def pack_context(packer)
|
545
|
+
packer.write_array_header(@ctx.length*2)
|
546
|
+
if @flag
|
547
|
+
(1...@ctx.length).each do |i|
|
548
|
+
Value.of(@ctx[i].id).pack(packer)
|
549
|
+
Value.of(@ctx[i].value).pack(packer)
|
550
|
+
end
|
551
|
+
|
552
|
+
Value.of(@ctx[-1].id | @flag).pack(packer)
|
553
|
+
Value.of(@ctx[-1].value).pack(packer)
|
554
|
+
else
|
555
|
+
@ctx.each do |ctx|
|
556
|
+
Value.of(ctx.id).pack(packer)
|
557
|
+
Value.of(ctx.value).pack(packer)
|
558
|
+
end
|
559
|
+
end
|
560
|
+
end
|
502
561
|
end
|
503
562
|
|
504
563
|
class InvertibleListOp < ListOperation
|