aerospike 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 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
+ module ListOrder
23
+
24
+ ##
25
+ # List is not ordered. This is the default.
26
+ UNORDERED = 0
27
+
28
+ ##
29
+ # List is ordered
30
+ ORDERED = 1
31
+
32
+ ##
33
+ # Default order
34
+ DEFAULT = UNORDERED
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 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 ListPolicy
23
+
24
+ attr_accessor :order, :flags
25
+
26
+ def initialize(order: ListOrder::DEFAULT, write_flags: ListWriteFlags::DEFAULT)
27
+ @order = order
28
+ @flags = write_flags
29
+ end
30
+
31
+ DEFAULT = ListPolicy.new
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 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
+ module ListReturnType
23
+
24
+ ##
25
+ # Do not return a result.
26
+ NONE = 0
27
+
28
+ ##
29
+ # Return key index order.
30
+ # 0 = first key
31
+ # N = Nth key
32
+ # -1 = last key
33
+ INDEX = 1
34
+
35
+ ##
36
+ # Return reverse key order.
37
+ # 0 = last key
38
+ # -1 = first key
39
+ REVERSE_INDEX = 2
40
+
41
+ ##
42
+ # Return value order.
43
+ # 0 = smalles value
44
+ # N = Nth smalles value
45
+ # -1 = largest value
46
+ RANK = 3
47
+
48
+ ##
49
+ # Return reverse value order.
50
+ # 0 = largest value
51
+ # N = Nth largest value
52
+ # -1 = smallest values
53
+ REVERSE_RANK = 4
54
+
55
+ ##
56
+ # Return count of items selected.
57
+ COUNT = 5
58
+
59
+ ##
60
+ # Return value for single key read and value list for range read.
61
+ VALUE = 7
62
+
63
+ ##
64
+ # :private
65
+ #
66
+ # See ListOperation#invert_selection
67
+ INVERTED = 0x10000
68
+
69
+ ##
70
+ # Default return type: NONE
71
+ DEFAULT = NONE
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 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
+ module ListSortFlags
23
+
24
+ ##
25
+ # Default. Preserve duplicate values when sorting list.
26
+ DEFAULT = 0
27
+
28
+ ##
29
+ # Drop duplicate values when sorting list.
30
+ DROP_DUPLICATES = 2
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 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
+ module ListWriteFlags
23
+
24
+ ##
25
+ # Default. Allow duplicate values and insertion at any index.
26
+ DEFAULT = 0
27
+
28
+ ##
29
+ # Only add unique values.
30
+ ADD_UNIQUE = 1
31
+
32
+ ##
33
+ # Enforce list boundaries when inserting. Do not allow values to be
34
+ # inserted at index outside current list boundaries.
35
+ INSERT_BOUNED = 2
36
+
37
+ ##
38
+ # Do not raise error if a list item fails due to write flag constraints.
39
+ NO_FAIL = 4
40
+
41
+ ##
42
+ # Allow other valid list items to be committed if a list item fails due
43
+ # to write flag constraints.
44
+ PARTIAL = 8
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2016-2017 Aerospike, Inc.
2
+ # Copyright 2016-2018 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -19,45 +19,50 @@ module Aerospike
19
19
 
20
20
  class MapOperation < Operation
21
21
 
22
- SET_TYPE = 64
23
- ADD = 65
24
- ADD_ITEMS = 66
25
- PUT = 67
26
- PUT_ITEMS = 68
27
- REPLACE = 69
28
- REPLACE_ITEMS = 70
29
- INCREMENT = 73
30
- DECREMENT = 74
31
- CLEAR = 75
32
- REMOVE_BY_KEY = 76
33
- REMOVE_BY_INDEX = 77
34
- REMOVE_BY_RANK = 79
35
- REMOVE_BY_KEY_LIST = 81
36
- REMOVE_BY_VALUE = 82
37
- REMOVE_BY_VALUE_LIST = 83
38
- REMOVE_BY_KEY_INTERVAL = 84
39
- REMOVE_BY_INDEX_RANGE = 85
40
- REMOVE_BY_VALUE_INTERVAL = 86
41
- REMOVE_BY_RANK_RANGE = 87
42
- SIZE = 96
43
- GET_BY_KEY = 97
44
- GET_BY_INDEX = 98
45
- GET_BY_RANK = 100
46
- GET_BY_VALUE = 102
47
- GET_BY_KEY_INTERVAL = 103
48
- GET_BY_INDEX_RANGE = 104
49
- GET_BY_VALUE_INTERVAL = 105
50
- GET_BY_RANK_RANGE = 106
51
-
52
- attr_reader :map_op, :arguments, :policy, :return_type
53
-
54
- def initialize(op_type, map_op, bin_name, *arguments, policy: nil, return_type: nil)
22
+ SET_TYPE = 64
23
+ ADD = 65
24
+ ADD_ITEMS = 66
25
+ PUT = 67
26
+ PUT_ITEMS = 68
27
+ REPLACE = 69
28
+ REPLACE_ITEMS = 70
29
+ INCREMENT = 73
30
+ DECREMENT = 74
31
+ CLEAR = 75
32
+ REMOVE_BY_KEY = 76
33
+ REMOVE_BY_INDEX = 77
34
+ REMOVE_BY_RANK = 79
35
+ REMOVE_BY_KEY_LIST = 81
36
+ REMOVE_BY_VALUE = 82
37
+ REMOVE_BY_VALUE_LIST = 83
38
+ REMOVE_BY_KEY_INTERVAL = 84
39
+ REMOVE_BY_INDEX_RANGE = 85
40
+ REMOVE_BY_VALUE_INTERVAL = 86
41
+ REMOVE_BY_RANK_RANGE = 87
42
+ REMOVE_BY_KEY_REL_INDEX_RANGE = 88
43
+ REMOVE_BY_VALUE_REL_RANK_RANGE = 89
44
+ SIZE = 96
45
+ GET_BY_KEY = 97
46
+ GET_BY_INDEX = 98
47
+ GET_BY_RANK = 100
48
+ GET_BY_VALUE = 102
49
+ GET_BY_KEY_INTERVAL = 103
50
+ GET_BY_INDEX_RANGE = 104
51
+ GET_BY_VALUE_INTERVAL = 105
52
+ GET_BY_RANK_RANGE = 106
53
+ GET_BY_KEY_LIST = 107
54
+ GET_BY_VALUE_LIST = 108
55
+ GET_BY_KEY_REL_INDEX_RANGE = 109
56
+ GET_BY_VALUE_REL_RANK_RANGE = 110
57
+
58
+ attr_reader :map_op, :arguments, :return_type
59
+
60
+ def initialize(op_type, map_op, bin_name, *arguments, return_type: nil)
55
61
  @op_type = op_type
56
62
  @bin_name = bin_name
57
63
  @bin_value = nil
58
64
  @map_op = map_op
59
65
  @arguments = arguments
60
- @policy = policy
61
66
  @return_type = return_type
62
67
  self
63
68
  end
@@ -68,7 +73,7 @@ module Aerospike
68
73
  #
69
74
  # The required map policy attributes can be changed after the map is created.
70
75
  def self.set_policy(bin_name, policy)
71
- MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy: policy)
76
+ MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order)
72
77
  end
73
78
 
74
79
  ##
@@ -76,16 +81,21 @@ module Aerospike
76
81
  # Server writes key/value item to map bin and returns map size.
77
82
  #
78
83
  # The map policy dictates the type of map to create when it does not exist.
79
- # The map policy also specifies the mode used when writing items to the map.
84
+ # The map policy also specifies the flags used when writing items to the map.
80
85
  def self.put(bin_name, key, value, policy: MapPolicy::DEFAULT)
81
- cmd =
86
+ if policy.flags != MapWriteFlags::DEFAULT
87
+ MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order, policy.flags)
88
+ else
82
89
  case policy.write_mode
83
- when MapWriteMode::UPDATE then PUT
84
- when MapWriteMode::UPDATE_ONLY then REPLACE
85
- when MapWriteMode::CREATE_ONLY then ADD
86
- else PUT
90
+ when MapWriteMode::UPDATE_ONLY
91
+ # Replace doesn't allow map order because it does not create on non-existing key.
92
+ MapOperation.new(Operation::CDT_MODIFY, REPLACE, bin_name, key, value)
93
+ when MapWriteMode::CREATE_ONLY
94
+ MapOperation.new(Operation::CDT_MODIFY, ADD, bin_name, key, value, policy.order)
95
+ else
96
+ MapOperation.new(Operation::CDT_MODIFY, PUT, bin_name, key, value, policy.order)
87
97
  end
88
- MapOperation.new(Operation::CDT_MODIFY, cmd, bin_name, key, value, policy: policy)
98
+ end
89
99
  end
90
100
 
91
101
  ##
@@ -93,16 +103,21 @@ module Aerospike
93
103
  # Server writes each map item to map bin and returns map size.
94
104
  #
95
105
  # The map policy dictates the type of map to create when it does not exist.
96
- # The map policy also specifies the mode used when writing items to the map.
106
+ # The map policy also specifies the flags used when writing items to the map.
97
107
  def self.put_items(bin_name, values, policy: MapPolicy::DEFAULT)
98
- cmd =
108
+ if policy.flags != MapWriteFlags::DEFAULT
109
+ MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order, policy.flags)
110
+ else
99
111
  case policy.write_mode
100
- when MapWriteMode::UPDATE then PUT_ITEMS
101
- when MapWriteMode::UPDATE_ONLY then REPLACE_ITEMS
102
- when MapWriteMode::CREATE_ONLY then ADD_ITEMS
103
- else PUT_ITEMS
112
+ when MapWriteMode::UPDATE_ONLY
113
+ # Replace doesn't allow map order because it does not create on non-existing key.
114
+ MapOperation.new(Operation::CDT_MODIFY, REPLACE_ITEMS, bin_name, values)
115
+ when MapWriteMode::CREATE_ONLY
116
+ MapOperation.new(Operation::CDT_MODIFY, ADD_ITEMS, bin_name, values, policy.order)
117
+ else
118
+ MapOperation.new(Operation::CDT_MODIFY, PUT_ITEMS, bin_name, values, policy.order)
104
119
  end
105
- MapOperation.new(Operation::CDT_MODIFY, cmd, bin_name, values, policy: policy)
120
+ end
106
121
  end
107
122
 
108
123
  ##
@@ -113,7 +128,7 @@ module Aerospike
113
128
  # The map policy dictates the type of map to create when it does not exist.
114
129
  # The map policy also specifies the mode used when writing items to the map.
115
130
  def self.increment(bin_name, key, incr, policy: MapPolicy::DEFAULT)
116
- MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy: policy)
131
+ MapOperation.new(Operation::CDT_MODIFY, INCREMENT, bin_name, key, incr, policy.order)
117
132
  end
118
133
 
119
134
  ##
@@ -124,7 +139,7 @@ module Aerospike
124
139
  # The map policy dictates the type of map to create when it does not exist.
125
140
  # The map policy also specifies the mode used when writing items to the map.
126
141
  def self.decrement(bin_name, key, decr, policy: MapPolicy::DEFAULT)
127
- MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy: policy)
142
+ MapOperation.new(Operation::CDT_MODIFY, DECREMENT, bin_name, key, decr, policy.order)
128
143
  end
129
144
 
130
145
  ##
@@ -136,89 +151,217 @@ module Aerospike
136
151
 
137
152
  ##
138
153
  # Create map remove operation.
139
- # Server removes map item identified by key and returns removed data specified by return_type.
154
+ #
155
+ # Server removes map item identified by key and returns removed data
156
+ # specified by return_type.
157
+ def self.remove_by_key(bin_name, key, return_type: nil)
158
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, key, return_type: return_type)
159
+ end
160
+
161
+ ##
162
+ # Create map remove operation.
163
+ #
164
+ # Server removes map items identified by keys.
165
+ #
166
+ # Server returns removed data specified by return_type.
167
+ def self.remove_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
168
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type)
169
+ end
170
+
171
+ ##
172
+ # Create map remove operation.
173
+ #
174
+ # Server removes map items identified by keys.
175
+ #
176
+ # Server returns removed data specified by return_type.
177
+ #
178
+ # Deprecated. Use remove_by_key / remove_by_key_list instead.
140
179
  def self.remove_keys(bin_name, *keys, return_type: MapReturnType::NONE)
141
180
  if keys.length > 1
142
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_LIST, bin_name, keys, return_type: return_type)
181
+ remove_by_key_list(bin_name, keys, return_type: return_type)
143
182
  else
144
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY, bin_name, keys.first, return_type: return_type)
183
+ remove_by_key(bin_name, keys.first, return_type: return_type)
145
184
  end
146
185
  end
147
186
 
148
187
  ##
149
188
  # Create map remove operation.
189
+ #
150
190
  # Server removes map items identified by key range (key_begin inclusive, key_end exclusive).
151
191
  # If key_begin is null, the range is less than key_end.
152
192
  # If key_end is null, the range is greater than equal to key_begin.
153
193
  #
154
194
  # Server returns removed data specified by return_type.
155
- def self.remove_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
195
+ def self.remove_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
156
196
  if key_end
157
197
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
158
198
  else
159
199
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
160
200
  end
161
201
  end
202
+ singleton_class.send(:alias_method, :remove_key_range, :remove_by_key_range)
203
+
204
+ ##
205
+ # Create map remove by key relative to index range operation.
206
+ #
207
+ # Server removes map items nearest to key and greater by relative index,
208
+ # with a count limit.
209
+ #
210
+ # Server returns removed data specified by return_type.
211
+ #
212
+ # Examples for map [{0=17},{4=2},{5=15},{9=10}]:
213
+ #
214
+ # * (value, index, count) = [removed items]
215
+ # * (5, 0, 1) = [{5=15}]
216
+ # * (5, 1, 2) = [{9=10}]
217
+ # * (5, -1, 1) = [{4=2}]
218
+ # * (3, 2, 1) = [{9=10}]
219
+ # * (3, -2, 2) = [{0=17}]
220
+ #
221
+ # Without count:
222
+ #
223
+ # * (value, index) = [removed items]
224
+ # * (5, 0) = [{5=15}, {9=10}]
225
+ # * (5, 1) = [{9=10}]
226
+ # * (5, -1) = [{4=2}, {5=15}, {9=10}]
227
+ # * (3, 2) = [{9=10}]
228
+ # * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
229
+ def self.remove_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
230
+ if count
231
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
232
+ else
233
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
234
+ end
235
+ end
236
+
237
+ ##
238
+ # Create map remove operation.
239
+ #
240
+ # Server removes map item identified by value.
241
+ #
242
+ # Server returns removed data specified by return_type.
243
+ def self.remove_by_value(bin_name, value, return_type: MapReturnType::NONE)
244
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, value, return_type: return_type)
245
+ end
246
+
247
+ ##
248
+ # Create map remove operation.
249
+ #
250
+ # Server removes map items identified by value.
251
+ #
252
+ # Server returns removed data specified by return_type.
253
+ def self.remove_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
254
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
255
+ end
162
256
 
163
257
  ##
164
258
  # Create map remove operation.
165
- # Server removes map items identified by value and returns removed data specified by return_type.
259
+ #
260
+ # Server removes map items identified by value.
261
+ #
262
+ # Server returns removed data specified by return_type.
263
+ #
264
+ # Deprecated. Use remove_by_value / remove_by_value_list instead.
166
265
  def self.remove_values(bin_name, *values, return_type: MapReturnType::NONE)
167
266
  if values.length > 1
168
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_LIST, bin_name, values, return_type: return_type)
267
+ remove_by_value_list(bin_name, values, return_type: return_type)
169
268
  else
170
- MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE, bin_name, values.first, return_type: return_type)
269
+ remove_by_value(bin_name, values.first, return_type: return_type)
171
270
  end
172
271
  end
173
272
 
174
273
  ##
175
274
  # Create map remove operation.
176
- # Server removes map items identified by value range (value_begin inclusive, value_end exclusive).
177
- # If value_begin is null, the range is less than value_end.
178
- # If value_end is null, the range is greater than equal to value_begin.
275
+ #
276
+ # Server removes map items identified by value range (value_begin
277
+ # inclusive, value_end exclusive). If value_begin is null, the range is
278
+ # less than value_end. If value_end is null, the range is greater than
279
+ # equal to value_begin.
179
280
  #
180
281
  # Server returns removed data specified by return_type.
181
- def self.remove_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
282
+ def self.remove_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
182
283
  if value_end
183
284
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
184
285
  else
185
286
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
186
287
  end
187
288
  end
289
+ singleton_class.send(:alias_method, :remove_value_range, :remove_by_value_range)
290
+
291
+ ##
292
+ # Create map remove by value relative to rank range operation.
293
+ #
294
+ # Server removes "count" map items nearest to value and greater by relative rank.
295
+ # If "count" is not specified, server removes map items nearest to value
296
+ # and greater by relative rank, until the end of the map.
297
+ #
298
+ # Server returns removed data specified by return_type.
299
+ #
300
+ # Examples for map [{4=2},{9=10},{5=15},{0=17}]:
301
+ #
302
+ # * (value, rank, count) = [removed items]
303
+ # * (11, 1, 1) = [{0=17}]
304
+ # * (11, -1, 1) = [{9=10}]
305
+ #
306
+ # Without count:
307
+ #
308
+ # * (value, rank) = [removed items]
309
+ # * (11, 1) = [{0=17}]
310
+ # * (11, -1) = [{9=10}, {5=15}, {0=17}]
311
+ def self.remove_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
312
+ if count
313
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
314
+ else
315
+ MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
316
+ end
317
+ end
188
318
 
189
319
  ##
190
320
  # Create map remove operation.
191
- # Server removes map item identified by index and returns removed data specified by return_type.
192
- def self.remove_index(bin_name, index, return_type: MapReturnType::NONE)
321
+ #
322
+ # Server removes map item identified by index.
323
+ #
324
+ # Server returns removed data specified by return_type.
325
+ def self.remove_by_index(bin_name, index, return_type: MapReturnType::NONE)
193
326
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX, bin_name, index, return_type: return_type)
194
327
  end
328
+ singleton_class.send(:alias_method, :remove_index, :remove_by_index)
195
329
 
196
330
  ##
197
331
  # Create map remove operation.
198
- # Server removes "count" map items starting at specified index and
199
- # returns removed data specified by return_type. If "count" is not
200
- # specified, the server selects map items starting at specified index to
201
- # the end of map.
202
- def self.remove_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
332
+ #
333
+ # Server removes "count" map items starting at specified index. If
334
+ # "count" is not specified, the server selects map items starting at
335
+ # specified index to the end of map.
336
+ #
337
+ # Server returns removed data specified by return_type.
338
+ def self.remove_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
203
339
  if count
204
340
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
205
341
  else
206
342
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
207
343
  end
208
344
  end
345
+ singleton_class.send(:alias_method, :remove_index_range, :remove_by_index_range)
209
346
 
210
347
  ##
211
348
  # Create map remove operation.
212
- # Server removes map item identified by rank and returns removed data specified by return_type.
349
+ #
350
+ # Server removes map item identified by rank.
351
+ #
352
+ # Server returns removed data specified by return_type.
213
353
  def self.remove_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
214
354
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK, bin_name, rank, return_type: return_type)
215
355
  end
216
356
 
217
357
  ##
218
358
  # Create map remove operation.
219
- # Server selects "count" map items starting at specified rank and returns
220
- # selected data specified by return_type. If "count" is not specified,
221
- # server removes map items starting at specified rank to the last ranked.
359
+ #
360
+ # Server selects "count" map items starting at specified rank. If "count"
361
+ # is not specified, server removes map items starting at specified rank
362
+ # to the last ranked.
363
+ #
364
+ # Server returns removed data specified by return_type.
222
365
  def self.remove_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
223
366
  if count
224
367
  MapOperation.new(Operation::CDT_MODIFY, REMOVE_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
@@ -237,75 +380,179 @@ module Aerospike
237
380
  ##
238
381
  # Create map get by key operation.
239
382
  # Server selects map item identified by key and returns selected data specified by return_type.
240
- def self.get_key(bin_name, key, return_type: MapReturnType::NONE)
383
+ def self.get_by_key(bin_name, key, return_type: MapReturnType::NONE)
241
384
  MapOperation.new(Operation::CDT_READ, GET_BY_KEY, bin_name, key, return_type: return_type)
242
385
  end
386
+ singleton_class.send(:alias_method, :get_key, :get_by_key)
387
+
388
+ ##
389
+ # Create map get by key list operation.
390
+ #
391
+ # Server selects map items identified by keys.
392
+ #
393
+ # Server returns selected data specified by return_type.
394
+ def self.get_by_key_list(bin_name, keys, return_type: MapReturnType::NONE)
395
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_LIST, bin_name, keys, return_type: return_type)
396
+ end
243
397
 
244
398
  # Create map get by key range operation.
245
- # Server selects map items identified by key range (key_begin inclusive, key_end exclusive).
246
- # If key_begin is null, the range is less than key_end.
247
- # If key_end is null, the range is greater than equal to key_begin.
248
- # <p>
399
+ #
400
+ # Server selects map items identified by key range (key_begin inclusive,
401
+ # key_end exclusive). If key_begin is null, the range is less than
402
+ # key_end. If key_end is null, the range is greater than equal to
403
+ # key_begin.
404
+ #
249
405
  # Server returns selected data specified by return_type.
250
- def self.get_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
406
+ def self.get_by_key_range(bin_name, key_begin, key_end = nil, return_type: MapReturnType::NONE)
251
407
  if key_end
252
408
  MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, key_end, return_type: return_type)
253
409
  else
254
410
  MapOperation.new(Operation::CDT_READ, GET_BY_KEY_INTERVAL, bin_name, key_begin, return_type: return_type)
255
411
  end
256
412
  end
413
+ singleton_class.send(:alias_method, :get_key_range, :get_by_key_range)
414
+
415
+ ##
416
+ # Create map get by key relative to index range operation.
417
+ #
418
+ # Server selects "count" map items nearest to key and greater by relative
419
+ # index. If "count" is not specified, server selects map items nearest to
420
+ # key and greater by relative index, until the end of the map.
421
+ #
422
+ # Server returns selected data specified by return_type.
423
+ #
424
+ # Examples for map [{0=17},{4=2},{5=15},{9=10}]:
425
+ #
426
+ # * (value, index, count) = [selected items]
427
+ # * (5, 0, 1) = [{5=15}]
428
+ # * (5, 1, 2) = [{9=10}]
429
+ # * (5, -1, 1) = [{4=2}]
430
+ # * (3, 2, 1) = [{9=10}]
431
+ # * (3, -2, 2) = [{0=17}]
432
+ #
433
+ # Without count:
434
+ #
435
+ # * (value, index) = [selected items]
436
+ # * (5, 0) = [{5=15}, {9=10}]
437
+ # * (5, 1) = [{9=10}]
438
+ # * (5, -1) = [{4=2}, {5=15}, {9=10}]
439
+ # * (3, 2) = [{9=10}]
440
+ # * (3, -2) = [{0=17}, {4=2}, {5=15}, {9=10}]
441
+ def self.get_by_key_rel_index_range(bin_name, key, index, count = nil, return_type: nil)
442
+ if count
443
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, count, return_type: return_type)
444
+ else
445
+ MapOperation.new(Operation::CDT_READ, GET_BY_KEY_REL_INDEX_RANGE, bin_name, key, index, return_type: return_type)
446
+ end
447
+ end
257
448
 
258
449
  # Create map get by value operation.
259
- # Server selects map items identified by value and returns selected data specified by return_type.
260
- def self.get_value(bin_name, value, return_type: MapReturnType::NONE)
450
+ #
451
+ # Server selects map items identified by value.
452
+ #
453
+ # Server returns selected data specified by return_type.
454
+ def self.get_by_value(bin_name, value, return_type: MapReturnType::NONE)
261
455
  MapOperation.new(Operation::CDT_READ, GET_BY_VALUE, bin_name, value, return_type: return_type)
262
456
  end
457
+ singleton_class.send(:alias_method, :get_value, :get_by_value)
458
+
459
+ # Create map get by value list operation.
460
+ #
461
+ # Server selects map items identified by value list.
462
+ #
463
+ # Server returns selected data specified by return_type.
464
+ def self.get_by_value_list(bin_name, values, return_type: MapReturnType::NONE)
465
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_LIST, bin_name, values, return_type: return_type)
466
+ end
263
467
 
264
468
  # Create map get by value range operation.
265
- # Server selects map items identified by value range (value_begin inclusive, value_end exclusive)
266
- # If value_begin is null, the range is less than value_end.
267
- # If value_end is null, the range is greater than equal to value_begin.
268
- # <p>
469
+ #
470
+ # Server selects map items identified by value range (value_begin
471
+ # inclusive, value_end exclusive). If value_begin is null, the range is
472
+ # less than value_end. If value_end is null, the range is greater than
473
+ # equal to value_begin.
474
+ #
269
475
  # Server returns selected data specified by return_type.
270
- def self.get_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
476
+ def self.get_by_value_range(bin_name, value_begin, value_end = nil, return_type: MapReturnType::NONE)
271
477
  if value_end
272
478
  MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, value_end, return_type: return_type)
273
479
  else
274
480
  MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_INTERVAL, bin_name, value_begin, return_type: return_type)
275
481
  end
276
482
  end
483
+ singleton_class.send(:alias_method, :get_value_range, :get_by_value_range)
484
+
485
+ ##
486
+ # Create map get by value relative to rank range operation.
487
+ #
488
+ # Server selects "count" map items nearest to value and greater by relative rank.
489
+ # If "count" is not specified, server selects map items nearest to value
490
+ # and greater by relative rank, until the end of the map.
491
+ #
492
+ # Server returns selected data specified by return_type.
493
+ #
494
+ # Examples for map [{4=2},{9=10},{5=15},{0=17}]:
495
+ #
496
+ # * (value, rank, count) = [selected items]
497
+ # * (11, 1, 1) = [{0=17}]
498
+ # * (11, -1, 1) = [{9=10}]
499
+ #
500
+ # Without count:
501
+ #
502
+ # * (value, rank) = [selected items]
503
+ # * (11, 1) = [{0=17}]
504
+ # * (11, -1) = [{9=10}, {5=15}, {0=17}]
505
+ def self.get_by_value_rel_rank_range(bin_name, value, rank, count = nil, return_type: nil)
506
+ if count
507
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, count, return_type: return_type)
508
+ else
509
+ MapOperation.new(Operation::CDT_READ, GET_BY_VALUE_REL_RANK_RANGE, bin_name, value, rank, return_type: return_type)
510
+ end
511
+ end
512
+
277
513
 
278
514
  # Create map get by index operation.
279
- # Server selects map item identified by index and returns selected data specified by return_type.
280
- def self.get_index(bin_name, index, return_type: MapReturnType::NONE)
515
+ #
516
+ # Server selects map item identified by index.
517
+ #
518
+ # Server returns selected data specified by return_type.
519
+ def self.get_by_index(bin_name, index, return_type: MapReturnType::NONE)
281
520
  MapOperation.new(Operation::CDT_READ, GET_BY_INDEX, bin_name, index, return_type: return_type)
282
521
  end
522
+ singleton_class.send(:alias_method, :get_index, :get_by_index)
283
523
 
284
524
  # Create map get by index range operation.
285
- # Server selects "count" map items starting at specified index and
286
- # returns selected data specified by return_type. If "count" is not
287
- # specified, server selects map items starting at specified index to the
288
- # end of map.
289
- def self.get_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
525
+ #
526
+ # Server selects "count" map items starting at specified index. If
527
+ # "count" is not specified, server selects map items starting at
528
+ # specified index to the end of map.
529
+ #
530
+ # Server returns selected data specified by return_type.
531
+ def self.get_by_index_range(bin_name, index, count = nil, return_type: MapReturnType::NONE)
290
532
  if count
291
533
  MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, count, return_type: return_type)
292
534
  else
293
535
  MapOperation.new(Operation::CDT_READ, GET_BY_INDEX_RANGE, bin_name, index, return_type: return_type)
294
536
  end
295
537
  end
538
+ singleton_class.send(:alias_method, :get_index_range, :get_by_index_range)
296
539
 
297
540
  # Create map get by rank operation.
298
- # Server selects map item identified by rank and returns selected data
299
- # specified by return_type.
541
+ #
542
+ # Server selects map item identified by rank.
543
+ #
544
+ # Server returns selected data specified by return_type.
300
545
  def self.get_by_rank(bin_name, rank, return_type: MapReturnType::NONE)
301
546
  MapOperation.new(Operation::CDT_READ, GET_BY_RANK, bin_name, rank, return_type: return_type)
302
547
  end
303
548
 
304
549
  # Create map get by rank range operation.
305
- # Server selects "count" map items starting at specified rank and returns
306
- # selected data specified by returnType. If "count" is not specified,
307
- # server selects map items starting at specified rank to the last ranked
308
- # item.
550
+ #
551
+ # Server selects "count" map items starting at specified rank. If "count"
552
+ # is not specified, server selects map items starting at specified rank
553
+ # to the last ranked item.
554
+ #
555
+ # Server returns selected data specified by return_type.
309
556
  def self.get_by_rank_range(bin_name, rank, count = nil, return_type: MapReturnType::NONE)
310
557
  if count
311
558
  MapOperation.new(Operation::CDT_READ, GET_BY_RANK_RANGE, bin_name, rank, count, return_type: return_type)
@@ -332,9 +579,6 @@ module Aerospike
332
579
  packer.write_raw_short(map_op)
333
580
  args = arguments.dup
334
581
  args.unshift(return_type) if return_type
335
- if policy && policy.write_mode != MapWriteMode::UPDATE_ONLY
336
- args << policy.value
337
- end
338
582
  if args.length > 0
339
583
  packer.write_array_header(args.length)
340
584
  args.each do |value|