aerospike 2.19.0 → 2.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +354 -244
  3. data/lib/aerospike/atomic/atomic.rb +1 -1
  4. data/lib/aerospike/cdt/context.rb +137 -70
  5. data/lib/aerospike/cdt/list_return_type.rb +4 -0
  6. data/lib/aerospike/cdt/map_operation.rb +6 -6
  7. data/lib/aerospike/cdt/map_policy.rb +16 -2
  8. data/lib/aerospike/cdt/map_return_type.rb +13 -1
  9. data/lib/aerospike/client.rb +137 -115
  10. data/lib/aerospike/cluster/create_connection.rb +1 -1
  11. data/lib/aerospike/cluster.rb +41 -4
  12. data/lib/aerospike/command/admin_command.rb +368 -52
  13. data/lib/aerospike/command/batch_index_command.rb +4 -8
  14. data/lib/aerospike/command/batch_index_exists_command.rb +1 -1
  15. data/lib/aerospike/command/batch_index_node.rb +1 -1
  16. data/lib/aerospike/command/batch_item.rb +1 -1
  17. data/lib/aerospike/command/command.rb +180 -123
  18. data/lib/aerospike/command/field_type.rb +25 -24
  19. data/lib/aerospike/command/login_command.rb +164 -0
  20. data/lib/aerospike/command/multi_command.rb +25 -2
  21. data/lib/aerospike/command/operate_args.rb +99 -0
  22. data/lib/aerospike/command/operate_command.rb +6 -11
  23. data/lib/aerospike/command/read_command.rb +2 -2
  24. data/lib/aerospike/connection/authenticate.rb +36 -3
  25. data/lib/aerospike/exp/exp.rb +1329 -0
  26. data/lib/aerospike/exp/exp_bit.rb +388 -0
  27. data/lib/aerospike/exp/exp_hll.rb +169 -0
  28. data/lib/aerospike/exp/exp_list.rb +403 -0
  29. data/lib/aerospike/exp/exp_map.rb +493 -0
  30. data/lib/aerospike/exp/operation.rb +56 -0
  31. data/lib/aerospike/features.rb +22 -9
  32. data/lib/aerospike/host/parse.rb +2 -2
  33. data/lib/aerospike/key.rb +10 -1
  34. data/lib/aerospike/node/refresh/info.rb +1 -1
  35. data/lib/aerospike/node/verify/name.rb +1 -1
  36. data/lib/aerospike/node/verify/partition_generation.rb +1 -1
  37. data/lib/aerospike/node/verify/peers_generation.rb +1 -1
  38. data/lib/aerospike/node/verify/rebalance_generation.rb +1 -1
  39. data/lib/aerospike/node_validator.rb +6 -1
  40. data/lib/aerospike/operation.rb +20 -22
  41. data/lib/aerospike/policy/auth_mode.rb +36 -0
  42. data/lib/aerospike/policy/client_policy.rb +4 -1
  43. data/lib/aerospike/policy/policy.rb +29 -13
  44. data/lib/aerospike/policy/query_policy.rb +35 -2
  45. data/lib/aerospike/policy/scan_policy.rb +19 -2
  46. data/lib/aerospike/privilege.rb +133 -0
  47. data/lib/aerospike/query/filter.rb +44 -32
  48. data/lib/aerospike/query/node_partitions.rb +39 -0
  49. data/lib/aerospike/query/partition_filter.rb +66 -0
  50. data/lib/aerospike/{command/roles.rb → query/partition_status.rb} +16 -19
  51. data/lib/aerospike/query/partition_tracker.rb +347 -0
  52. data/lib/aerospike/query/query_command.rb +20 -10
  53. data/lib/aerospike/query/query_executor.rb +71 -0
  54. data/lib/aerospike/query/query_partition_command.rb +267 -0
  55. data/lib/aerospike/query/recordset.rb +9 -9
  56. data/lib/aerospike/query/scan_command.rb +3 -2
  57. data/lib/aerospike/query/scan_executor.rb +71 -0
  58. data/lib/aerospike/query/scan_partition_command.rb +49 -0
  59. data/lib/aerospike/query/statement.rb +8 -1
  60. data/lib/aerospike/query/stream_command.rb +17 -0
  61. data/lib/aerospike/result_code.rb +83 -8
  62. data/lib/aerospike/role.rb +55 -0
  63. data/lib/aerospike/task/execute_task.rb +19 -16
  64. data/lib/aerospike/task/index_task.rb +1 -1
  65. data/lib/aerospike/user_role.rb +26 -1
  66. data/lib/aerospike/utils/buffer.rb +93 -29
  67. data/lib/aerospike/utils/packer.rb +7 -6
  68. data/lib/aerospike/utils/pool.rb +1 -1
  69. data/lib/aerospike/value/particle_type.rb +1 -12
  70. data/lib/aerospike/value/value.rb +35 -60
  71. data/lib/aerospike/version.rb +1 -1
  72. data/lib/aerospike.rb +156 -136
  73. metadata +24 -6
@@ -17,28 +17,27 @@
17
17
  # License for the specific language governing permissions and limitations under
18
18
  # the License.
19
19
 
20
- require 'aerospike/aerospike_exception'
20
+ require "aerospike/aerospike_exception"
21
21
 
22
22
  module Aerospike
23
23
  # Polymorphic value classes used to efficiently serialize objects into the wire protocol.
24
24
  class Value #:nodoc:
25
-
26
25
  def self.of(value, allow_64bits = false)
27
26
  case value
28
27
  when Integer
29
- if !allow_64bits
30
- if value.bit_length < 64
28
+ if allow_64bits
29
+ # used in bitwise operations
30
+ if value.bit_length <= 64
31
31
  res = IntegerValue.new(value)
32
32
  else
33
- # big nums > 2**63 are not supported
33
+ # nums with more than 64 bits are not supported
34
34
  raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported with more than 64 bits.")
35
35
  end
36
36
  else
37
- # used in bitwise operations
38
- if value.bit_length <= 64
37
+ if value.bit_length < 64
39
38
  res = IntegerValue.new(value)
40
39
  else
41
- # nums with more than 64 bits are not supported
40
+ # big nums > 2**63 are not supported
42
41
  raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported with more than 64 bits.")
43
42
  end
44
43
  end
@@ -83,12 +82,10 @@ module Aerospike
83
82
  raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::TYPE_NOT_SUPPORTED, "Value type #{value.class} not supported as hash key.")
84
83
  end
85
84
  end
86
-
87
85
  end # Value
88
86
 
89
87
  # Empty value.
90
88
  class NullValue < Value #:nodoc:
91
-
92
89
  def initialize
93
90
  self
94
91
  end
@@ -102,7 +99,7 @@ module Aerospike
102
99
  end
103
100
 
104
101
  def to_s
105
- ''
102
+ ""
106
103
  end
107
104
 
108
105
  def estimate_size
@@ -118,13 +115,12 @@ module Aerospike
118
115
  end
119
116
 
120
117
  def to_bytes
121
- ''
118
+ ""
122
119
  end
123
120
  end
124
121
 
125
122
  NULL = NullValue.new.freeze
126
123
 
127
-
128
124
  # Infinity value.
129
125
  class InfinityValue < Value #:nodoc:
130
126
  def initialize
@@ -156,7 +152,7 @@ module Aerospike
156
152
  end
157
153
 
158
154
  def to_bytes
159
- ''
155
+ ""
160
156
  end
161
157
 
162
158
  def to_msgpack_ext
@@ -197,7 +193,7 @@ module Aerospike
197
193
  end
198
194
 
199
195
  def to_bytes
200
- ''
196
+ ""
201
197
  end
202
198
 
203
199
  def to_msgpack_ext
@@ -209,10 +205,9 @@ module Aerospike
209
205
 
210
206
  # Byte array value.
211
207
  class BytesValue < Value #:nodoc:
212
-
213
208
  def initialize(value)
214
209
  @bytes = value
215
- @bytes.force_encoding('binary')
210
+ @bytes.force_encoding("binary")
216
211
 
217
212
  self
218
213
  end
@@ -244,16 +239,14 @@ module Aerospike
244
239
  def pack(packer)
245
240
  packer.write(Aerospike::ParticleType::BLOB.chr + @bytes)
246
241
  end
247
-
248
242
  end # BytesValue
249
243
 
250
244
  #######################################
251
245
 
252
246
  # value string.
253
247
  class StringValue < Value #:nodoc:
254
-
255
248
  def initialize(val)
256
- @value = val || ''
249
+ @value = val || ""
257
250
  self
258
251
  end
259
252
 
@@ -289,14 +282,12 @@ module Aerospike
289
282
  def to_sym
290
283
  @value.to_sym
291
284
  end
292
-
293
285
  end # StringValue
294
286
 
295
287
  #######################################
296
288
 
297
289
  # Integer value.
298
290
  class IntegerValue < Value #:nodoc:
299
-
300
291
  def initialize(val)
301
292
  @value = val || 0
302
293
  self
@@ -326,20 +317,18 @@ module Aerospike
326
317
  def to_bytes
327
318
  # Convert integer to big endian unsigned 64 bits.
328
319
  # @see http://ruby-doc.org/core-2.3.0/Array.html#method-i-pack
329
- [@value].pack('Q>')
320
+ [@value].pack("Q>")
330
321
  end
331
322
 
332
323
  def to_s
333
324
  @value.to_s
334
325
  end
335
-
336
326
  end # IntegerValue
337
327
 
338
328
  #######################################
339
329
 
340
330
  # Float value.
341
331
  class FloatValue < Value #:nodoc:
342
-
343
332
  def initialize(val)
344
333
  @value = val || 0.0
345
334
  self
@@ -367,13 +356,12 @@ module Aerospike
367
356
  end
368
357
 
369
358
  def to_bytes
370
- [@value].pack('G')
359
+ [@value].pack("G")
371
360
  end
372
361
 
373
362
  def to_s
374
363
  @value.to_s
375
364
  end
376
-
377
365
  end # FloatValue
378
366
 
379
367
  #######################################
@@ -381,7 +369,6 @@ module Aerospike
381
369
  # List value.
382
370
  # Supported by Aerospike 3 servers only.
383
371
  class ListValue < Value #:nodoc:
384
-
385
372
  def initialize(list)
386
373
  @list = list || []
387
374
  end
@@ -415,7 +402,7 @@ module Aerospike
415
402
  end
416
403
 
417
404
  def to_s
418
- @list.map{|v| v.to_s}.to_s
405
+ @list.map { |v| v.to_s }.to_s
419
406
  end
420
407
 
421
408
  private
@@ -430,15 +417,13 @@ module Aerospike
430
417
 
431
418
  @bytes
432
419
  end
433
-
434
420
  end
435
421
 
436
422
  # #######################################/
437
423
 
438
424
  # Map value.
439
- # Supported by Aerospike 3 servers only.
425
+ # Supported by Aerospike 3+ servers only.
440
426
  class MapValue < Value #:nodoc:
441
-
442
427
  def initialize(vmap)
443
428
  @vmap = vmap || {}
444
429
  end
@@ -475,7 +460,7 @@ module Aerospike
475
460
  end
476
461
 
477
462
  def to_s
478
- @vmap.map{|k, v| "#{k.to_s} => #{v.to_s}" }.to_s
463
+ @vmap.map { |k, v| "#{k.to_s} => #{v.to_s}" }.to_s
479
464
  end
480
465
 
481
466
  private
@@ -490,7 +475,6 @@ module Aerospike
490
475
 
491
476
  @bytes
492
477
  end
493
-
494
478
  end
495
479
 
496
480
  # #######################################/
@@ -498,7 +482,6 @@ module Aerospike
498
482
  # GeoJSON value.
499
483
  # Supported by Aerospike server version 3.7 and later.
500
484
  class GeoJSONValue < Value #:nodoc:
501
-
502
485
  def initialize(json)
503
486
  @json = json
504
487
  @bytes = json.to_json
@@ -535,7 +518,6 @@ module Aerospike
535
518
  def to_s
536
519
  @json
537
520
  end
538
-
539
521
  end
540
522
 
541
523
  # #######################################/
@@ -543,14 +525,19 @@ module Aerospike
543
525
  # HLLValue value. Encapsulates a HyperLogLog value.
544
526
  # Supported by Aerospike server version 4.9 and later.
545
527
  class HLLValue < Value #:nodoc:
528
+ attr_reader :bytes
546
529
 
547
530
  def initialize(value)
548
531
  @bytes = value
549
- @bytes.force_encoding('binary')
532
+ @bytes.force_encoding("binary")
550
533
 
551
534
  self
552
535
  end
553
536
 
537
+ def ==(other)
538
+ @bytes.to_s == other.to_s
539
+ end
540
+
554
541
  def type
555
542
  Aerospike::ParticleType::HLL
556
543
  end
@@ -578,7 +565,6 @@ module Aerospike
578
565
  def pack(packer)
579
566
  packer.write(Aerospike::ParticleType::BLOB.chr + @bytes)
580
567
  end
581
-
582
568
  end
583
569
 
584
570
  #######################################
@@ -594,60 +580,49 @@ module Aerospike
594
580
  protected
595
581
 
596
582
  def self.bytes_to_particle(type, buf, offset, length) # :nodoc:
597
-
598
583
  case type
599
584
  when Aerospike::ParticleType::STRING
600
585
  bytes = buf.read(offset, length)
601
586
  bytes.force_encoding(Aerospike.encoding)
602
-
603
587
  when Aerospike::ParticleType::INTEGER
604
588
  buf.read_int64(offset)
605
-
606
589
  when Aerospike::ParticleType::DOUBLE
607
590
  buf.read_double(offset)
608
-
591
+ when Aerospike::ParticleType::BOOL
592
+ buf.read_bool(offset, length)
609
593
  when Aerospike::ParticleType::BLOB
610
- buf.read(offset,length)
611
-
594
+ buf.read(offset, length)
612
595
  when Aerospike::ParticleType::LIST
613
596
  Unpacker.use do |unpacker|
614
597
  data = buf.read(offset, length)
615
598
  unpacker.unpack(data)
616
599
  end
617
-
618
600
  when Aerospike::ParticleType::MAP
619
601
  Unpacker.use do |unpacker|
620
602
  data = buf.read(offset, length)
621
603
  unpacker.unpack(data)
622
604
  end
623
-
624
605
  when Aerospike::ParticleType::GEOJSON
625
606
  # ignore the flags for now
626
607
  ncells = buf.read_int16(offset + 1)
627
608
  hdrsz = 1 + 2 + (ncells * 8)
628
609
  Aerospike::GeoJSON.new(buf.read(offset + hdrsz, length - hdrsz))
629
-
630
610
  when Aerospike::ParticleType::HLL
631
- bytes = buf.read(offset,length)
611
+ bytes = buf.read(offset, length)
632
612
  Aerospike::HLLValue.new(bytes)
633
-
634
613
  else
635
614
  nil
636
615
  end
637
616
  end
638
617
 
639
618
  def self.bytes_to_key_value(type, buf, offset, len) # :nodoc:
640
-
641
619
  case type
642
620
  when Aerospike::ParticleType::STRING
643
621
  StringValue.new(buf.read(offset, len))
644
-
645
622
  when Aerospike::ParticleType::INTEGER
646
623
  IntegerValue.new(buf.read_var_int64(offset, len))
647
-
648
624
  when Aerospike::ParticleType::BLOB
649
- BytesValue.new(buf.read(offset,len))
650
-
625
+ BytesValue.new(buf.read(offset, len))
651
626
  else
652
627
  nil
653
628
  end
@@ -658,9 +633,8 @@ module Aerospike
658
633
  #######################################
659
634
 
660
635
  # Boolean value.
661
- # This is private, and only used internally for bitwise CDTs
636
+ # Supported by Aerospike server 5.6+ only.
662
637
  class BoolValue < Value #:nodoc:
663
-
664
638
  def initialize(val)
665
639
  @value = val || false
666
640
  self
@@ -671,7 +645,9 @@ module Aerospike
671
645
  end
672
646
 
673
647
  def write(buffer, offset)
674
- raise Exception.new("Unreachable")
648
+ val = @value ? 1 : 0
649
+ buffer.write_byte(val.ord, offset)
650
+ 1
675
651
  end
676
652
 
677
653
  def pack(packer)
@@ -679,7 +655,7 @@ module Aerospike
679
655
  end
680
656
 
681
657
  def type
682
- raise Exception.new("Unreachable")
658
+ Aerospike::ParticleType::BOOL
683
659
  end
684
660
 
685
661
  def get
@@ -687,12 +663,11 @@ module Aerospike
687
663
  end
688
664
 
689
665
  def to_bytes
690
- raise Exception.new("Unreachable")
666
+ @value.ord
691
667
  end
692
668
 
693
669
  def to_s
694
670
  @value.to_s
695
671
  end
696
-
697
672
  end # BoolValue
698
673
  end # module
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Aerospike
3
- VERSION = "2.19.0"
3
+ VERSION = "2.26.0"
4
4
  end