aerospike 2.8.0 → 2.9.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 +12 -0
- data/lib/aerospike.rb +1 -0
- data/lib/aerospike/client.rb +74 -47
- data/lib/aerospike/cluster.rb +1 -1
- data/lib/aerospike/features.rb +44 -0
- data/lib/aerospike/policy/client_policy.rb +4 -0
- data/lib/aerospike/policy/write_policy.rb +2 -2
- data/lib/aerospike/result_code.rb +1 -1
- data/lib/aerospike/utils/packer.rb +8 -3
- data/lib/aerospike/value/value.rb +86 -3
- data/lib/aerospike/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4a6204e2eedbfcbd9a755abdc89da26d978ec5cddbc401b9085863e953c9a5a
|
4
|
+
data.tar.gz: 9ef1ad5e358a98a30da46cf6aded8bc8958f62e16f239523f313a7c2ddd169b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca26471e04a8999b081699e2b68f51eaa00e28cc1e8e8fc4d7e0f1fa2830de9dbb5725b888420cab85dbd5f34af2dae675b81963a9b7c88320e3393e2b0c1a1
|
7
|
+
data.tar.gz: c854595481004116f1c0fd90600dcf0ba94dfe9b371a8a310a21afae601dd491ecd960658cfe7fe3f08859259af421b19453aeec2cfda68484af328f7c98657c
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [2.9.0] - 2018-11-09
|
8
|
+
|
9
|
+
* **New Features**
|
10
|
+
* Add INFINITY and WILDCARD values for use in CDT map/list comparators. [AER-5945]
|
11
|
+
|
12
|
+
* **Bug Fixes**
|
13
|
+
* Default policies set on Client instance do not get applied [[#74](https://github.com/aerospike/aerospike-client-ruby/issue/74)]
|
14
|
+
|
15
|
+
* **Updates**
|
16
|
+
* *BREAKING CHANGE*: Change default for send_key write policy to false [[#73](https://github.com/aerospike/aerospike-client-ruby/issue/73)]
|
17
|
+
* Support truncate info command argument "lut=now" for servers that require it. [AER-5955]
|
18
|
+
|
7
19
|
## [2.8.0] - 2018-08-06
|
8
20
|
|
9
21
|
* **New Features**
|
data/lib/aerospike.rb
CHANGED
data/lib/aerospike/client.rb
CHANGED
@@ -37,18 +37,19 @@ module Aerospike
|
|
37
37
|
|
38
38
|
class Client
|
39
39
|
|
40
|
-
attr_accessor :
|
41
|
-
|
40
|
+
attr_accessor :default_admin_policy
|
41
|
+
attr_accessor :default_batch_policy
|
42
|
+
attr_accessor :default_info_policy
|
43
|
+
attr_accessor :default_query_policy
|
44
|
+
attr_accessor :default_read_policy
|
45
|
+
attr_accessor :default_scan_policy
|
46
|
+
attr_accessor :default_write_policy
|
42
47
|
|
43
48
|
def initialize(hosts = nil, policy: ClientPolicy.new, connect: true)
|
44
|
-
@default_policy = Policy.new
|
45
|
-
@default_write_policy = WritePolicy.new
|
46
|
-
@default_scan_policy = ScanPolicy.new
|
47
|
-
@default_query_policy = QueryPolicy.new
|
48
|
-
@default_admin_policy = QueryPolicy.new
|
49
49
|
|
50
50
|
hosts = ::Aerospike::Host::Parse.(hosts || ENV['AEROSPIKE_HOSTS'] || 'localhost')
|
51
51
|
policy = create_policy(policy, ClientPolicy)
|
52
|
+
set_default_policies(policy.policies)
|
52
53
|
@cluster = Cluster.new(policy, hosts)
|
53
54
|
@cluster.add_cluster_config_change_listener(self)
|
54
55
|
|
@@ -112,7 +113,7 @@ module Aerospike
|
|
112
113
|
# client.put key, {'bin', 'value string'}, :timeout => 0.001
|
113
114
|
|
114
115
|
def put(key, bins, options = nil)
|
115
|
-
policy = create_policy(options, WritePolicy)
|
116
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
116
117
|
command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::WRITE)
|
117
118
|
execute_command(command)
|
118
119
|
end
|
@@ -135,7 +136,7 @@ module Aerospike
|
|
135
136
|
# client.append key, {'bin', 'value to append'}, :timeout => 0.001
|
136
137
|
|
137
138
|
def append(key, bins, options = nil)
|
138
|
-
policy = create_policy(options, WritePolicy)
|
139
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
139
140
|
command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::APPEND)
|
140
141
|
execute_command(command)
|
141
142
|
end
|
@@ -154,7 +155,7 @@ module Aerospike
|
|
154
155
|
# client.prepend key, {'bin', 'value to prepend'}, :timeout => 0.001
|
155
156
|
|
156
157
|
def prepend(key, bins, options = nil)
|
157
|
-
policy = create_policy(options, WritePolicy)
|
158
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
158
159
|
command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::PREPEND)
|
159
160
|
execute_command(command)
|
160
161
|
end
|
@@ -177,7 +178,7 @@ module Aerospike
|
|
177
178
|
# client.add key, {'bin', -1}, :timeout => 0.001
|
178
179
|
|
179
180
|
def add(key, bins, options = nil)
|
180
|
-
policy = create_policy(options, WritePolicy)
|
181
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
181
182
|
command = WriteCommand.new(@cluster, policy, key, hash_to_bins(bins), Aerospike::Operation::ADD)
|
182
183
|
execute_command(command)
|
183
184
|
end
|
@@ -199,7 +200,7 @@ module Aerospike
|
|
199
200
|
# existed = client.delete key, :timeout => 0.001
|
200
201
|
|
201
202
|
def delete(key, options = nil)
|
202
|
-
policy = create_policy(options, WritePolicy)
|
203
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
203
204
|
command = DeleteCommand.new(@cluster, policy, key)
|
204
205
|
execute_command(command)
|
205
206
|
command.existed
|
@@ -221,10 +222,18 @@ module Aerospike
|
|
221
222
|
# If no policy options are provided, +@default_info_policy+ will be used.
|
222
223
|
|
223
224
|
def truncate(namespace, set_name = nil, before_last_update = nil, options = {})
|
224
|
-
policy = create_policy(options,
|
225
|
+
policy = create_policy(options, Policy, default_info_policy)
|
226
|
+
|
225
227
|
str_cmd = "truncate:namespace=#{namespace}"
|
226
228
|
str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?
|
227
|
-
|
229
|
+
|
230
|
+
if before_last_update
|
231
|
+
lut_nanos = (before_last_update.to_f * 1_000_000_000.0).round
|
232
|
+
str_cmd << ";lut=#{lut_nanos}"
|
233
|
+
elsif supports_feature?(Aerospike::Features::LUT_NOW)
|
234
|
+
# Servers >= 4.3.1.4 require lut argument
|
235
|
+
str_cmd << ";lut=now"
|
236
|
+
end
|
228
237
|
|
229
238
|
# Send index command to one node. That node will distribute the command to other nodes.
|
230
239
|
response = send_info_command(policy, str_cmd).upcase
|
@@ -247,7 +256,7 @@ module Aerospike
|
|
247
256
|
# client.touch key, :timeout => 0.001
|
248
257
|
|
249
258
|
def touch(key, options = nil)
|
250
|
-
policy = create_policy(options, WritePolicy)
|
259
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
251
260
|
command = TouchCommand.new(@cluster, policy, key)
|
252
261
|
execute_command(command)
|
253
262
|
end
|
@@ -260,7 +269,7 @@ module Aerospike
|
|
260
269
|
# Determines if a record key exists.
|
261
270
|
# The policy can be used to specify timeouts.
|
262
271
|
def exists(key, options = nil)
|
263
|
-
policy = create_policy(options, Policy)
|
272
|
+
policy = create_policy(options, Policy, default_read_policy)
|
264
273
|
command = ExistsCommand.new(@cluster, policy, key)
|
265
274
|
execute_command(command)
|
266
275
|
command.exists
|
@@ -273,7 +282,7 @@ module Aerospike
|
|
273
282
|
# Read record header and bins for specified key.
|
274
283
|
# The policy can be used to specify timeouts.
|
275
284
|
def get(key, bin_names = nil, options = nil)
|
276
|
-
policy = create_policy(options, Policy)
|
285
|
+
policy = create_policy(options, Policy, default_read_policy)
|
277
286
|
|
278
287
|
command = ReadCommand.new(@cluster, policy, key, bin_names)
|
279
288
|
execute_command(command)
|
@@ -283,7 +292,7 @@ module Aerospike
|
|
283
292
|
# Read record generation and expiration only for specified key. Bins are not read.
|
284
293
|
# The policy can be used to specify timeouts.
|
285
294
|
def get_header(key, options = nil)
|
286
|
-
policy = create_policy(options, Policy)
|
295
|
+
policy = create_policy(options, Policy, default_read_policy)
|
287
296
|
command = ReadHeaderCommand.new(@cluster, policy, key)
|
288
297
|
execute_command(command)
|
289
298
|
command.record
|
@@ -298,7 +307,7 @@ module Aerospike
|
|
298
307
|
# If a key is not found, the positional record will be nil.
|
299
308
|
# The policy can be used to specify timeouts and protocol type.
|
300
309
|
def batch_get(keys, bin_names = nil, options = nil)
|
301
|
-
policy = create_policy(options, BatchPolicy)
|
310
|
+
policy = create_policy(options, BatchPolicy, default_batch_policy)
|
302
311
|
results = Array.new(keys.length)
|
303
312
|
info_flags = INFO1_READ
|
304
313
|
|
@@ -337,7 +346,7 @@ module Aerospike
|
|
337
346
|
# The returned boolean array is in positional order with the original key array order.
|
338
347
|
# The policy can be used to specify timeouts and protocol type.
|
339
348
|
def batch_exists(keys, options = nil)
|
340
|
-
policy = create_policy(options, BatchPolicy)
|
349
|
+
policy = create_policy(options, BatchPolicy, default_batch_policy)
|
341
350
|
results = Array.new(keys.length)
|
342
351
|
|
343
352
|
if policy.use_batch_direct
|
@@ -363,7 +372,7 @@ module Aerospike
|
|
363
372
|
# read the result, all in one database call. Operations are executed in
|
364
373
|
# the order they are specified.
|
365
374
|
def operate(key, operations, options = nil)
|
366
|
-
policy = create_policy(options, WritePolicy)
|
375
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
367
376
|
|
368
377
|
command = OperateCommand.new(@cluster, policy, key, operations)
|
369
378
|
execute_command(command)
|
@@ -392,12 +401,14 @@ module Aerospike
|
|
392
401
|
#
|
393
402
|
# This method is only supported by Aerospike 3 servers.
|
394
403
|
def register_udf(udf_body, server_path, language, options = nil)
|
395
|
-
|
404
|
+
policy = create_policy(options, Policy, default_info_policy)
|
396
405
|
|
406
|
+
content = Base64.strict_encode64(udf_body).force_encoding('binary')
|
397
407
|
str_cmd = "udf-put:filename=#{server_path};content=#{content};"
|
398
408
|
str_cmd << "content-len=#{content.length};udf-type=#{language};"
|
409
|
+
|
399
410
|
# Send UDF to one node. That node will distribute the UDF to other nodes.
|
400
|
-
response_map = @cluster.request_info(
|
411
|
+
response_map = @cluster.request_info(policy, str_cmd)
|
401
412
|
|
402
413
|
res = {}
|
403
414
|
response_map.each do |k, response|
|
@@ -422,11 +433,13 @@ module Aerospike
|
|
422
433
|
#
|
423
434
|
# This method is only supported by Aerospike 3 servers.
|
424
435
|
def remove_udf(udf_name, options = nil)
|
436
|
+
policy = create_policy(options, Policy, default_info_policy)
|
437
|
+
|
425
438
|
str_cmd = "udf-remove:filename=#{udf_name};"
|
426
439
|
|
427
440
|
# Send command to one node. That node will distribute it to other nodes.
|
428
441
|
# Send UDF to one node. That node will distribute the UDF to other nodes.
|
429
|
-
response_map = @cluster.request_info(
|
442
|
+
response_map = @cluster.request_info(policy, str_cmd)
|
430
443
|
_, response = response_map.first
|
431
444
|
|
432
445
|
if response == 'ok'
|
@@ -439,10 +452,12 @@ module Aerospike
|
|
439
452
|
# ListUDF lists all packages containing user defined functions in the server.
|
440
453
|
# This method is only supported by Aerospike 3 servers.
|
441
454
|
def list_udf(options = nil)
|
455
|
+
policy = create_policy(options, Policy, default_info_policy)
|
456
|
+
|
442
457
|
str_cmd = 'udf-list'
|
443
458
|
|
444
459
|
# Send command to one node. That node will distribute it to other nodes.
|
445
|
-
response_map = @cluster.request_info(
|
460
|
+
response_map = @cluster.request_info(policy, str_cmd)
|
446
461
|
_, response = response_map.first
|
447
462
|
|
448
463
|
vals = response.split(';')
|
@@ -475,7 +490,7 @@ module Aerospike
|
|
475
490
|
#
|
476
491
|
# This method is only supported by Aerospike 3 servers.
|
477
492
|
def execute_udf(key, package_name, function_name, args=[], options = nil)
|
478
|
-
policy = create_policy(options, WritePolicy)
|
493
|
+
policy = create_policy(options, WritePolicy, default_write_policy)
|
479
494
|
|
480
495
|
command = ExecuteCommand.new(@cluster, policy, key, package_name, function_name, args)
|
481
496
|
execute_command(command)
|
@@ -504,7 +519,7 @@ module Aerospike
|
|
504
519
|
# This method is only supported by Aerospike 3 servers.
|
505
520
|
# If the policy is nil, the default relevant policy will be used.
|
506
521
|
def execute_udf_on_query(statement, package_name, function_name, function_args=[], options = nil)
|
507
|
-
policy = create_policy(options, QueryPolicy)
|
522
|
+
policy = create_policy(options, QueryPolicy, default_query_policy)
|
508
523
|
|
509
524
|
nodes = @cluster.nodes
|
510
525
|
if nodes.empty?
|
@@ -540,11 +555,12 @@ module Aerospike
|
|
540
555
|
# This method is only supported by Aerospike 3 servers.
|
541
556
|
# index_type should be :string, :numeric or :geo2dsphere (requires server version 3.7 or later)
|
542
557
|
# collection_type should be :list, :mapkeys or :mapvalues
|
543
|
-
def create_index(namespace, set_name, index_name, bin_name, index_type, collection_type=nil, options = nil)
|
558
|
+
def create_index(namespace, set_name, index_name, bin_name, index_type, collection_type = nil, options = nil)
|
544
559
|
if options.nil? && collection_type.is_a?(Hash)
|
545
560
|
options, collection_type = collection_type, nil
|
546
561
|
end
|
547
|
-
policy = create_policy(options,
|
562
|
+
policy = create_policy(options, Policy, default_info_policy)
|
563
|
+
|
548
564
|
str_cmd = "sindex-create:ns=#{namespace}"
|
549
565
|
str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?
|
550
566
|
str_cmd << ";indexname=#{index_name};numbins=1"
|
@@ -570,7 +586,8 @@ module Aerospike
|
|
570
586
|
# Delete secondary index.
|
571
587
|
# This method is only supported by Aerospike 3 servers.
|
572
588
|
def drop_index(namespace, set_name, index_name, options = nil)
|
573
|
-
policy = create_policy(options,
|
589
|
+
policy = create_policy(options, Policy, default_info_policy)
|
590
|
+
|
574
591
|
str_cmd = "sindex-delete:ns=#{namespace}"
|
575
592
|
str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?
|
576
593
|
str_cmd << ";indexname=#{index_name}"
|
@@ -585,8 +602,9 @@ module Aerospike
|
|
585
602
|
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::INDEX_GENERIC, "Drop index failed: #{response}")
|
586
603
|
end
|
587
604
|
|
588
|
-
def request_info(*commands)
|
589
|
-
|
605
|
+
def request_info(*commands, policy: nil)
|
606
|
+
policy = create_policy(policy, Policy, default_info_policy)
|
607
|
+
@cluster.request_info(policy, *commands)
|
590
608
|
end
|
591
609
|
|
592
610
|
#-------------------------------------------------------
|
@@ -594,7 +612,7 @@ module Aerospike
|
|
594
612
|
#-------------------------------------------------------
|
595
613
|
|
596
614
|
def scan_all(namespace, set_name, bin_names = nil, options = nil)
|
597
|
-
policy = create_policy(options, ScanPolicy)
|
615
|
+
policy = create_policy(options, ScanPolicy, default_scan_policy)
|
598
616
|
|
599
617
|
# wait until all migrations are finished
|
600
618
|
# TODO: implement
|
@@ -650,7 +668,7 @@ module Aerospike
|
|
650
668
|
# ScanNode reads all records in specified namespace and set, from one node only.
|
651
669
|
# The policy can be used to specify timeouts.
|
652
670
|
def scan_node(node, namespace, set_name, bin_names = nil, options = nil)
|
653
|
-
policy = create_policy(options, ScanPolicy)
|
671
|
+
policy = create_policy(options, ScanPolicy, default_scan_policy)
|
654
672
|
# wait until all migrations are finished
|
655
673
|
# TODO: implement
|
656
674
|
# @cluster.WaitUntillMigrationIsFinished(policy.timeout)
|
@@ -692,7 +710,7 @@ module Aerospike
|
|
692
710
|
# This method is only supported by Aerospike 3 servers.
|
693
711
|
# If the policy is nil, a default policy will be generated.
|
694
712
|
def query(statement, options = nil)
|
695
|
-
policy = create_policy(options, QueryPolicy)
|
713
|
+
policy = create_policy(options, QueryPolicy, default_query_policy)
|
696
714
|
new_policy = policy.clone
|
697
715
|
|
698
716
|
nodes = @cluster.nodes
|
@@ -728,7 +746,7 @@ module Aerospike
|
|
728
746
|
# Create user with password and roles. Clear-text password will be hashed using bcrypt
|
729
747
|
# before sending to server.
|
730
748
|
def create_user(user, password, roles, options = nil)
|
731
|
-
policy = create_policy(options, AdminPolicy)
|
749
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
732
750
|
hash = AdminCommand.hash_password(password)
|
733
751
|
command = AdminCommand.new
|
734
752
|
command.create_user(@cluster, policy, user, hash, roles)
|
@@ -736,7 +754,7 @@ module Aerospike
|
|
736
754
|
|
737
755
|
# Remove user from cluster.
|
738
756
|
def drop_user(user, options = nil)
|
739
|
-
policy = create_policy(options, AdminPolicy)
|
757
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
740
758
|
command = AdminCommand.new
|
741
759
|
command.drop_user(@cluster, policy, user)
|
742
760
|
end
|
@@ -744,7 +762,7 @@ module Aerospike
|
|
744
762
|
# Change user's password. Clear-text password will be hashed using bcrypt before sending to server.
|
745
763
|
def change_password(user, password, options = nil)
|
746
764
|
raise Aerospike::Exceptions::Aerospike.new(INVALID_USER) unless @cluster.user && @cluster.user != ""
|
747
|
-
policy = create_policy(options, AdminPolicy)
|
765
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
748
766
|
|
749
767
|
hash = AdminCommand.hash_password(password)
|
750
768
|
command = AdminCommand.new
|
@@ -762,36 +780,45 @@ module Aerospike
|
|
762
780
|
|
763
781
|
# Add roles to user's list of roles.
|
764
782
|
def grant_roles(user, roles, options = nil)
|
765
|
-
policy = create_policy(options, AdminPolicy)
|
783
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
766
784
|
command = AdminCommand.new
|
767
785
|
command.grant_roles(@cluster, policy, user, roles)
|
768
786
|
end
|
769
787
|
|
770
788
|
# Remove roles from user's list of roles.
|
771
789
|
def revoke_roles(user, roles, options = nil)
|
772
|
-
policy = create_policy(options, AdminPolicy)
|
790
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
773
791
|
command = AdminCommand.new
|
774
792
|
command.revoke_roles(@cluster, policy, user, roles)
|
775
793
|
end
|
776
794
|
|
777
795
|
# Retrieve roles for a given user.
|
778
796
|
def query_user(user, options = nil)
|
779
|
-
policy = create_policy(options, AdminPolicy)
|
797
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
780
798
|
command = AdminCommand.new
|
781
799
|
command.query_user(@cluster, policy, user)
|
782
800
|
end
|
783
801
|
|
784
802
|
# Retrieve all users and their roles.
|
785
803
|
def query_users(options = nil)
|
786
|
-
policy = create_policy(options, AdminPolicy)
|
804
|
+
policy = create_policy(options, AdminPolicy, default_admin_policy)
|
787
805
|
command = AdminCommand.new
|
788
806
|
command.query_users(@cluster, policy)
|
789
807
|
end
|
790
808
|
|
791
809
|
private
|
792
810
|
|
811
|
+
def set_default_policies(policies)
|
812
|
+
self.default_info_policy = create_policy(policies[:info], Policy)
|
813
|
+
self.default_read_policy = create_policy(policies[:read], Policy)
|
814
|
+
self.default_admin_policy = create_policy(policies[:admin], AdminPolicy)
|
815
|
+
self.default_batch_policy = create_policy(policies[:batch], BatchPolicy)
|
816
|
+
self.default_query_policy = create_policy(policies[:query], QueryPolicy)
|
817
|
+
self.default_scan_policy = create_policy(policies[:scan], ScanPolicy)
|
818
|
+
self.default_write_policy = create_policy(policies[:write], WritePolicy)
|
819
|
+
end
|
820
|
+
|
793
821
|
def send_info_command(policy, command)
|
794
|
-
policy ||= default_policy
|
795
822
|
Aerospike.logger.debug { "Sending info command: #{command}" }
|
796
823
|
_, response = @cluster.request_info(policy, command).first
|
797
824
|
response.to_s
|
@@ -810,10 +837,10 @@ module Aerospike
|
|
810
837
|
end
|
811
838
|
end
|
812
839
|
|
813
|
-
def create_policy(policy, policy_klass)
|
840
|
+
def create_policy(policy, policy_klass, default_policy = nil)
|
814
841
|
case policy
|
815
842
|
when nil
|
816
|
-
policy_klass.new
|
843
|
+
default_policy || policy_klass.new
|
817
844
|
when policy_klass
|
818
845
|
policy
|
819
846
|
when Hash
|
@@ -838,8 +865,8 @@ module Aerospike
|
|
838
865
|
|
839
866
|
# guard against unsupported particle types
|
840
867
|
unsupported_particle_types = []
|
841
|
-
unsupported_particle_types << Aerospike::ParticleType::DOUBLE unless
|
842
|
-
unsupported_particle_types << Aerospike::ParticleType::GEOJSON unless
|
868
|
+
unsupported_particle_types << Aerospike::ParticleType::DOUBLE unless supports_feature?(Aerospike::Features::FLOAT)
|
869
|
+
unsupported_particle_types << Aerospike::ParticleType::GEOJSON unless supports_feature?(Aerospike::Features::GEO)
|
843
870
|
validators << UnsupportedParticleTypeValidator.new(*unsupported_particle_types) unless unsupported_particle_types.empty?
|
844
871
|
|
845
872
|
@command_validators = validators
|
data/lib/aerospike/cluster.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2014-2017 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 http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15
|
+
# License for the specific language governing permissions and limitations under
|
16
|
+
# the License.
|
17
|
+
|
18
|
+
module Aerospike
|
19
|
+
|
20
|
+
# Feature flags describing capabilities of the Aerospike server cluster the
|
21
|
+
# client is connected to. The list of supported server features can be
|
22
|
+
# retrieved by issuing the "features" info command.
|
23
|
+
module Features
|
24
|
+
|
25
|
+
# Server supports List Complex Data Type (CDT)
|
26
|
+
CDT_LIST = :"cdt-list"
|
27
|
+
|
28
|
+
# Server supports Map Complex Data Type (CDT)
|
29
|
+
CDT_MAP = :"cdt-map"
|
30
|
+
|
31
|
+
# Server supports Float data type
|
32
|
+
FLOAT = :float
|
33
|
+
|
34
|
+
# Server supports geo-spatial data type and indexing
|
35
|
+
GEO = :geo
|
36
|
+
|
37
|
+
# Server requires "lut=now" in truncate command (AER-5955)
|
38
|
+
LUT_NOW = :"lut-now"
|
39
|
+
|
40
|
+
# Server supports the new "peers" protocol for automatic node discovery
|
41
|
+
PEERS = :peers
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -26,6 +26,7 @@ module Aerospike
|
|
26
26
|
attr_accessor :timeout, :connection_queue_size, :fail_if_not_connected, :tend_interval
|
27
27
|
attr_accessor :cluster_name
|
28
28
|
attr_accessor :tls
|
29
|
+
attr_accessor :policies
|
29
30
|
|
30
31
|
def initialize(opt={})
|
31
32
|
# Initial host connection timeout in seconds. The timeout when opening a connection
|
@@ -52,6 +53,9 @@ module Aerospike
|
|
52
53
|
@cluster_name = opt[:cluster_name]
|
53
54
|
|
54
55
|
@tls = opt[:tls] || opt[:ssl_options]
|
56
|
+
|
57
|
+
# Default Policies
|
58
|
+
@policies = opt.fetch(:policies) { Hash.new }
|
55
59
|
end
|
56
60
|
|
57
61
|
def requires_authentication
|
@@ -65,8 +65,8 @@ module Aerospike
|
|
65
65
|
@ttl = opt[:ttl] || opt[:expiration] || 0
|
66
66
|
|
67
67
|
# Send user defined key in addition to hash digest on a record put.
|
68
|
-
# The default is to send the user defined key.
|
69
|
-
@send_key = opt
|
68
|
+
# The default is to _not_ send the user defined key.
|
69
|
+
@send_key = opt.fetch(:send_key, false)
|
70
70
|
|
71
71
|
# If the transaction results in a record deletion, leave a tombstone for
|
72
72
|
# the record. This prevents deleted records from reappearing after node
|
@@ -107,7 +107,7 @@ module Aerospike
|
|
107
107
|
# Invalid namespace.
|
108
108
|
INVALID_NAMESPACE = 20
|
109
109
|
|
110
|
-
# Sent too-long bin name (>
|
110
|
+
# Sent too-long bin name (>15, should be impossible in this client) or exceeded
|
111
111
|
# namespace's bin name quota.
|
112
112
|
BIN_NAME_TOO_LONG = 21
|
113
113
|
|
@@ -19,12 +19,17 @@ require 'aerospike/utils/pool'
|
|
19
19
|
|
20
20
|
module Aerospike
|
21
21
|
|
22
|
-
private
|
23
|
-
|
24
22
|
class Packer < MessagePack::Packer #:nodoc:
|
25
23
|
|
24
|
+
AS_EXT_TYPE = -1
|
25
|
+
|
26
26
|
@@pool = Pool.new
|
27
|
-
@@pool.create_proc =
|
27
|
+
@@pool.create_proc = lambda do
|
28
|
+
Packer.new.tap do |p|
|
29
|
+
p.register_type(AS_EXT_TYPE, Aerospike::WildcardValue, :to_msgpack_ext)
|
30
|
+
p.register_type(AS_EXT_TYPE, Aerospike::InfinityValue, :to_msgpack_ext)
|
31
|
+
end
|
32
|
+
end
|
28
33
|
|
29
34
|
def self.use
|
30
35
|
packer = @@pool.poll
|
@@ -27,7 +27,7 @@ module Aerospike
|
|
27
27
|
def self.of(value)
|
28
28
|
case value
|
29
29
|
when nil
|
30
|
-
res =
|
30
|
+
res = NULL
|
31
31
|
when Integer
|
32
32
|
if INTEGER_RANGE.cover?(value)
|
33
33
|
res = IntegerValue.new(value)
|
@@ -59,7 +59,6 @@ module Aerospike
|
|
59
59
|
|
60
60
|
end # Value
|
61
61
|
|
62
|
-
|
63
62
|
# Empty value.
|
64
63
|
class NullValue < Value #:nodoc:
|
65
64
|
|
@@ -79,7 +78,6 @@ module Aerospike
|
|
79
78
|
''
|
80
79
|
end
|
81
80
|
|
82
|
-
|
83
81
|
def estimate_size
|
84
82
|
0
|
85
83
|
end
|
@@ -97,6 +95,91 @@ module Aerospike
|
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
98
|
+
NULL = NullValue.new.freeze
|
99
|
+
|
100
|
+
|
101
|
+
# Infinity value.
|
102
|
+
class InfinityValue < Value #:nodoc:
|
103
|
+
def initialize
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
def type
|
108
|
+
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::PARAMETER_ERROR, "Invalid particle type: INF")
|
109
|
+
end
|
110
|
+
|
111
|
+
def get
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_s
|
116
|
+
"INF"
|
117
|
+
end
|
118
|
+
|
119
|
+
def estimate_size
|
120
|
+
0
|
121
|
+
end
|
122
|
+
|
123
|
+
def write(buffer, offset)
|
124
|
+
0
|
125
|
+
end
|
126
|
+
|
127
|
+
def pack(packer)
|
128
|
+
packer.pack(self)
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_bytes
|
132
|
+
''
|
133
|
+
end
|
134
|
+
|
135
|
+
def to_msgpack_ext
|
136
|
+
1.chr
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
INFINITY = InfinityValue.new.freeze
|
141
|
+
|
142
|
+
# Wildcard value.
|
143
|
+
class WildcardValue < Value #:nodoc:
|
144
|
+
def initialize
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
def type
|
149
|
+
raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::PARAMETER_ERROR, "Invalid particle type: wildcard")
|
150
|
+
end
|
151
|
+
|
152
|
+
def get
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
|
156
|
+
def to_s
|
157
|
+
"*"
|
158
|
+
end
|
159
|
+
|
160
|
+
def estimate_size
|
161
|
+
0
|
162
|
+
end
|
163
|
+
|
164
|
+
def write(buffer, offset)
|
165
|
+
0
|
166
|
+
end
|
167
|
+
|
168
|
+
def pack(packer)
|
169
|
+
packer.pack(self)
|
170
|
+
end
|
171
|
+
|
172
|
+
def to_bytes
|
173
|
+
''
|
174
|
+
end
|
175
|
+
|
176
|
+
def to_msgpack_ext
|
177
|
+
0.chr
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
WILDCARD = WildcardValue.new.freeze
|
182
|
+
|
100
183
|
# Byte array value.
|
101
184
|
class BytesValue < Value #:nodoc:
|
102
185
|
|
data/lib/aerospike/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aerospike
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khosrow Afroozeh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/aerospike/command/write_command.rb
|
100
100
|
- lib/aerospike/connection/authenticate.rb
|
101
101
|
- lib/aerospike/connection/create.rb
|
102
|
+
- lib/aerospike/features.rb
|
102
103
|
- lib/aerospike/geo_json.rb
|
103
104
|
- lib/aerospike/host.rb
|
104
105
|
- lib/aerospike/host/parse.rb
|