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
@@ -40,6 +40,7 @@ module Aerospike
40
40
 
41
41
  def get_hosts(address)
42
42
  aliases = [get_alias(address, host.port)]
43
+ res = []
43
44
 
44
45
  begin
45
46
  conn = Cluster::CreateConnection.(@cluster, Host.new(address, host.port, host.tls_name))
@@ -61,11 +62,15 @@ module Aerospike
61
62
  unless is_loopback?(address)
62
63
  aliases = info_map[address_command].split(',').map { |addr| get_alias(*addr.split(':')) }
63
64
  end
65
+
66
+ res = aliases.map { |al| Host.new(al[:address], al[:port], host.tls_name) }
67
+ rescue
68
+ # we don't care about the actual connection error; Just need to continue
64
69
  ensure
65
70
  conn.close if conn
66
71
  end
67
72
 
68
- aliases.map { |al| Host.new(al[:address], al[:port], host.tls_name) }
73
+ res
69
74
  end
70
75
 
71
76
  def get_alias(address, port)
@@ -14,30 +14,30 @@
14
14
  # License for the specific language governing permissions and limitations under
15
15
  # the License.
16
16
 
17
- require 'aerospike/value/value'
17
+ require "aerospike/value/value"
18
18
 
19
19
  module Aerospike
20
-
21
20
  class Operation
22
-
23
21
  attr_reader :op_type, :bin_name, :bin_value, :ctx
24
22
 
25
- READ = 1
23
+ READ = 1
26
24
  READ_HEADER = 1
27
- WRITE = 2
28
- CDT_READ = 3
29
- CDT_MODIFY = 4
30
- ADD = 5
31
- APPEND = 9
32
- PREPEND = 10
33
- TOUCH = 11
34
- BIT_READ = 12
35
- BIT_MODIFY = 13
36
- DELETE = 14
37
- HLL_READ = 15
38
- HLL_MODIFY = 16
39
-
40
- def initialize(op_type, bin_name=nil, bin_value=NullValue.new, ctx = nil)
25
+ WRITE = 2
26
+ CDT_READ = 3
27
+ CDT_MODIFY = 4
28
+ ADD = 5
29
+ EXP_READ = 7
30
+ EXP_MODIFY = 8
31
+ APPEND = 9
32
+ PREPEND = 10
33
+ TOUCH = 11
34
+ BIT_READ = 12
35
+ BIT_MODIFY = 13
36
+ DELETE = 14
37
+ HLL_READ = 15
38
+ HLL_MODIFY = 16
39
+
40
+ def initialize(op_type, bin_name = nil, bin_value = NullValue.new, ctx = nil)
41
41
  @op_type = op_type
42
42
  @bin_name = bin_name
43
43
  @bin_value = Value.of(bin_value)
@@ -49,11 +49,11 @@ module Aerospike
49
49
  Aerospike::Bin.new(bin_name, bin_value) if bin_name && bin_value
50
50
  end
51
51
 
52
- def self.get(bin_name=nil)
52
+ def self.get(bin_name = nil)
53
53
  Operation.new(READ, bin_name)
54
54
  end
55
55
 
56
- def self.get_header(bin_name=nil)
56
+ def self.get_header(bin_name = nil)
57
57
  Operation.new(READ_HEADER, bin_name)
58
58
  end
59
59
 
@@ -80,7 +80,5 @@ module Aerospike
80
80
  def self.delete
81
81
  Operation.new(DELETE)
82
82
  end
83
-
84
83
  end
85
-
86
84
  end # module
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http:#www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Aerospike
17
+
18
+ module AuthMode
19
+
20
+ # INTERNAL uses internal authentication only when user/password defined. Hashed password is stored
21
+ # on the server. Do not send clear password. This is the default.
22
+ INTERNAL = 0
23
+
24
+ # EXTERNAL uses external authentication (like LDAP) when user/password defined. Specific external authentication is
25
+ # configured on server. If TLS is defined, sends clear password on node login via TLS.
26
+ # Will raise exception if TLS is not defined.
27
+ EXTERNAL = 1
28
+
29
+ # PKI allows authentication and authorization based on a certificate. No user name or
30
+ # password needs to be configured. Requires TLS and a client certificate.
31
+ # Requires server version 5.7.0+
32
+ PKI = 2
33
+
34
+ end # module
35
+
36
+ end # module
@@ -22,7 +22,7 @@ module Aerospike
22
22
  # Container object for client policy command.
23
23
  class ClientPolicy
24
24
 
25
- attr_accessor :user, :password
25
+ attr_accessor :user, :password, :auth_mode
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
@@ -44,6 +44,9 @@ module Aerospike
44
44
  # which the client checks for cluster state changes. Minimum interval is 10ms.
45
45
  self.tend_interval = opt[:tend_interval] || 1000 # 1 second
46
46
 
47
+ # Authentication mode
48
+ @auth_mode = opt[:auth_mode] || AuthMode::INTERNAL
49
+
47
50
  # user name
48
51
  @user = opt[:user]
49
52
 
@@ -13,23 +13,44 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require 'aerospike/policy/priority'
17
- require 'aerospike/policy/consistency_level'
18
- require 'aerospike/policy/replica'
19
-
16
+ require "aerospike/policy/priority"
17
+ require "aerospike/policy/consistency_level"
18
+ require "aerospike/policy/replica"
20
19
 
21
20
  module Aerospike
22
21
 
23
22
  # Container object for client policy command.
24
23
  class Policy
25
-
26
- attr_accessor :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level,
24
+ attr_accessor :filter_exp, :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level,
27
25
  :predexp, :fail_on_filtered_out, :replica, :use_compression
28
26
 
29
- def initialize(opt={})
27
+ alias total_timeout timeout
28
+ alias total_timeout= timeout=
29
+
30
+ def initialize(opt = {})
30
31
  # Container object for transaction policy attributes used in all database
31
32
  # operation calls.
32
33
 
34
+ # Optional expression filter. If filterExp exists and evaluates to false, the
35
+ # transaction is ignored.
36
+ #
37
+ # Default: nil
38
+ #
39
+ # ==== Examples:
40
+ #
41
+ # p = Policy.new
42
+ # p.filter_exp = Exp.build(Exp.eq(Exp.int_bin("a"), Exp.int_val(11)));
43
+ @filter_exp = opt[:filter_exp]
44
+
45
+ # Throw exception if {#filter_exp} is defined and that filter evaluates
46
+ # to false (transaction ignored). The {AerospikeException}
47
+ # will contain result code {ResultCode::FILTERED_OUT}.
48
+ #
49
+ # This field is not applicable to batch, scan or query commands.
50
+ #
51
+ # Default: false
52
+ @fail_on_filtered_out = opt[:fail_on_filtered_out] || false
53
+
33
54
  # Priority of request relative to other transactions.
34
55
  # Currently, only used for scans.
35
56
  @priority = opt[:priority] || Priority::DEFAULT
@@ -71,7 +92,6 @@ module Aerospike
71
92
  # ]
72
93
  @predexp = opt[:predexp] || nil
73
94
 
74
-
75
95
  # Throw exception if @predexp is defined and that filter evaluates
76
96
  # to false (transaction ignored). The Aerospike::Exceptions::Aerospike
77
97
  # will contain result code Aerospike::ResultCode::FILTERED_OUT.
@@ -83,9 +103,8 @@ module Aerospike
83
103
  # read operation.
84
104
  @consistency_level = opt[:consistency_level] || Aerospike::ConsistencyLevel::CONSISTENCY_ONE
85
105
 
86
-
87
106
  # Send read commands to the node containing the key's partition replica type.
88
- # Write commands are not affected by this setting, because all writes are directed
107
+ # Write commands are not affected by this setting, because all writes are directed
89
108
  # to the node containing the key's master partition.
90
109
  #
91
110
  # Default to sending read commands to the node containing the key's master partition.
@@ -115,8 +134,5 @@ module Aerospike
115
134
  # timeout was not exceeded. Enter zero to skip sleep.
116
135
  @sleep_between_retries = opt[:sleep_between_retries] || 0.5
117
136
  end
118
-
119
-
120
137
  end # class
121
-
122
138
  end # module
@@ -22,20 +22,45 @@ module Aerospike
22
22
  # Container object for query policy command.
23
23
  class QueryPolicy < Policy
24
24
 
25
+ attr_accessor :concurrent_nodes
26
+ attr_accessor :max_records
25
27
  attr_accessor :include_bin_data
26
28
  attr_accessor :record_queue_size
27
29
  attr_accessor :records_per_second
30
+ attr_accessor :socket_timeout
31
+ attr_accessor :short_query
28
32
 
29
33
  def initialize(opt={})
30
34
  super(opt)
31
35
 
32
- @max_retries = 0
33
-
34
36
  # Indicates if bin data is retrieved. If false, only record digests (and
35
37
  # user keys if stored on the server) are retrieved.
36
38
  # Default is true.
37
39
  @include_bin_data = opt.fetch(:include_bin_data, true)
38
40
 
41
+ # Approximates the number of records to return to the client. This number is divided by the
42
+ # number of nodes involved in the query. The actual number of records returned
43
+ # may be less than MaxRecords if node record counts are small and unbalanced across
44
+ # nodes.
45
+ #
46
+ # This field is supported on server versions >= 4.9.
47
+ #
48
+ # Default: 0 (do not limit record count)
49
+ @max_records = opt.fetch(:max_records) { 0 }
50
+
51
+ # Issue scan requests in parallel or serially.
52
+ @concurrent_nodes = opt.fetch(:concurrent_nodes) { true }
53
+
54
+ # Determines network timeout for each attempt.
55
+ #
56
+ # If socket_timeout is not zero and socket_timeout is reached before an attempt completes,
57
+ # the Timeout above is checked. If Timeout is not exceeded, the transaction
58
+ # is retried. If both socket_timeout and Timeout are non-zero, socket_timeout must be less
59
+ # than or equal to Timeout, otherwise Timeout will also be used for socket_timeout.
60
+ #
61
+ # Default: 30s
62
+ @socket_timeout = opt[:socket_timeout] || 30000
63
+
39
64
  # Number of records to place in queue before blocking. Records received
40
65
  # from multiple server nodes will be placed in a queue. A separate thread
41
66
  # consumes these records in parallel. If the queue is full, the producer
@@ -49,6 +74,14 @@ module Aerospike
49
74
  # Default is 0
50
75
  @records_per_second = opt[:records_per_second] || 0
51
76
 
77
+ # Detemine wether query expected to return less than 100 records.
78
+ # If true, the server will optimize the query for a small record set.
79
+ # This field is ignored for aggregation queries, background queries
80
+ # and server versions 6.0+.
81
+ #
82
+ # Default: false
83
+ @short_query = opt[:short_query] ||false
84
+
52
85
  self
53
86
  end
54
87
 
@@ -22,6 +22,7 @@ module Aerospike
22
22
  # Container object for scan policy command.
23
23
  class ScanPolicy < Policy
24
24
 
25
+ attr_accessor :max_records
25
26
  attr_accessor :scan_percent
26
27
  attr_accessor :concurrent_nodes
27
28
  attr_accessor :include_bin_data
@@ -33,7 +34,15 @@ module Aerospike
33
34
  def initialize(opt={})
34
35
  super(opt)
35
36
 
36
- @max_retries = 0
37
+ # Approximates the number of records to return to the client. This number is divided by the
38
+ # number of nodes involved in the query. The actual number of records returned
39
+ # may be less than MaxRecords if node record counts are small and unbalanced across
40
+ # nodes.
41
+ #
42
+ # This field is supported on server versions >= 4.9.
43
+ #
44
+ # Default: 0 (do not limit record count)
45
+ @max_records = opt.fetch(:max_records) { 0 }
37
46
 
38
47
  # Percent of data to scan. Valid integer range is 1 to 100.
39
48
  # Default is 100.
@@ -51,7 +60,15 @@ module Aerospike
51
60
  # Default is true.
52
61
  @fail_on_cluster_change = opt.fetch(:fail_on_cluster_change) { true }
53
62
 
54
- @socket_timeout = opt[:socket_timeout] || 10000
63
+ # Determines network timeout for each attempt.
64
+ #
65
+ # If socket_timeout is not zero and socket_timeout is reached before an attempt completes,
66
+ # the Timeout above is checked. If Timeout is not exceeded, the transaction
67
+ # is retried. If both socket_timeout and Timeout are non-zero, socket_timeout must be less
68
+ # than or equal to Timeout, otherwise Timeout will also be used for socket_timeout.
69
+ #
70
+ # Default: 30s
71
+ @socket_timeout = opt[:socket_timeout] || 30000
55
72
 
56
73
  # Number of records to place in queue before blocking. Records received
57
74
  # from multiple server nodes will be placed in a queue. A separate thread
@@ -0,0 +1,133 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014-2022 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ module Aerospike
18
+
19
+ # Determines user access granularity.
20
+ class Privilege
21
+
22
+ # Role
23
+ attr_accessor :code
24
+
25
+ # Namespace determines namespace scope. Apply permission to this namespace only.
26
+ # If namespace is zero value, the privilege applies to all namespaces.
27
+ attr_accessor :namespace
28
+
29
+ # Set name scope. Apply permission to this set within namespace only.
30
+ # If set is zero value, the privilege applies to all sets within namespace.
31
+ attr_accessor :set_name
32
+
33
+ # Manage users and their roles.
34
+ USER_ADMIN = 'user-admin'
35
+
36
+ # Manage indicies, user-defined functions and server configuration.
37
+ SYS_ADMIN = 'sys-admin'
38
+
39
+ # Manage indicies and user defined functions.
40
+ DATA_ADMIN = 'data-admin'
41
+
42
+ # Manage user defined functions.
43
+ UDF_ADMIN = 'udf-admin'
44
+
45
+ # Manage indicies.
46
+ SINDEX_ADMIN = 'sindex-admin'
47
+
48
+ # Allow read, write and UDF transactions with the database.
49
+ READ_WRITE_UDF = "read-write-udf"
50
+
51
+ # Allow read and write transactions with the database.
52
+ READ_WRITE = 'read-write'
53
+
54
+ # Allow read transactions with the database.
55
+ READ = 'read'
56
+
57
+ # Write allows write transactions with the database.
58
+ WRITE = 'write'
59
+
60
+ # Truncate allow issuing truncate commands.
61
+ TRUNCATE = 'truncate'
62
+
63
+ def initialize(opt={})
64
+ @code = opt[:code]
65
+ @namespace = opt[:namespace]
66
+ @set_name = opt[:set_name]
67
+ end
68
+
69
+ def to_s
70
+ "code: #{@code}, namespace: #{@namespace}, set_name: #{@set_name}"
71
+ end
72
+
73
+ def to_code
74
+ case @code
75
+ when USER_ADMIN
76
+ 0
77
+ when SYS_ADMIN
78
+ 1
79
+ when DATA_ADMIN
80
+ 2
81
+ when UDF_ADMIN
82
+ 3
83
+ when SINDEX_ADMIN
84
+ 4
85
+ when READ
86
+ 10
87
+ when READ_WRITE
88
+ 11
89
+ when READ_WRITE_UDF
90
+ 12
91
+ when WRITE
92
+ 13
93
+ when TRUNCATE
94
+ 14
95
+ else
96
+ raise Exceptions::Aerospike.new(Aerospike::ResultCode::INVALID_PRIVILEGE, "Invalid role #{@code}")
97
+ end # case
98
+ end # def
99
+
100
+ def self.from(code)
101
+ case code
102
+ when 0
103
+ USER_ADMIN
104
+ when 1
105
+ SYS_ADMIN
106
+ when 2
107
+ DATA_ADMIN
108
+ when 3
109
+ UDF_ADMIN
110
+ when 4
111
+ SINDEX_ADMIN
112
+ when 10
113
+ READ
114
+ when 11
115
+ READ_WRITE
116
+ when 12
117
+ READ_WRITE_UDF
118
+ when 13
119
+ WRITE
120
+ when 14
121
+ TRUNCATE
122
+ else
123
+ raise Exceptions::Aerospike.new(Aerospike::ResultCode::INVALID_PRIVILEGE, "Invalid code #{code}")
124
+ end # case
125
+ end # def
126
+
127
+ def can_scope?
128
+ to_code >= 10
129
+ end
130
+
131
+ end # class
132
+
133
+ end
@@ -15,39 +15,51 @@
15
15
  # the License.
16
16
 
17
17
  module Aerospike
18
-
19
18
  class Filter
19
+ attr_reader :packed_ctx
20
20
 
21
- def self.Equal(bin_name, value)
22
- Filter.new(bin_name, value, value)
23
- end
21
+ # open up the class to alias the class methods for naming consistency
22
+ class << self
23
+ def equal(bin_name, value, ctx: nil)
24
+ Filter.new(bin_name, value, value, nil, nil, ctx)
25
+ end
24
26
 
25
- def self.Contains(bin_name, value, col_type)
26
- Filter.new(bin_name, value, value, nil, col_type)
27
- end
27
+ def contains(bin_name, value, col_type, ctx: nil)
28
+ Filter.new(bin_name, value, value, nil, col_type, ctx)
29
+ end
28
30
 
29
- def self.Range(bin_name, from, to, col_type = nil)
30
- Filter.new(bin_name, from, to, nil, col_type)
31
- end
31
+ def range(bin_name, from, to, col_type = nil, ctx: nil)
32
+ Filter.new(bin_name, from, to, nil, col_type, ctx)
33
+ end
32
34
 
33
- def self.geoWithinGeoJSONRegion(bin_name, region, col_type = nil)
34
- region = region.to_json
35
- Filter.new(bin_name, region, region, ParticleType::GEOJSON, col_type)
36
- end
35
+ def geo_within_geo_region(bin_name, region, col_type = nil, ctx: nil)
36
+ region = region.to_json
37
+ Filter.new(bin_name, region, region, ParticleType::GEOJSON, col_type, ctx)
38
+ end
37
39
 
38
- def self.geoWithinRadius(bin_name, lon, lat, radius_meter, col_type = nil)
39
- region = GeoJSON.new({type: "AeroCircle", coordinates: [[lon, lat], radius_meter]})
40
- geoWithinGeoJSONRegion(bin_name, region, col_type)
41
- end
40
+ def geo_within_radius(bin_name, lon, lat, radius_meter, col_type = nil, ctx: nil)
41
+ region = GeoJSON.new({ type: "AeroCircle", coordinates: [[lon, lat], radius_meter] })
42
+ geo_within_geo_region(bin_name, region, col_type, ctx: ctx)
43
+ end
42
44
 
43
- def self.geoContainsGeoJSONPoint(bin_name, point, col_type = nil)
44
- point = point.to_json
45
- Filter.new(bin_name, point, point, ParticleType::GEOJSON, col_type)
46
- end
45
+ def geo_contains_geo_point(bin_name, point, col_type = nil, ctx: nil)
46
+ point = point.to_json
47
+ Filter.new(bin_name, point, point, ParticleType::GEOJSON, col_type, ctx)
48
+ end
47
49
 
48
- def self.geoContainsPoint(bin_name, lon, lat, col_type = nil)
49
- point = GeoJSON.new({type: "Point", coordinates: [lon, lat]})
50
- geoContainsGeoJSONPoint(bin_name, point, col_type)
50
+ def geo_contains_point(bin_name, lon, lat, col_type = nil, ctx: nil)
51
+ point = GeoJSON.new({ type: "Point", coordinates: [lon, lat] })
52
+ geo_contains_geo_point(bin_name, point, col_type, ctx: ctx)
53
+ end
54
+
55
+ # alias the old names for compatibility
56
+ alias :Equal :equal
57
+ alias :Contains :contains
58
+ alias :Range :range
59
+ alias :geoWithinGeoJSONRegion :geo_within_geo_region
60
+ alias :geoWithinRadius :geo_within_radius
61
+ alias :geoContainsGeoJSONPoint :geo_contains_geo_point
62
+ alias :geoContainsPoint :geo_contains_point
51
63
  end
52
64
 
53
65
  def estimate_size
@@ -56,21 +68,21 @@ module Aerospike
56
68
 
57
69
  def write(buf, offset)
58
70
  # Write name.
59
- len = buf.write_binary(@name, offset+1)
71
+ len = buf.write_binary(@name, offset + 1)
60
72
  buf.write_byte(len, offset)
61
73
  offset += len + 1
62
74
 
63
75
  # Write particle type.
64
76
  buf.write_byte(@val_type, offset)
65
- offset+=1
77
+ offset += 1
66
78
 
67
79
  # Write filter begin.
68
- len = @begin.write(buf, offset+4)
80
+ len = @begin.write(buf, offset + 4)
69
81
  buf.write_int32(len, offset)
70
82
  offset += len + 4
71
83
 
72
84
  # Write filter end.
73
- len = @end.write(buf, offset+4)
85
+ len = @end.write(buf, offset + 4)
74
86
  buf.write_int32(len, offset)
75
87
  offset += len + 4
76
88
 
@@ -98,7 +110,7 @@ module Aerospike
98
110
 
99
111
  private
100
112
 
101
- def initialize(bin_name, begin_value, end_value, val_type = nil, col_type = nil)
113
+ def initialize(bin_name, begin_value, end_value, val_type = nil, col_type = nil, ctx = nil)
102
114
  @name = bin_name
103
115
  @begin = Aerospike::Value.of(begin_value)
104
116
  @end = Aerospike::Value.of(end_value)
@@ -107,8 +119,8 @@ module Aerospike
107
119
  # but in certain cases caller can override the type.
108
120
  @val_type = val_type || @begin.type
109
121
  @col_type = col_type
110
- end
111
122
 
123
+ @packed_ctx = CDT::Context.bytes(ctx)
124
+ end
112
125
  end # class
113
-
114
126
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2014-2020 Aerospike, Inc.
4
+ #
5
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
+ # license agreements.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
+ # use this file except in compliance with the License. You may obtain a copy of
10
+ # the License at 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
+ class NodePartitions
20
+ attr_accessor :node, :parts_full, :parts_partial, :record_count, :record_max, :parts_unavailable
21
+
22
+ def initialize(node)
23
+ @node= node
24
+ @parts_full= []
25
+ @parts_partial= []
26
+ @record_count= 0
27
+ @parts_unavailable= 0
28
+ @record_max= 0
29
+ end
30
+
31
+ def to_s
32
+ "Node #{@node.inspect}: full: #{@parts_full.length}, partial: #{@parts_partial.length}"
33
+ end
34
+
35
+ def add_partition(partition_status)
36
+ partition_status.digest.nil? ? @parts_full << partition_status : @parts_partial << partition_status
37
+ end
38
+ end
39
+ end