aerospike 2.11.0 → 2.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -1
  3. data/README.md +1 -1
  4. data/lib/aerospike.rb +17 -4
  5. data/lib/aerospike/aerospike_exception.rb +7 -1
  6. data/lib/aerospike/atomic/atomic.rb +1 -1
  7. data/lib/aerospike/bin.rb +1 -1
  8. data/lib/aerospike/cdt/bit_operation.rb +376 -0
  9. data/lib/aerospike/cdt/bit_overflow_action.rb +46 -0
  10. data/lib/aerospike/cdt/bit_policy.rb +36 -0
  11. data/lib/aerospike/cdt/bit_resize_flags.rb +44 -0
  12. data/lib/aerospike/cdt/bit_write_flags.rb +51 -0
  13. data/lib/aerospike/cdt/context.rb +101 -0
  14. data/lib/aerospike/cdt/hll_operation.rb +200 -0
  15. data/lib/aerospike/cdt/hll_policy.rb +34 -0
  16. data/lib/aerospike/cdt/hll_write_flags.rb +53 -0
  17. data/lib/aerospike/cdt/list_operation.rb +127 -97
  18. data/lib/aerospike/cdt/list_sort_flags.rb +10 -2
  19. data/lib/aerospike/cdt/map_operation.rb +154 -93
  20. data/lib/aerospike/cdt/map_order.rb +1 -1
  21. data/lib/aerospike/cdt/map_policy.rb +1 -1
  22. data/lib/aerospike/cdt/map_return_type.rb +1 -1
  23. data/lib/aerospike/cdt/map_write_mode.rb +1 -1
  24. data/lib/aerospike/client.rb +33 -17
  25. data/lib/aerospike/cluster.rb +139 -17
  26. data/lib/aerospike/cluster/partition.rb +1 -1
  27. data/lib/aerospike/cluster/partition_parser.rb +169 -0
  28. data/lib/aerospike/cluster/rack_parser.rb +117 -0
  29. data/lib/aerospike/command/admin_command.rb +1 -1
  30. data/lib/aerospike/command/batch_direct_command.rb +2 -1
  31. data/lib/aerospike/command/batch_direct_exists_command.rb +1 -1
  32. data/lib/aerospike/command/batch_direct_node.rb +3 -3
  33. data/lib/aerospike/command/batch_index_command.rb +11 -2
  34. data/lib/aerospike/command/batch_index_node.rb +2 -2
  35. data/lib/aerospike/command/batch_item.rb +1 -1
  36. data/lib/aerospike/command/command.rb +168 -12
  37. data/lib/aerospike/command/delete_command.rb +21 -5
  38. data/lib/aerospike/command/execute_command.rb +1 -1
  39. data/lib/aerospike/command/exists_command.rb +21 -5
  40. data/lib/aerospike/command/field_type.rb +2 -1
  41. data/lib/aerospike/command/multi_command.rb +55 -5
  42. data/lib/aerospike/command/operate_command.rb +6 -1
  43. data/lib/aerospike/command/read_command.rb +63 -20
  44. data/lib/aerospike/command/read_header_command.rb +18 -6
  45. data/lib/aerospike/command/roles.rb +1 -1
  46. data/lib/aerospike/command/single_command.rb +9 -3
  47. data/lib/aerospike/command/touch_command.rb +48 -4
  48. data/lib/aerospike/command/unsupported_particle_type_validator.rb +1 -1
  49. data/lib/aerospike/command/write_command.rb +13 -4
  50. data/lib/aerospike/connection/create.rb +1 -1
  51. data/lib/aerospike/features.rb +6 -1
  52. data/lib/aerospike/geo_json.rb +1 -1
  53. data/lib/aerospike/host.rb +1 -1
  54. data/lib/aerospike/info.rb +1 -1
  55. data/lib/aerospike/key.rb +1 -1
  56. data/lib/aerospike/language.rb +1 -1
  57. data/lib/aerospike/node.rb +21 -7
  58. data/lib/aerospike/node/rebalance.rb +50 -0
  59. data/lib/aerospike/node/refresh/info.rb +4 -1
  60. data/lib/aerospike/node/refresh/partitions.rb +6 -15
  61. data/lib/aerospike/node/refresh/racks.rb +47 -0
  62. data/lib/aerospike/node/refresh/reset.rb +1 -0
  63. data/lib/aerospike/node/verify/rebalance_generation.rb +43 -0
  64. data/lib/aerospike/node_validator.rb +4 -19
  65. data/lib/aerospike/operation.rb +13 -3
  66. data/lib/aerospike/policy/admin_policy.rb +1 -1
  67. data/lib/aerospike/policy/batch_policy.rb +1 -1
  68. data/lib/aerospike/policy/client_policy.rb +16 -1
  69. data/lib/aerospike/policy/commit_level.rb +1 -1
  70. data/lib/aerospike/policy/consistency_level.rb +1 -1
  71. data/lib/aerospike/policy/generation_policy.rb +1 -1
  72. data/lib/aerospike/policy/operate_policy.rb +1 -1
  73. data/lib/aerospike/policy/policy.rb +64 -2
  74. data/lib/aerospike/policy/priority.rb +1 -1
  75. data/lib/aerospike/policy/query_policy.rb +8 -1
  76. data/lib/aerospike/policy/record_bin_multiplicity.rb +1 -1
  77. data/lib/aerospike/policy/record_exists_action.rb +1 -1
  78. data/lib/aerospike/policy/replica.rb +45 -0
  79. data/lib/aerospike/policy/scan_policy.rb +8 -1
  80. data/lib/aerospike/policy/write_policy.rb +1 -1
  81. data/lib/aerospike/query/filter.rb +1 -1
  82. data/lib/aerospike/query/query_command.rb +16 -5
  83. data/lib/aerospike/query/recordset.rb +1 -1
  84. data/lib/aerospike/query/scan_command.rb +1 -1
  85. data/lib/aerospike/query/statement.rb +9 -2
  86. data/lib/aerospike/query/stream_command.rb +1 -1
  87. data/lib/aerospike/record.rb +1 -1
  88. data/lib/aerospike/result_code.rb +26 -7
  89. data/lib/aerospike/socket/base.rb +4 -3
  90. data/lib/aerospike/task/execute_task.rb +1 -1
  91. data/lib/aerospike/task/index_task.rb +1 -1
  92. data/lib/aerospike/task/task.rb +1 -1
  93. data/lib/aerospike/task/udf_register_task.rb +1 -1
  94. data/lib/aerospike/task/udf_remove_task.rb +1 -1
  95. data/lib/aerospike/ttl.rb +1 -1
  96. data/lib/aerospike/udf.rb +1 -1
  97. data/lib/aerospike/user_role.rb +1 -1
  98. data/lib/aerospike/utils/buffer.rb +14 -4
  99. data/lib/aerospike/utils/packer.rb +1 -1
  100. data/lib/aerospike/utils/pool.rb +1 -1
  101. data/lib/aerospike/utils/unpacker.rb +1 -1
  102. data/lib/aerospike/value/particle_type.rb +2 -2
  103. data/lib/aerospike/value/value.rb +165 -33
  104. data/lib/aerospike/version.rb +1 -1
  105. metadata +20 -8
  106. data/lib/aerospike/cluster/partition_tokenizer_new.rb +0 -130
  107. data/lib/aerospike/cluster/partition_tokenizer_old.rb +0 -135
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2014-2018 Aerospike, Inc.
3
+ # Copyright 2014-2020 Aerospike, Inc.
4
4
  #
5
5
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
6
  # license agreements.
@@ -19,13 +19,11 @@
19
19
 
20
20
  module Aerospike
21
21
  class NodeValidator # :nodoc:
22
- VERSION_REGEXP = /(?<v1>\d+)\.(?<v2>\d+)\.(?<v3>\d+).*/.freeze
23
22
 
24
- attr_reader :host, :aliases, :name, :use_new_info, :features, :cluster_name, :tls_options, :conn
23
+ attr_reader :host, :aliases, :name, :features, :cluster_name, :tls_options, :conn
25
24
 
26
25
  def initialize(cluster, host, timeout, cluster_name, tls_options = {})
27
26
  @cluster = cluster
28
- @use_new_info = true
29
27
  @features = Set.new
30
28
  @host = host
31
29
  @cluster_name = cluster_name
@@ -46,7 +44,7 @@ module Aerospike
46
44
  begin
47
45
  conn = Cluster::CreateConnection.(@cluster, Host.new(address, host.port, host.tls_name))
48
46
 
49
- commands = %w[node build features]
47
+ commands = %w[node features]
50
48
  commands << address_command unless is_loopback?(address)
51
49
 
52
50
  info_map = Info.request(conn, *commands)
@@ -58,16 +56,10 @@ module Aerospike
58
56
  if features = info_map['features']
59
57
  @features = features.split(';').to_set
60
58
  end
61
-
62
- # Check new info protocol support for >= 2.6.6 build
63
- if build_version = info_map['build']
64
- v1, v2, v3 = parse_version_string(build_version)
65
- @use_new_info = v1.to_i > 2 || (v1.to_i == 2 && (v2.to_i > 6 || (v2.to_i == 6 && v3.to_i >= 6)))
66
- end
67
59
  end
68
60
 
69
61
  unless is_loopback?(address)
70
- aliases = info_map[address_command].split(',').map { |address| get_alias(*address.split(':')) }
62
+ aliases = info_map[address_command].split(',').map { |addr| get_alias(*addr.split(':')) }
71
63
  end
72
64
  ensure
73
65
  conn.close if conn
@@ -103,12 +95,5 @@ module Aerospike
103
95
  !!((hostname =~ Resolv::IPv4::Regex) || (hostname =~ Resolv::IPv6::Regex))
104
96
  end
105
97
 
106
- def parse_version_string(version)
107
- if v = VERSION_REGEXP.match(version)
108
- return v['v1'], v['v2'], v['v3']
109
- end
110
-
111
- raise Aerospike::Exceptions::Parse.new("Invalid build version string in Info: #{version}")
112
- end
113
98
  end # class
114
99
  end # module
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -20,7 +20,7 @@ module Aerospike
20
20
 
21
21
  class Operation
22
22
 
23
- attr_reader :op_type, :bin_name, :bin_value
23
+ attr_reader :op_type, :bin_name, :bin_value, :ctx
24
24
 
25
25
  READ = 1
26
26
  READ_HEADER = 1
@@ -31,11 +31,17 @@ module Aerospike
31
31
  APPEND = 9
32
32
  PREPEND = 10
33
33
  TOUCH = 11
34
+ BIT_READ = 12
35
+ BIT_MODIFY = 13
36
+ DELETE = 14
37
+ HLL_READ = 15
38
+ HLL_MODIFY = 16
34
39
 
35
- def initialize(op_type, bin_name=nil, bin_value=NullValue.new)
40
+ def initialize(op_type, bin_name=nil, bin_value=NullValue.new, ctx = nil)
36
41
  @op_type = op_type
37
42
  @bin_name = bin_name
38
43
  @bin_value = Value.of(bin_value)
44
+ @ctx = ctx
39
45
  self
40
46
  end
41
47
 
@@ -71,6 +77,10 @@ module Aerospike
71
77
  Operation.new(TOUCH)
72
78
  end
73
79
 
80
+ def self.delete
81
+ Operation.new(DELETE)
82
+ end
83
+
74
84
  end
75
85
 
76
86
  end # module
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -1,4 +1,4 @@
1
- # Copyright 2014-2018 Aerospike, Inc.
1
+ # Copyright 2014-2020 Aerospike, Inc.
2
2
  #
3
3
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
4
4
  # license agreements.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright 2014-2018 Aerospike, Inc.
3
+ # Copyright 2014-2020 Aerospike, Inc.
4
4
  #
5
5
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
6
6
  # license agreements.
@@ -27,6 +27,7 @@ module Aerospike
27
27
  attr_accessor :cluster_name
28
28
  attr_accessor :tls
29
29
  attr_accessor :policies
30
+ attr_accessor :rack_aware, :rack_id
30
31
 
31
32
  def initialize(opt={})
32
33
  # Initial host connection timeout in seconds. The timeout when opening a connection
@@ -56,6 +57,20 @@ module Aerospike
56
57
 
57
58
  # Default Policies
58
59
  @policies = opt.fetch(:policies) { Hash.new }
60
+
61
+ # Track server rack data. This field is useful when directing read commands to the server node
62
+ # that contains the key and exists on the same rack as the client. This serves to lower cloud
63
+ # provider costs when nodes are distributed across different racks/data centers.
64
+ #
65
+ # ClientPolicy#rack_id, Replica#PREFER_RACK and server rack
66
+ # configuration must also be set to enable this functionality.
67
+ @rack_aware = opt[:rack_aware] || false
68
+
69
+ # Rack where this client instance resides.
70
+ #
71
+ # ClientPolicy#rack_aware, Replica#PREFER_RACK and server rack
72
+ # configuration must also be set to enable this functionality.
73
+ @rack_id = opt[:rack_id] || 0
59
74
  end
60
75
 
61
76
  def requires_authentication
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2016-2017 Aerospike, Inc.
2
+ # Copyright 2016-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
15
15
 
16
16
  require 'aerospike/policy/priority'
17
17
  require 'aerospike/policy/consistency_level'
18
+ require 'aerospike/policy/replica'
18
19
 
19
20
 
20
21
  module Aerospike
@@ -22,7 +23,8 @@ module Aerospike
22
23
  # Container object for client policy command.
23
24
  class Policy
24
25
 
25
- attr_accessor :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level
26
+ attr_accessor :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level,
27
+ :predexp, :fail_on_filtered_out, :replica, :use_compression
26
28
 
27
29
  def initialize(opt={})
28
30
  # Container object for transaction policy attributes used in all database
@@ -32,11 +34,71 @@ module Aerospike
32
34
  # Currently, only used for scans.
33
35
  @priority = opt[:priority] || Priority::DEFAULT
34
36
 
37
+ # Set optional predicate expression filters in postfix notation.
38
+ # Predicate expression filters are applied on the query results on the server.
39
+ # Predicate expression filters may occur on any bin in the record.
40
+ # Requires Aerospike Server versions >= 3.12
41
+ #
42
+ # Postfix notation is described here: http://wiki.c2.com/?PostfixNotation
43
+ #
44
+ # Example:
45
+ #
46
+ # (c >= 11 and c <= 20) or (d > 3 and (d < 5)
47
+ # policy.predexp = [
48
+ # PredExp.integer_bin("c"),
49
+ # PredExp.integer_value(11),
50
+ # PredExp.integer_greater_eq(),
51
+ # PredExp.integer_bin("c"),
52
+ # PredExp.integer_value(20),
53
+ # PredExp.integer_less_eq(),
54
+ # PredExp.and(2),
55
+ # PredExp.integer_bin("d"),
56
+ # PredExp.integer_value(3),
57
+ # PredExp.integer_greater(),
58
+ # PredExp.integer_bin("d"),
59
+ # PredExp.integer_value(5),
60
+ # PredExp.integer_less(),
61
+ # PredExp.and(2),
62
+ # PredExp.or(2)
63
+ # ]
64
+ #
65
+ # # Record last update time > 2017-01-15
66
+ # policy.predexp = [
67
+ # PredExp.rec_last_update(),
68
+ # PredExp.integer_value(Time.new(2017, 1, 15).to_i),
69
+ # PredExp.integer_greater(),
70
+ # PredExp.integer_greater()
71
+ # ]
72
+ @predexp = opt[:predexp] || nil
73
+
74
+
75
+ # Throw exception if @predexp is defined and that filter evaluates
76
+ # to false (transaction ignored). The Aerospike::Exceptions::Aerospike
77
+ # will contain result code Aerospike::ResultCode::FILTERED_OUT.
78
+ # This field is not applicable to batch, scan or query commands.
79
+ @fail_on_filtered_out = opt[:fail_on_filtered_out] || false
80
+
35
81
  # How replicas should be consulted in a read operation to provide the desired
36
82
  # consistency guarantee. Default to allowing one replica to be used in the
37
83
  # read operation.
38
84
  @consistency_level = opt[:consistency_level] || Aerospike::ConsistencyLevel::CONSISTENCY_ONE
39
85
 
86
+
87
+ # 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
89
+ # to the node containing the key's master partition.
90
+ #
91
+ # Default to sending read commands to the node containing the key's master partition.
92
+ @replica = opt[:replica] || Aerospike::Replica::MASTER
93
+
94
+ # Use zlib compression on write or batch read commands when the command buffer size is greater
95
+ # than 128 bytes. In addition, tell the server to compress its response on read commands.
96
+ # The server response compression threshold is also 128 bytes.
97
+ #
98
+ # This option will increase cpu and memory usage (for extra compressed buffers), but
99
+ # decrease the size of data sent over the network.
100
+ @use_compression = opt[:use_compression] || false
101
+
40
102
  # Transaction timeout.
41
103
  # This timeout is used to set the socket timeout and is also sent to the
42
104
  # server along with the transaction in the wire protocol.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2014-2018 Aerospike, Inc.
1
+ # Copyright 2014-2020 Aerospike, Inc.
2
2
  #
3
3
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
4
4
  # license agreements.
@@ -24,6 +24,7 @@ module Aerospike
24
24
 
25
25
  attr_accessor :include_bin_data
26
26
  attr_accessor :record_queue_size
27
+ attr_accessor :records_per_second
27
28
 
28
29
  def initialize(opt={})
29
30
  super(opt)
@@ -42,6 +43,12 @@ module Aerospike
42
43
  # Default is 5000.
43
44
  @record_queue_size = opt[:record_queue_size] || 5000
44
45
 
46
+ # Limit returned records per second (rps) rate for each server.
47
+ # Will not apply rps limit if records_per_second is zero.
48
+ # Currently only applicable to a query without a defined filter (scan).
49
+ # Default is 0
50
+ @records_per_second = opt[:records_per_second] || 0
51
+
45
52
  self
46
53
  end
47
54
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2016-2017 Aerospike, Inc.
2
+ # Copyright 2016-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,45 @@
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 Replica
19
+
20
+ # Read from node containing key's master partition. This is the default behavior.
21
+ MASTER = 0
22
+
23
+ # Distribute reads across nodes containing key's master and replicated partitions
24
+ # in round-robin fashion.
25
+ MASTER_PROLES = 1
26
+
27
+ # Always try node containing master partition first. If connection fails and
28
+ # Policy#retryOnTimeout is true, try nodes containing prole partition.
29
+ SEQUENCE = 2
30
+
31
+ # Try node on the same rack as the client first. If there are no nodes on the
32
+ # same rack, use SEQUENCE instead.
33
+ #
34
+ # ClientPolicy#rack_aware, ClientPolicy#rack_id, and server rack
35
+ # configuration must also be set to enable this functionality.
36
+ PREFER_RACK = 3
37
+
38
+ # Distribute reads across all nodes in cluster in round-robin fashion.
39
+ # This option is useful when the replication factor equals the number
40
+ # of nodes in the cluster and the overhead of requesting proles is not desired.
41
+ RANDOM = 4
42
+
43
+ end # module
44
+
45
+ end # module
@@ -1,4 +1,4 @@
1
- # Copyright 2014-2018 Aerospike, Inc.
1
+ # Copyright 2014-2020 Aerospike, Inc.
2
2
  #
3
3
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
4
4
  # license agreements.
@@ -28,6 +28,7 @@ module Aerospike
28
28
  attr_accessor :fail_on_cluster_change
29
29
  attr_accessor :socket_timeout
30
30
  attr_accessor :record_queue_size
31
+ attr_accessor :records_per_second
31
32
 
32
33
  def initialize(opt={})
33
34
  super(opt)
@@ -59,6 +60,12 @@ module Aerospike
59
60
  # Default is 5000.
60
61
  @record_queue_size = opt[:record_queue_size] || 5000
61
62
 
63
+ # Limit returned records per second (rps) rate for each server.
64
+ # Will not apply rps limit if records_per_second is zero.
65
+ # Currently only applicable to a query without a defined filter (scan).
66
+ # Default is 0
67
+ @records_per_second = opt[:records_per_second] || 0
68
+
62
69
  self
63
70
  end
64
71
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Copyright 2014-2017 Aerospike, Inc.
2
+ # Copyright 2014-2020 Aerospike, Inc.
3
3
  #
4
4
  # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
5
  # license agreements.
@@ -82,6 +82,11 @@ module Aerospike
82
82
  fieldCount+=1
83
83
  end
84
84
  else
85
+ if @policy.records_per_second > 0
86
+ @data_offset += 4 + FIELD_HEADER_SIZE
87
+ fieldCount += 1
88
+ end
89
+
85
90
  # Calling query with no filters is more efficiently handled by a primary index scan.
86
91
  # Estimate scan options size.
87
92
  @data_offset += (2 + FIELD_HEADER_SIZE)
@@ -93,9 +98,11 @@ module Aerospike
93
98
  @data_offset += 8 + FIELD_HEADER_SIZE
94
99
  fieldCount+=1
95
100
 
96
- if @statement.predexp
101
+ predexp = @policy.predexp || @statement.predexp
102
+
103
+ if predexp
97
104
  @data_offset += FIELD_HEADER_SIZE
98
- predSize = Aerospike::PredExp.estimate_size(@statement.predexp)
105
+ predSize = Aerospike::PredExp.estimate_size(predexp)
99
106
  @data_offset += predSize
100
107
  fieldCount += 1
101
108
  end
@@ -170,6 +177,10 @@ module Aerospike
170
177
  end
171
178
  end
172
179
  else
180
+ if @policy.records_per_second > 0
181
+ write_field_int(@policy.records_per_second, Aerospike::FieldType::RECORDS_PER_SECOND)
182
+ end
183
+
173
184
  # Calling query with no filters is more efficiently handled by a primary index scan.
174
185
  write_field_header(2, Aerospike::FieldType::SCAN_OPTIONS)
175
186
  priority = @policy.priority.ord
@@ -184,10 +195,10 @@ module Aerospike
184
195
  @data_buffer.write_int64(@statement.task_id, @data_offset)
185
196
  @data_offset += 8
186
197
 
187
- if @statement.predexp
198
+ if predexp
188
199
  write_field_header(predSize, Aerospike::FieldType::PREDEXP)
189
200
  @data_offset = Aerospike::PredExp.write(
190
- @statement.predexp, @data_buffer, @data_offset
201
+ predexp, @data_buffer, @data_offset
191
202
  )
192
203
  end
193
204