aerospike 3.0.0 → 4.0.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +13 -9
  4. data/lib/aerospike/batch_attr.rb +292 -0
  5. data/lib/aerospike/batch_delete.rb +48 -0
  6. data/lib/aerospike/batch_read.rb +97 -0
  7. data/lib/aerospike/batch_record.rb +83 -0
  8. data/lib/aerospike/batch_results.rb +38 -0
  9. data/lib/aerospike/batch_udf.rb +76 -0
  10. data/lib/aerospike/batch_write.rb +79 -0
  11. data/lib/aerospike/cdt/bit_operation.rb +4 -5
  12. data/lib/aerospike/cdt/map_return_type.rb +8 -0
  13. data/lib/aerospike/client.rb +37 -51
  14. data/lib/aerospike/cluster.rb +50 -46
  15. data/lib/aerospike/command/batch_index_command.rb +6 -10
  16. data/lib/aerospike/command/batch_index_node.rb +3 -4
  17. data/lib/aerospike/command/batch_operate_command.rb +151 -0
  18. data/lib/aerospike/command/batch_operate_node.rb +51 -0
  19. data/lib/aerospike/command/command.rb +101 -87
  20. data/lib/aerospike/command/single_command.rb +1 -1
  21. data/lib/aerospike/exp/exp.rb +39 -41
  22. data/lib/aerospike/exp/exp_bit.rb +24 -24
  23. data/lib/aerospike/exp/exp_hll.rb +12 -12
  24. data/lib/aerospike/exp/exp_list.rb +101 -92
  25. data/lib/aerospike/exp/exp_map.rb +118 -121
  26. data/lib/aerospike/exp/operation.rb +2 -2
  27. data/lib/aerospike/info.rb +2 -4
  28. data/lib/aerospike/node.rb +7 -3
  29. data/lib/aerospike/operation.rb +38 -0
  30. data/lib/aerospike/policy/batch_delete_policy.rb +71 -0
  31. data/lib/aerospike/policy/batch_policy.rb +53 -4
  32. data/lib/aerospike/{command/batch_direct_node.rb → policy/batch_read_policy.rb} +17 -19
  33. data/lib/aerospike/policy/batch_udf_policy.rb +75 -0
  34. data/lib/aerospike/policy/batch_write_policy.rb +105 -0
  35. data/lib/aerospike/policy/policy.rb +3 -40
  36. data/lib/aerospike/query/server_command.rb +1 -0
  37. data/lib/aerospike/query/statement.rb +5 -21
  38. data/lib/aerospike/utils/buffer.rb +15 -15
  39. data/lib/aerospike/version.rb +1 -1
  40. data/lib/aerospike.rb +13 -12
  41. metadata +16 -14
  42. data/lib/aerospike/command/batch_direct_command.rb +0 -105
  43. data/lib/aerospike/command/batch_direct_exists_command.rb +0 -51
  44. data/lib/aerospike/query/pred_exp/and_or.rb +0 -32
  45. data/lib/aerospike/query/pred_exp/geo_json_value.rb +0 -41
  46. data/lib/aerospike/query/pred_exp/integer_value.rb +0 -32
  47. data/lib/aerospike/query/pred_exp/op.rb +0 -27
  48. data/lib/aerospike/query/pred_exp/regex.rb +0 -32
  49. data/lib/aerospike/query/pred_exp/regex_flags.rb +0 -23
  50. data/lib/aerospike/query/pred_exp/string_value.rb +0 -29
  51. data/lib/aerospike/query/pred_exp.rb +0 -192
@@ -4,7 +4,7 @@
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
6
6
  #
7
- # Licensed under the Apache License, Version 2.0 (the "License"); you may no
7
+ # Licensed under the Apache License, Version 2.0 (the "License") you may no
8
8
  # use this file except in compliance with the License. You may obtain a copy of
9
9
  # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
10
  #
@@ -15,7 +15,7 @@
15
15
  # the License.
16
16
 
17
17
  module Aerospike
18
- # Map expression generator. See {@link Exp}.
18
+ # Map expression generator. See {Exp}.
19
19
  #
20
20
  # The bin expression argument in these methods can be a reference to a bin or the
21
21
  # result of another expression. Expressions that modify bin values are only used
@@ -80,24 +80,22 @@ module Aerospike
80
80
  value.pack(packer)
81
81
  packer.write(policy.attributes)
82
82
  packer.write(policy.flags)
83
+ elsif policy.item_command == REPLACE
84
+ Exp.pack_ctx(packer, ctx)
85
+ packer.write_array_header(3)
86
+ packer.write(policy.item_command)
87
+ key.pack(packer)
88
+ value.pack(packer)
89
+ # Replace doesn't allow map attributes because it does not create on non-existing key.
83
90
  else
84
- if policy.item_command == REPLACE
85
- # Replace doesn't allow map attributes because it does not create on non-existing key.
86
- Exp.pack_ctx(packer, ctx)
87
- packer.write_array_header(3)
88
- packer.write(policy.item_command)
89
- key.pack(packer)
90
- value.pack(packer)
91
- else
92
91
  Exp.pack_ctx(packer, ctx)
93
92
  packer.write_array_header(4)
94
93
  packer.write(policy.item_command)
95
94
  key.pack(packer)
96
95
  value.pack(packer)
97
96
  packer.write(policy.attributes)
98
- end
99
97
  end
100
- self.add_write(bin, packer.bytes, ctx)
98
+ add_write(bin, packer.bytes, ctx)
101
99
  end
102
100
  end
103
101
 
@@ -111,22 +109,20 @@ module Aerospike
111
109
  map.pack(packer)
112
110
  packer.write(policy.attributes)
113
111
  packer.write(policy.flags)
112
+ elsif policy.items_command == REPLACE_ITEMS
113
+ Exp.pack_ctx(packer, ctx)
114
+ packer.write_array_header(2)
115
+ packer.write(policy.items_command)
116
+ map.pack(packer)
117
+ # Replace doesn't allow map attributes because it does not create on non-existing key.
114
118
  else
115
- if policy.items_command == REPLACE_ITEMS
116
- # Replace doesn't allow map attributes because it does not create on non-existing key.
117
- Exp.pack_ctx(packer, ctx)
118
- packer.write_array_header(2)
119
- packer.write(policy.items_command)
120
- map.pack(packer)
121
- else
122
119
  Exp.pack_ctx(packer, ctx)
123
120
  packer.write_array_header(3)
124
121
  packer.write(policy.items_command)
125
122
  map.pack(packer)
126
123
  packer.write(policy.attributes)
127
- end
128
124
  end
129
- self.add_write(bin, packer.bytes, ctx)
125
+ add_write(bin, packer.bytes, ctx)
130
126
  end
131
127
  end
132
128
 
@@ -134,25 +130,25 @@ module Aerospike
134
130
  # Valid only for numbers.
135
131
  def self.increment(key, incr, bin, ctx: nil, policy: CDT::MapPolicy::DEFAULT)
136
132
  bytes = Exp.pack(ctx, INCREMENT, key, incr, policy.attributes)
137
- return self.add_write(bin, bytes, ctx)
133
+ add_write(bin, bytes, ctx)
138
134
  end
139
135
 
140
136
  # Create expression that removes all items in map.
141
137
  def self.clear(bin, ctx: nil)
142
138
  bytes = Exp.pack(ctx, CLEAR)
143
- return self.add_write(bin, bytes, ctx)
139
+ add_write(bin, bytes, ctx)
144
140
  end
145
141
 
146
142
  # Create expression that removes map item identified by key.
147
143
  def self.remove_by_key(key, bin, ctx: nil)
148
144
  bytes = Exp.pack(ctx, REMOVE_BY_KEY, CDT::MapReturnType::NONE, key)
149
- return self.add_write(bin, bytes, ctx)
145
+ add_write(bin, bytes, ctx)
150
146
  end
151
147
 
152
148
  # Create expression that removes map items identified by keys.
153
149
  def self.remove_by_key_list(keys, bin, ctx: nil)
154
150
  bytes = Exp.pack(ctx, REMOVE_BY_KEY_LIST, CDT::MapReturnType::NONE, keys)
155
- return self.add_write(bin, bytes, ctx)
151
+ add_write(bin, bytes, ctx)
156
152
  end
157
153
 
158
154
  # Create expression that removes map items identified by key range (key_begin inclusive, key_end exclusive).
@@ -160,7 +156,7 @@ module Aerospike
160
156
  # If key_end is nil, the range is greater than equal to key_begin.
161
157
  def self.remove_by_key_range(key_begin, key_end, bin, ctx: nil)
162
158
  bytes = Exp::List.pack_range_operation(REMOVE_BY_KEY_INTERVAL, CDT::MapReturnType::NONE, key_begin, key_end, ctx)
163
- return self.add_write(bin, bytes, ctx)
159
+ add_write(bin, bytes, ctx)
164
160
  end
165
161
 
166
162
  # Create expression that removes map items nearest to key and greater by index with a count limit if provided.
@@ -174,24 +170,24 @@ module Aerospike
174
170
  # (3,2,1) = [{9=10}]
175
171
  # (3,-2,2) = [{0=17}]
176
172
  def self.remove_by_key_relative_index_range(key, index, bin, ctx: nil, count: nil)
177
- unless count.nil?
178
- bytes = Exp.pack(ctx, REMOVE_BY_KEY_REL_INDEX_RANGE, CDT::MapReturnType::NONE, key, index, count)
179
- else
180
- bytes = Exp.pack(ctx, REMOVE_BY_KEY_REL_INDEX_RANGE, CDT::MapReturnType::NONE, key, index)
181
- end
182
- return self.add_write(bin, bytes, ctx)
173
+ bytes = if count.nil?
174
+ Exp.pack(ctx, REMOVE_BY_KEY_REL_INDEX_RANGE, CDT::MapReturnType::NONE, key, index)
175
+ else
176
+ Exp.pack(ctx, REMOVE_BY_KEY_REL_INDEX_RANGE, CDT::MapReturnType::NONE, key, index, count)
177
+ end
178
+ add_write(bin, bytes, ctx)
183
179
  end
184
180
 
185
181
  # Create expression that removes map items identified by value.
186
182
  def self.remove_by_value(value, bin, ctx: nil)
187
183
  bytes = Exp.pack(ctx, REMOVE_BY_VALUE, CDT::MapReturnType::NONE, value)
188
- return self.add_write(bin, bytes, ctx)
184
+ add_write(bin, bytes, ctx)
189
185
  end
190
186
 
191
187
  # Create expression that removes map items identified by values.
192
188
  def self.remove_by_value_list(values, bin, ctx: nil)
193
189
  bytes = Exp.pack(ctx, REMOVE_BY_VALUE_LIST, CDT::MapReturnType::NONE, values)
194
- return self.add_write(bin, bytes, ctx)
190
+ add_write(bin, bytes, ctx)
195
191
  end
196
192
 
197
193
  # Create expression that removes map items identified by value range (valueBegin inclusive, valueEnd exclusive).
@@ -199,7 +195,7 @@ module Aerospike
199
195
  # If valueEnd is nil, the range is greater than equal to valueBegin.
200
196
  def self.remove_by_value_range(valueBegin, valueEnd, bin, ctx: nil)
201
197
  bytes = Exp::List.pack_range_operation(REMOVE_BY_VALUE_INTERVAL, CDT::MapReturnType::NONE, valueBegin, valueEnd, ctx)
202
- return self.add_write(bin, bytes, ctx)
198
+ add_write(bin, bytes, ctx)
203
199
  end
204
200
 
205
201
  # Create expression that removes map items nearest to value and greater by relative rank.
@@ -211,7 +207,7 @@ module Aerospike
211
207
  # (11,-1) = [{9=10},{5=15},{0=17}]
212
208
  def self.remove_by_value_relative_rank_range(value, rank, bin, ctx: nil)
213
209
  bytes = Exp.pack(ctx, REMOVE_BY_VALUE_REL_RANK_RANGE, CDT::MapReturnType::NONE, value, rank)
214
- return self.add_write(bin, bytes, ctx)
210
+ add_write(bin, bytes, ctx)
215
211
  end
216
212
 
217
213
  # Create expression that removes map items nearest to value and greater by relative rank with a count limit.
@@ -223,40 +219,40 @@ module Aerospike
223
219
  # (11,-1,1) = [{9=10}]
224
220
  def self.remove_by_value_relative_rank_range(value, rank, count, bin, ctx: nil)
225
221
  bytes = Exp.pack(ctx, REMOVE_BY_VALUE_REL_RANK_RANGE, CDT::MapReturnType::NONE, value, rank, count)
226
- return self.add_write(bin, bytes, ctx)
222
+ add_write(bin, bytes, ctx)
227
223
  end
228
224
 
229
225
  # Create expression that removes map item identified by index.
230
226
  def self.remove_by_index(index, bin, ctx: nil)
231
227
  bytes = Exp.pack(ctx, REMOVE_BY_INDEX, CDT::MapReturnType::NONE, index)
232
- return self.add_write(bin, bytes, ctx)
228
+ add_write(bin, bytes, ctx)
233
229
  end
234
230
 
235
231
  # Create expression that removes "count" map items starting at specified index limited by count if provided.
236
232
  def self.remove_by_index_range(index, bin, ctx: nil, count: nil)
237
- unless count.nil?
238
- bytes = Exp.pack(ctx, REMOVE_BY_INDEX_RANGE, CDT::MapReturnType::NONE, index, count)
239
- else
240
- bytes = Exp.pack(ctx, REMOVE_BY_INDEX_RANGE, CDT::MapReturnType::NONE, index)
241
- end
242
- return self.add_write(bin, bytes, ctx)
233
+ bytes = if count.nil?
234
+ Exp.pack(ctx, REMOVE_BY_INDEX_RANGE, CDT::MapReturnType::NONE, index)
235
+ else
236
+ Exp.pack(ctx, REMOVE_BY_INDEX_RANGE, CDT::MapReturnType::NONE, index, count)
237
+ end
238
+ add_write(bin, bytes, ctx)
243
239
  end
244
240
 
245
241
  # Create expression that removes map item identified by rank.
246
242
  def self.remove_by_rank(rank, bin, ctx: nil)
247
243
  bytes = Exp.pack(ctx, REMOVE_BY_RANK, CDT::MapReturnType::NONE, rank)
248
- return self.add_write(bin, bytes, ctx)
244
+ add_write(bin, bytes, ctx)
249
245
  end
250
246
 
251
247
  # Create expression that removes "count" map items starting at specified rank. If count is not provided,
252
248
  # all items until the last ranked item will be removed
253
249
  def self.remove_by_rank_range(rank, bin, ctx: nil, count: nil)
254
- unless count.nil?
255
- bytes = Exp.pack(ctx, REMOVE_BY_RANK_RANGE, CDT::MapReturnType::NONE, rank, count)
256
- else
257
- bytes = Exp.pack(ctx, REMOVE_BY_RANK_RANGE, CDT::MapReturnType::NONE, rank)
258
- end
259
- return self.add_write(bin, bytes, ctx)
250
+ bytes = if count.nil?
251
+ Exp.pack(ctx, REMOVE_BY_RANK_RANGE, CDT::MapReturnType::NONE, rank)
252
+ else
253
+ Exp.pack(ctx, REMOVE_BY_RANK_RANGE, CDT::MapReturnType::NONE, rank, count)
254
+ end
255
+ add_write(bin, bytes, ctx)
260
256
  end
261
257
 
262
258
  # Create expression that returns list size.
@@ -266,7 +262,7 @@ module Aerospike
266
262
  # Exp.gt(MapExp.size(mapBin("a")), Exp.val(7))
267
263
  def self.size(bin, ctx: nil)
268
264
  bytes = Exp.pack(ctx, SIZE)
269
- return self.add_read(bin, bytes, Exp::Type::INT)
265
+ add_read(bin, bytes, Exp::Type::INT)
270
266
  end
271
267
 
272
268
  # Create expression that selects map item identified by key and returns selected data
@@ -278,35 +274,35 @@ module Aerospike
278
274
  # MapExp.getByKey(CDT::MapReturnType::COUNT, Exp::Type::INT, Exp.val("B"), Exp.mapBin("a")),
279
275
  # Exp.val(0))
280
276
  #
281
- # @param return_type metadata attributes to return. See {@link MapReturnType}
277
+ # @param return_type metadata attributes to return. See {MapReturnType}
282
278
  # @param value_type expected type of return value
283
279
  # @param key map key expression
284
280
  # @param bin bin or map value expression
285
281
  # @param ctx optional context path for nested CDT
286
282
  def self.get_by_key(return_type, value_type, key, bin, ctx: nil)
287
283
  bytes = Exp.pack(ctx, GET_BY_KEY, return_type, key)
288
- return self.add_read(bin, bytes, value_type)
284
+ add_read(bin, bytes, value_type)
289
285
  end
290
286
 
291
287
  # Create expression that selects map items identified by key range (key_begin inclusive, key_end exclusive).
292
288
  # If key_begin is nil, the range is less than key_end.
293
289
  # If key_end is nil, the range is greater than equal to key_begin.
294
290
  #
295
- # Expression returns selected data specified by return_type (See {@link MapReturnType}).
291
+ # Expression returns selected data specified by return_type (See {MapReturnType}).
296
292
  def self.get_by_key_range(return_type, key_begin, key_end, bin, ctx: nil)
297
293
  bytes = Exp::List.pack_range_operation(GET_BY_KEY_INTERVAL, return_type, key_begin, key_end, ctx)
298
- return self.add_read(bin, bytes, get_value_type(return_type))
294
+ add_read(bin, bytes, get_value_type(return_type))
299
295
  end
300
296
 
301
297
  # Create expression that selects map items identified by keys and returns selected data specified by
302
- # return_type (See {@link MapReturnType}).
298
+ # return_type (See {MapReturnType}).
303
299
  def self.get_by_key_list(return_type, keys, bin, ctx: nil)
304
300
  bytes = Exp.pack(ctx, GET_BY_KEY_LIST, return_type, keys)
305
- return self.add_read(bin, bytes, get_value_type(return_type))
301
+ add_read(bin, bytes, get_value_type(return_type))
306
302
  end
307
303
 
308
304
  # Create expression that selects map items nearest to key and greater by index with a coun.
309
- # Expression returns selected data specified by return_type (See {@link MapReturnType}).
305
+ # Expression returns selected data specified by return_type (See {MapReturnType}).
310
306
  #
311
307
  # Examples for ordered map [{0=17},{4=2},{5=15},{9=10}]:
312
308
  #
@@ -318,11 +314,11 @@ module Aerospike
318
314
  # (3,-2) = [{0=17},{4=2},{5=15},{9=10}]
319
315
  def self.get_by_key_relative_index_range(return_type, key, index, bin, ctx: nil)
320
316
  bytes = Exp.pack(ctx, GET_BY_KEY_REL_INDEX_RANGE, return_type, key, index)
321
- return self.add_read(bin, bytes, get_value_type(return_type))
317
+ add_read(bin, bytes, get_value_type(return_type))
322
318
  end
323
319
 
324
320
  # Create expression that selects map items nearest to key and greater by index with a count limit if provided.
325
- # Expression returns selected data specified by return_type (See {@link MapReturnType}).
321
+ # Expression returns selected data specified by return_type (See {MapReturnType}).
326
322
  #
327
323
  # Examples for ordered map [{0=17},{4=2},{5=15},{9=10}]:
328
324
  #
@@ -333,12 +329,12 @@ module Aerospike
333
329
  # (3,2,1) = [{9=10}]
334
330
  # (3,-2,2) = [{0=17}]
335
331
  def self.get_by_key_relative_index_range(return_type, key, index, bin, ctx: nil, count: nil)
336
- unless count.nil?
337
- bytes = Exp.pack(ctx, GET_BY_KEY_REL_INDEX_RANGE, return_type, key, index, count)
338
- else
339
- bytes = Exp.pack(ctx, GET_BY_KEY_REL_INDEX_RANGE, return_type, key, index)
340
- end
341
- return self.add_read(bin, bytes, get_value_type(return_type))
332
+ bytes = if count.nil?
333
+ Exp.pack(ctx, GET_BY_KEY_REL_INDEX_RANGE, return_type, key, index)
334
+ else
335
+ Exp.pack(ctx, GET_BY_KEY_REL_INDEX_RANGE, return_type, key, index, count)
336
+ end
337
+ add_read(bin, bytes, get_value_type(return_type))
342
338
  end
343
339
 
344
340
  # Create expression that selects map items identified by value and returns selected data
@@ -350,34 +346,34 @@ module Aerospike
350
346
  # MapExp.getByValue(CDT::MapReturnType::COUNT, Exp.val("BBB"), Exp.mapBin("a")),
351
347
  # Exp.val(0))
352
348
  #
353
- # @param return_type metadata attributes to return. See {@link MapReturnType}
349
+ # @param return_type metadata attributes to return. See {MapReturnType}
354
350
  # @param value value expression
355
351
  # @param bin bin or map value expression
356
352
  # @param ctx optional context path for nested CDT
357
353
  def self.get_by_value(return_type, value, bin, ctx: nil)
358
354
  bytes = Exp.pack(ctx, GET_BY_VALUE, return_type, value)
359
- return self.add_read(bin, bytes, get_value_type(return_type))
355
+ add_read(bin, bytes, get_value_type(return_type))
360
356
  end
361
357
 
362
358
  # Create expression that selects map items identified by value range (valueBegin inclusive, valueEnd exclusive)
363
359
  # If valueBegin is nil, the range is less than valueEnd.
364
360
  # If valueEnd is nil, the range is greater than equal to valueBegin.
365
361
  #
366
- # Expression returns selected data specified by return_type (See {@link MapReturnType}).
362
+ # Expression returns selected data specified by return_type (See {MapReturnType}).
367
363
  def self.get_by_value_range(return_type, valueBegin, valueEnd, bin, ctx: nil)
368
364
  bytes = Exp::List.pack_range_operation(GET_BY_VALUE_INTERVAL, return_type, valueBegin, valueEnd, ctx)
369
- return self.add_read(bin, bytes, get_value_type(return_type))
365
+ add_read(bin, bytes, get_value_type(return_type))
370
366
  end
371
367
 
372
368
  # Create expression that selects map items identified by values and returns selected data specified by
373
- # return_type (See {@link MapReturnType}).
369
+ # return_type (See {MapReturnType}).
374
370
  def self.get_by_value_list(return_type, values, bin, ctx: nil)
375
371
  bytes = Exp.pack(ctx, GET_BY_VALUE_LIST, return_type, values)
376
- return self.add_read(bin, bytes, get_value_type(return_type))
372
+ add_read(bin, bytes, get_value_type(return_type))
377
373
  end
378
374
 
379
375
  # Create expression that selects map items nearest to value and greater by relative rank (with a count limit if passed).
380
- # Expression returns selected data specified by return_type (See {@link MapReturnType}).
376
+ # Expression returns selected data specified by return_type (See {MapReturnType}).
381
377
  #
382
378
  # Examples for map [{4=2},{9=10},{5=15},{0=17}]:
383
379
  #
@@ -385,48 +381,48 @@ module Aerospike
385
381
  # (11,1) = [{0=17}]
386
382
  # (11,-1) = [{9=10},{5=15},{0=17}]
387
383
  def self.get_by_value_relative_rank_range(return_type, value, rank, bin, ctx: nil, count: nil)
388
- unless count.nil?
389
- bytes = Exp.pack(ctx, GET_BY_VALUE_REL_RANK_RANGE, return_type, value, rank, count)
390
- else
391
- bytes = Exp.pack(ctx, GET_BY_VALUE_REL_RANK_RANGE, return_type, value, rank)
392
- end
393
- return self.add_read(bin, bytes, get_value_type(return_type))
384
+ bytes = if count.nil?
385
+ Exp.pack(ctx, GET_BY_VALUE_REL_RANK_RANGE, return_type, value, rank)
386
+ else
387
+ Exp.pack(ctx, GET_BY_VALUE_REL_RANK_RANGE, return_type, value, rank, count)
388
+ end
389
+ add_read(bin, bytes, get_value_type(return_type))
394
390
  end
395
391
 
396
392
  # Create expression that selects map item identified by index and returns selected data specified by
397
- # return_type (See {@link MapReturnType}).
393
+ # return_type (See {MapReturnType}).
398
394
  def self.get_by_index(return_type, value_type, index, bin, ctx: nil)
399
395
  bytes = Exp.pack(ctx, GET_BY_INDEX, return_type, index)
400
- return self.add_read(bin, bytes, value_type)
396
+ add_read(bin, bytes, value_type)
401
397
  end
402
398
 
403
399
  # Create expression that selects map items starting at specified index to the end of map and returns selected
404
- # data specified by return_type (See {@link MapReturnType}) limited by count if provided.
400
+ # data specified by return_type (See {MapReturnType}) limited by count if provided.
405
401
  def self.get_by_index_range(return_type, index, bin, ctx: nil, count: nil)
406
- unless count.nil?
407
- bytes = Exp.pack(ctx, GET_BY_INDEX_RANGE, return_type, index, count)
408
- else
409
- bytes = Exp.pack(ctx, GET_BY_INDEX_RANGE, return_type, index)
410
- end
411
- return self.add_read(bin, bytes, get_value_type(return_type))
402
+ bytes = if count.nil?
403
+ Exp.pack(ctx, GET_BY_INDEX_RANGE, return_type, index)
404
+ else
405
+ Exp.pack(ctx, GET_BY_INDEX_RANGE, return_type, index, count)
406
+ end
407
+ add_read(bin, bytes, get_value_type(return_type))
412
408
  end
413
409
 
414
410
  # Create expression that selects map item identified by rank and returns selected data specified by
415
- # return_type (See {@link MapReturnType}).
411
+ # return_type (See {MapReturnType}).
416
412
  def self.get_by_rank(return_type, value_type, rank, bin, ctx: nil)
417
413
  bytes = Exp.pack(ctx, GET_BY_RANK, return_type, rank)
418
- return self.add_read(bin, bytes, value_type)
414
+ add_read(bin, bytes, value_type)
419
415
  end
420
416
 
421
417
  # Create expression that selects map items starting at specified rank to the last ranked item and
422
- # returns selected data specified by return_type (See {@link MapReturnType}).
418
+ # returns selected data specified by return_type (See {MapReturnType}).
423
419
  def self.get_by_rank_range(return_type, rank, bin, ctx: nil, count: nil)
424
- unless count.nil?
425
- bytes = Exp.pack(ctx, GET_BY_RANK_RANGE, return_type, rank, count)
426
- else
427
- bytes = Exp.pack(ctx, GET_BY_RANK_RANGE, return_type, rank)
428
- end
429
- return self.add_read(bin, bytes, get_value_type(return_type))
420
+ bytes = if count.nil?
421
+ Exp.pack(ctx, GET_BY_RANK_RANGE, return_type, rank)
422
+ else
423
+ Exp.pack(ctx, GET_BY_RANK_RANGE, return_type, rank, count)
424
+ end
425
+ add_read(bin, bytes, get_value_type(return_type))
430
426
  end
431
427
 
432
428
  private
@@ -454,7 +450,7 @@ module Aerospike
454
450
  GET_BY_KEY = 97
455
451
  GET_BY_INDEX = 98
456
452
  GET_BY_RANK = 100
457
- GET_BY_VALUE = 102; # GET_ALL_BY_VALUE on server
453
+ GET_BY_VALUE = 102 # GET_ALL_BY_VALUE on server
458
454
  GET_BY_KEY_INTERVAL = 103
459
455
  GET_BY_INDEX_RANGE = 104
460
456
  GET_BY_VALUE_INTERVAL = 105
@@ -465,11 +461,11 @@ module Aerospike
465
461
  GET_BY_VALUE_REL_RANK_RANGE = 110
466
462
 
467
463
  def self.add_write(bin, bytes, ctx)
468
- if ctx.to_a.empty?
469
- ret_type = Exp::Type::MAP
470
- else
471
- ret_type = ((ctx[0].id & 0x10) == 0) ? Exp::Type::MAP : Exp::Type::LIST
472
- end
464
+ ret_type = if ctx.to_a.empty?
465
+ Exp::Type::MAP
466
+ else
467
+ (ctx[0].id & 0x10) == 0 ? Exp::Type::MAP : Exp::Type::LIST
468
+ end
473
469
  Exp::Module.new(bin, bytes, ret_type, MODULE | Exp::MODIFY)
474
470
  end
475
471
 
@@ -480,25 +476,26 @@ module Aerospike
480
476
  def self.get_value_type(return_type)
481
477
  t = return_type & ~CDT::MapReturnType::INVERTED
482
478
  case t
483
- when CDT::MapReturnType::INDEX, CDT::MapReturnType::REVERSE_INDEX, CDT::MapReturnType::RANK, CDT::MapReturnType::REVERSE_RANK, CDT::MapReturnType::KEY, CDT::MapReturnType::VALUE
484
- Exp::Type::LIST
485
- when CDT::MapReturnType::COUNT
486
- Aerospike::Exp::Type::INT
487
- when CDT::MapReturnType::KEY_VALUE
488
- Exp::Type::MAP
489
- when CDT::MapReturnType::EXISTS
490
- Exp::Type::BOOL
479
+ when MapReturnType::INDEX, MapReturnType::REVERSE_INDEX, MapReturnType::RANK, MapReturnType::REVERSE_RANK
480
+ # This method only called from expressions that can return multiple integers (ie list).
481
+ Exp::Type::LIST
482
+
483
+ when MapReturnType::COUNT
484
+ Exp::Type::INT
485
+
486
+ when MapReturnType::KEY, MapReturnType::VALUE
487
+ # This method only called from expressions that can return multiple objects (ie list).
488
+ Exp::Type::LIST
489
+
490
+ when MapReturnType::KEY_VALUE, MapReturnType::ORDERED_MAP, MapReturnType::UNORDERED_MAP
491
+ Exp::Type::MAP
492
+
493
+ when MapReturnType::EXISTS
494
+ Exp::Type::BOOL
495
+
491
496
  else
492
- raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_ERROR, "Invalid MapReturnType: #{return_type}")
497
+ raise Exceptions::Aerospike.new(Aerospike::ResultCode::PARAMETER_ERROR, "Invalid MapReturnType: #{return_type}")
493
498
  end
494
- # if t <= CDT::MapReturnType::COUNT
495
- # return Exp::Type::INT
496
- # end
497
- #
498
- # if t == CDT::MapReturnType::KEY_VALUE
499
- # return Exp::Type::MAP
500
- # end
501
- # return Exp::Type::LIST
502
499
  end
503
500
  end # class MapExp
504
501
  end # module Aerospike
@@ -24,7 +24,7 @@ module Aerospike
24
24
  #
25
25
  # @param bin_name name of bin to store expression result
26
26
  # @param exp expression to evaluate
27
- # @param flags expression write flags. See {@link Exp::WriteFlags}
27
+ # @param flags expression write flags. See {Exp::WriteFlags}
28
28
  def self.write(bin_name, exp, flags = Aerospike::Exp::WriteFlags::DEFAULT)
29
29
  create_operation(Aerospike::Operation::EXP_MODIFY, bin_name, exp, flags)
30
30
  end
@@ -36,7 +36,7 @@ module Aerospike
36
36
  # @param name variable name of read expression result. This name can be used as the
37
37
  # bin name when retrieving bin results from the record.
38
38
  # @param exp expression to evaluate
39
- # @param flags expression read flags. See {@link Exp::ExpReadFlags}
39
+ # @param flags expression read flags. See {Exp::ExpReadFlags}
40
40
  def self.read(name, exp, flags = Aerospike::Exp::ReadFlags::DEFAULT)
41
41
  create_operation(Aerospike::Operation::EXP_READ, name, exp, flags)
42
42
  end
@@ -66,7 +66,6 @@ module Aerospike
66
66
  private
67
67
 
68
68
  def self.send_command(conn, offset, buffer)
69
- begin
70
69
  # Write size field.
71
70
  size = (offset - 8) | (2 << 56) | (1 << 48)
72
71
 
@@ -82,12 +81,11 @@ module Aerospike
82
81
  buffer.resize(length)
83
82
 
84
83
  conn.read(buffer, length)
85
- return length
86
- rescue => e
84
+ length
85
+ rescue => e
87
86
  Aerospike.logger.error(e)
88
87
  conn.close if conn
89
88
  raise e
90
- end
91
89
  end
92
90
 
93
91
  end
@@ -71,6 +71,10 @@ module Aerospike
71
71
  (@features & HAS_QUERY_SHOW) != 0
72
72
  end
73
73
 
74
+ def batch_any?
75
+ (@features & HAS_BATCH_ANY) != 0
76
+ end
77
+
74
78
  def update_racks(parser)
75
79
  new_racks = parser.update_racks
76
80
  @racks.value = new_racks if new_racks
@@ -78,7 +82,7 @@ module Aerospike
78
82
 
79
83
  def has_rack(ns, rack_id)
80
84
  racks = @racks.value
81
- return false if !racks
85
+ return false unless racks
82
86
  racks[ns] == rack_id
83
87
  end
84
88
 
@@ -108,7 +112,7 @@ module Aerospike
108
112
  # Put back a connection to the cache. If cache is full, the connection will be
109
113
  # closed and discarded
110
114
  def put_connection(conn)
111
- conn.close if !active?
115
+ conn.close unless active?
112
116
  @connections.offer(conn)
113
117
  end
114
118
 
@@ -236,7 +240,7 @@ module Aerospike
236
240
  Node::Refresh::Partitions.(self, peers)
237
241
  end
238
242
 
239
- def refresh_racks()
243
+ def refresh_racks
240
244
  Node::Refresh::Racks.(self)
241
245
  end
242
246
 
@@ -80,5 +80,43 @@ module Aerospike
80
80
  def self.delete
81
81
  Operation.new(DELETE)
82
82
  end
83
+
84
+ # :nodoc:
85
+ def is_write?
86
+ case @op_type
87
+ when READ
88
+ false
89
+ when READ_HEADER
90
+ false
91
+ when WRITE
92
+ true
93
+ when CDT_READ
94
+ false
95
+ when CDT_MODIFY
96
+ true
97
+ when ADD
98
+ true
99
+ when EXP_READ
100
+ false
101
+ when EXP_MODIFY
102
+ true
103
+ when APPEND
104
+ true
105
+ when PREPEND
106
+ true
107
+ when TOUCH
108
+ true
109
+ when BIT_READ
110
+ false
111
+ when BIT_MODIFY
112
+ true
113
+ when DELETE
114
+ true
115
+ when HLL_READ
116
+ false
117
+ when HLL_MODIFY
118
+ true
119
+ end
120
+ end
83
121
  end
84
122
  end # module