aerospike 3.0.0 → 4.1.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 +35 -0
- data/README.md +13 -9
- data/lib/aerospike/batch_attr.rb +292 -0
- data/lib/aerospike/batch_delete.rb +48 -0
- data/lib/aerospike/batch_read.rb +97 -0
- data/lib/aerospike/batch_record.rb +83 -0
- data/lib/aerospike/batch_results.rb +38 -0
- data/lib/aerospike/batch_udf.rb +76 -0
- data/lib/aerospike/batch_write.rb +79 -0
- data/lib/aerospike/cdt/bit_operation.rb +4 -5
- data/lib/aerospike/cdt/map_return_type.rb +8 -0
- data/lib/aerospike/client.rb +37 -51
- data/lib/aerospike/cluster.rb +50 -46
- data/lib/aerospike/command/batch_index_command.rb +7 -11
- data/lib/aerospike/command/batch_index_node.rb +3 -4
- data/lib/aerospike/command/batch_operate_command.rb +151 -0
- data/lib/aerospike/command/batch_operate_node.rb +51 -0
- data/lib/aerospike/command/command.rb +125 -98
- data/lib/aerospike/command/single_command.rb +1 -1
- data/lib/aerospike/exp/exp.rb +39 -41
- data/lib/aerospike/exp/exp_bit.rb +24 -24
- data/lib/aerospike/exp/exp_hll.rb +12 -12
- data/lib/aerospike/exp/exp_list.rb +101 -92
- data/lib/aerospike/exp/exp_map.rb +116 -119
- data/lib/aerospike/exp/operation.rb +2 -2
- data/lib/aerospike/info.rb +2 -4
- data/lib/aerospike/node.rb +7 -3
- data/lib/aerospike/operation.rb +38 -0
- data/lib/aerospike/policy/batch_delete_policy.rb +71 -0
- data/lib/aerospike/policy/batch_policy.rb +53 -4
- data/lib/aerospike/policy/batch_read_policy.rb +55 -0
- data/lib/aerospike/policy/batch_udf_policy.rb +75 -0
- data/lib/aerospike/policy/batch_write_policy.rb +105 -0
- data/lib/aerospike/policy/policy.rb +20 -40
- data/lib/aerospike/policy/query_duration.rb +48 -0
- data/lib/aerospike/policy/query_policy.rb +13 -8
- data/lib/aerospike/query/server_command.rb +1 -0
- data/lib/aerospike/query/statement.rb +5 -21
- data/lib/aerospike/result_code.rb +7 -1
- data/lib/aerospike/utils/buffer.rb +15 -15
- data/lib/aerospike/version.rb +1 -1
- data/lib/aerospike.rb +14 -12
- metadata +17 -14
- data/lib/aerospike/command/batch_direct_command.rb +0 -105
- data/lib/aerospike/command/batch_direct_exists_command.rb +0 -51
- data/lib/aerospike/command/batch_direct_node.rb +0 -40
- data/lib/aerospike/query/pred_exp/and_or.rb +0 -32
- data/lib/aerospike/query/pred_exp/geo_json_value.rb +0 -41
- data/lib/aerospike/query/pred_exp/integer_value.rb +0 -32
- data/lib/aerospike/query/pred_exp/op.rb +0 -27
- data/lib/aerospike/query/pred_exp/regex.rb +0 -32
- data/lib/aerospike/query/pred_exp/regex_flags.rb +0 -23
- data/lib/aerospike/query/pred_exp/string_value.rb +0 -29
- data/lib/aerospike/query/pred_exp.rb +0 -192
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright 2014-2024 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
|
+
# Policy attributes used in batch delete commands.
|
20
|
+
class BatchDeletePolicy
|
21
|
+
attr_accessor :filter_exp, :commit_level, :generation_policy, :generation, :durable_delete, :send_key
|
22
|
+
|
23
|
+
def initialize(opt = {})
|
24
|
+
# Optional expression filter. If filter_exp exists and evaluates to false, the specific batch key
|
25
|
+
# request is not performed and {BatchRecord#result_code} is set to
|
26
|
+
# {ResultCode#FILTERED_OUT}.
|
27
|
+
#
|
28
|
+
# If exists, this filter overrides the batch parent filter {Policy#filter_exp}
|
29
|
+
# for the specific key in batch commands that allow a different policy per key.
|
30
|
+
# Otherwise, this filter is ignored.
|
31
|
+
#
|
32
|
+
# Default: nil
|
33
|
+
@filter_exp = opt[:filter_exp]
|
34
|
+
|
35
|
+
# Desired consistency guarantee when committing a transaction on the server. The default
|
36
|
+
# (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
|
37
|
+
# be successful before returning success to the client.
|
38
|
+
#
|
39
|
+
# Default: CommitLevel.COMMIT_ALL
|
40
|
+
@commit_level = opt[:commit_level] || CommitLevel::COMMIT_ALL
|
41
|
+
|
42
|
+
# Qualify how to handle record deletes based on record generation. The default (NONE)
|
43
|
+
# indicates that the generation is not used to restrict deletes.
|
44
|
+
#
|
45
|
+
# Default: GenerationPolicy.NONE
|
46
|
+
@generation_policy = opt[:generation_policy] || GenerationPolicy::NONE
|
47
|
+
|
48
|
+
# Expected generation. Generation is the number of times a record has been modified
|
49
|
+
# (including creation) on the server. This field is only relevant when generationPolicy
|
50
|
+
# is not NONE.
|
51
|
+
#
|
52
|
+
# Default: 0
|
53
|
+
@generation = opt[:generation] || 0
|
54
|
+
|
55
|
+
# If the transaction results in a record deletion, leave a tombstone for the record.
|
56
|
+
# This prevents deleted records from reappearing after node failures.
|
57
|
+
# Valid for Aerospike Server Enterprise Edition only.
|
58
|
+
#
|
59
|
+
# Default: false (do not tombstone deleted records).
|
60
|
+
@durable_delete = opt[:durable_delete] || false
|
61
|
+
|
62
|
+
# Send user defined key in addition to hash digest.
|
63
|
+
# If true, the key will be stored with the tombstone record on the server.
|
64
|
+
#
|
65
|
+
# Default: false (do not send the user defined key)
|
66
|
+
@send_key = opt[:send_key] || false
|
67
|
+
|
68
|
+
self
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -21,12 +21,14 @@ module Aerospike
|
|
21
21
|
|
22
22
|
# Container object for batch policy command.
|
23
23
|
class BatchPolicy < Policy
|
24
|
-
|
25
|
-
attr_accessor :use_batch_direct
|
24
|
+
attr_accessor :allow_inline_ssd, :respond_all_keys, :send_key
|
26
25
|
|
27
26
|
def initialize(opt={})
|
28
|
-
super
|
27
|
+
super
|
29
28
|
|
29
|
+
# [:nodoc:]
|
30
|
+
# DEPRECATED
|
31
|
+
# This setting does not have any effect anymore.
|
30
32
|
# Use old batch direct protocol where batch reads are handled by direct
|
31
33
|
# low-level batch server database routines. The batch direct protocol can
|
32
34
|
# be faster when there is a single namespace. But there is one important
|
@@ -38,11 +40,58 @@ module Aerospike
|
|
38
40
|
# index protocol will perform this record proxy when necessary.
|
39
41
|
#
|
40
42
|
# Default: false (use new batch index protocol if server supports it)
|
41
|
-
@use_batch_direct = opt.fetch(:use_batch_direct
|
43
|
+
@use_batch_direct = opt.fetch(:use_batch_direct, false)
|
44
|
+
|
45
|
+
|
46
|
+
# Allow batch to be processed immediately in the server's receiving thread for SSD
|
47
|
+
# namespaces. If false, the batch will always be processed in separate service threads.
|
48
|
+
# Server versions < 6.0 ignore this field.
|
49
|
+
#
|
50
|
+
# Inline processing can introduce the possibility of unfairness because the server
|
51
|
+
# can process the entire batch before moving onto the next command.
|
52
|
+
#
|
53
|
+
# Default: false
|
54
|
+
@allow_inline_ssd = opt.fetch(:allow_inline_ssd, false)
|
55
|
+
|
56
|
+
|
57
|
+
# Should all batch keys be attempted regardless of errors. This field is used on both
|
58
|
+
# the client and server. The client handles node specific errors and the server handles
|
59
|
+
# key specific errors.
|
60
|
+
#
|
61
|
+
# If true, every batch key is attempted regardless of previous key specific errors.
|
62
|
+
# Node specific errors such as timeouts stop keys to that node, but keys directed at
|
63
|
+
# other nodes will continue to be processed.
|
64
|
+
#
|
65
|
+
# If false, the server will stop the batch to its node on most key specific errors.
|
66
|
+
# The exceptions are {ResultCode#KEY_NOT_FOUND_ERROR} and
|
67
|
+
# {ResultCode#FILTERED_OUT} which never stop the batch.
|
68
|
+
# The client will stop the entire batch on node specific errors. The client will
|
69
|
+
# not stop the entire batch commands run in parallel.
|
70
|
+
#
|
71
|
+
# Server versions < 6.0 do not support this field and treat this value as false
|
72
|
+
# for key specific errors.
|
73
|
+
#
|
74
|
+
# Default: true
|
75
|
+
@respond_all_keys = opt.fetch(:respond_all_keys, true)
|
76
|
+
|
77
|
+
|
78
|
+
# Send user defined key in addition to hash digest on a record put.
|
79
|
+
# The default is to _not_ send the user defined key.
|
80
|
+
@send_key = opt.fetch(:send_key, false)
|
42
81
|
|
43
82
|
self
|
44
83
|
end
|
45
84
|
|
85
|
+
def self.read_default
|
86
|
+
BatchPolicy.new
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.write_default
|
90
|
+
bp = BatchPolicy.new
|
91
|
+
bp.max_retries = 0
|
92
|
+
bp
|
93
|
+
end
|
94
|
+
|
46
95
|
end # class
|
47
96
|
|
48
97
|
end # module
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright 2014-2020 Aerospike, Inc.
|
2
|
+
#
|
3
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
4
|
+
# license agreements.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
7
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
8
|
+
# the License at
|
9
|
+
#
|
10
|
+
# 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
|
+
# Policy attributes used in batch read commands.
|
21
|
+
class BatchReadPolicy
|
22
|
+
|
23
|
+
attr_accessor :filter_exp, :read_touch_ttl_percent
|
24
|
+
|
25
|
+
def initialize(opt={})
|
26
|
+
# Optional expression filter. If filter_exp exists and evaluates to false, the specific batch key
|
27
|
+
# request is not performed and {BatchRecord#result_code} is set to
|
28
|
+
# {ResultCode#FILTERED_OUT}.
|
29
|
+
#
|
30
|
+
# If exists, this filter overrides the batch parent filter {Policy#filter_exp}
|
31
|
+
# for the specific key in batch commands that allow a different policy per key.
|
32
|
+
# Otherwise, this filter is ignored.
|
33
|
+
#
|
34
|
+
# Default: nil
|
35
|
+
@filter_exp = opt[:filter_exp]
|
36
|
+
|
37
|
+
# Determines how record TTL (time to live) is affected on reads. When enabled, the server can
|
38
|
+
# efficiently operate as a read-based LRU cache where the least recently used records are expired.
|
39
|
+
# The value is expressed as a percentage of the TTL sent on the most recent write such that a read
|
40
|
+
# within this interval of the record’s end of life will generate a touch.
|
41
|
+
#
|
42
|
+
# For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
|
43
|
+
# 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
|
44
|
+
# recent write) will result in a touch, resetting the TTL to another 10 hours.
|
45
|
+
#
|
46
|
+
# Values:
|
47
|
+
#
|
48
|
+
# 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.
|
49
|
+
# -1 : Do not reset record TTL on reads.
|
50
|
+
# 1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.
|
51
|
+
# Default: 0
|
52
|
+
@read_touch_ttl_percent = opt[:read_touch_ttl_percent] || 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Copyright 2014-2023 Aerospike, Inc.
|
2
|
+
#
|
3
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
4
|
+
# license agreements.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
7
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
8
|
+
# the License at
|
9
|
+
#
|
10
|
+
# 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
|
+
# Policy attributes used in batch UDF execute commands.
|
21
|
+
class BatchUDFPolicy
|
22
|
+
|
23
|
+
attr_accessor :filter_exp, :commit_level, :ttl, :durable_delete, :send_key
|
24
|
+
|
25
|
+
alias expiration ttl
|
26
|
+
alias expiration= ttl=
|
27
|
+
|
28
|
+
def initialize(opt={})
|
29
|
+
# Optional expression filter. If filter_exp exists and evaluates to false, the specific batch key
|
30
|
+
# request is not performed and {BatchRecord#resultCode} is set to
|
31
|
+
# {ResultCode#FILTERED_OUT}.
|
32
|
+
#
|
33
|
+
# If exists, this filter overrides the batch parent filter {Policy#filter_exp}
|
34
|
+
# for the specific key in batch commands that allow a different policy per key.
|
35
|
+
# Otherwise, this filter is ignored.
|
36
|
+
#
|
37
|
+
# Default: nil
|
38
|
+
@filter_exp = opt[:filter_exp]
|
39
|
+
|
40
|
+
# Desired consistency guarantee when committing a transaction on the server. The default
|
41
|
+
# (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
|
42
|
+
# be successful before returning success to the client.
|
43
|
+
#
|
44
|
+
# Default: CommitLevel::COMMIT_ALL
|
45
|
+
@commit_level = opt.fetch(:commit_level, CommitLevel::COMMIT_ALL)
|
46
|
+
|
47
|
+
# Record expiration; also known as time-to-live (TTL).
|
48
|
+
# Seconds record will live before being removed by the server.
|
49
|
+
#
|
50
|
+
# Supported values:
|
51
|
+
# - `Aerospike::TTL::NEVER_EXPIRE`: Never expire record; requires Aerospike 2
|
52
|
+
# server versions >= 2.7.2 or Aerospike 3 server versions >= 3.1.4. Do
|
53
|
+
# not use for older servers.
|
54
|
+
# - `Aerospike::TTL::NAMESPACE_DEFAULT`: Default to namespace configuration
|
55
|
+
# variable "default-ttl" on the server.
|
56
|
+
# - `Aerospike::TTL::DONT_UPDATE`: Do not change a record's expiration date
|
57
|
+
# when updating the record. Requires Aerospike server v3.10.1 or later.
|
58
|
+
# - Any value > 0: Actual time-to-live in seconds.
|
59
|
+
@ttl = opt[:ttl] || opt[:expiration] || 0
|
60
|
+
|
61
|
+
# If the transaction results in a record deletion, leave a tombstone for the record.
|
62
|
+
# This prevents deleted records from reappearing after node failures.
|
63
|
+
# Valid for Aerospike Server Enterprise Edition only.
|
64
|
+
#
|
65
|
+
# Default: false (do not tombstone deleted records).
|
66
|
+
@durable_delete = opt.fetch(:durable_delete, false)
|
67
|
+
|
68
|
+
# Send user defined key in addition to hash digest.
|
69
|
+
# If true, the key will be stored with the record on the server.
|
70
|
+
#
|
71
|
+
# Default: false (do not send the user defined key)
|
72
|
+
@send_key = opt.fetch(:send_key, false)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# Copyright 2014-2023 Aerospike, Inc.
|
2
|
+
#
|
3
|
+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
|
4
|
+
# license agreements.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
7
|
+
# use this file except in compliance with the License. You may obtain a copy of
|
8
|
+
# the License at
|
9
|
+
#
|
10
|
+
# 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
|
+
|
21
|
+
# Policy attributes used in batch write commands.
|
22
|
+
class BatchWritePolicy
|
23
|
+
|
24
|
+
attr_accessor :filter_exp, :record_exists_action, :commit_level,
|
25
|
+
:generation_policy, :generation, :ttl, :durable_delete,
|
26
|
+
:send_key
|
27
|
+
|
28
|
+
alias expiration ttl
|
29
|
+
alias expiration= ttl=
|
30
|
+
|
31
|
+
def initialize(opt={})
|
32
|
+
# Optional expression filter. If filter_exp exists and evaluates to false, the specific batch key
|
33
|
+
# request is not performed and {BatchRecord#result_code} is set to
|
34
|
+
# {ResultCode#FILTERED_OUT}.
|
35
|
+
#
|
36
|
+
# If exists, this filter overrides the batch parent filter {Policy#filter_exp}
|
37
|
+
# for the specific key in batch commands that allow a different policy per key.
|
38
|
+
# Otherwise, this filter is ignored.
|
39
|
+
#
|
40
|
+
# Default: nil
|
41
|
+
@filter_exp = opt[:filter_exp]
|
42
|
+
|
43
|
+
# Qualify how to handle writes where the record already exists.
|
44
|
+
#
|
45
|
+
# Default: RecordExistsAction::UPDATE
|
46
|
+
@record_exists_action = opt.fetch(:record_exists_action, RecordExistsAction::UPDATE)
|
47
|
+
|
48
|
+
# Desired consistency guarantee when committing a transaction on the server. The default
|
49
|
+
# (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
|
50
|
+
# be successful before returning success to the client.
|
51
|
+
#
|
52
|
+
# Default: CommitLevel::COMMIT_ALL
|
53
|
+
@commit_level = opt.fetch(:commit_level, CommitLevel::COMMIT_ALL)
|
54
|
+
|
55
|
+
# Qualify how to handle record writes based on record generation. The default (NONE)
|
56
|
+
# indicates that the generation is not used to restrict writes.
|
57
|
+
#
|
58
|
+
# The server does not support this field for UDF execute() calls. The read-modify-write
|
59
|
+
# usage model can still be enforced inside the UDF code itself.
|
60
|
+
#
|
61
|
+
# Default: GenerationPolicy::NONE
|
62
|
+
@generation_policy = opt.fetch(:generation_policy, GenerationPolicy::NONE)
|
63
|
+
|
64
|
+
# Expected generation. Generation is the number of times a record has been modified
|
65
|
+
# (including creation) on the server. If a write operation is creating a record,
|
66
|
+
# the expected generation would be <code>0</code>. This field is only relevant when
|
67
|
+
# generationPolicy is not NONE.
|
68
|
+
#
|
69
|
+
# The server does not support this field for UDF execute() calls. The read-modify-write
|
70
|
+
# usage model can still be enforced inside the UDF code itself.
|
71
|
+
#
|
72
|
+
# Default: 0
|
73
|
+
@generation = opt.fetch(:generation, 0)
|
74
|
+
|
75
|
+
# Record expiration; also known as time-to-live (TTL).
|
76
|
+
# Seconds record will live before being removed by the server.
|
77
|
+
#
|
78
|
+
# Supported values:
|
79
|
+
# - `Aerospike::TTL::NEVER_EXPIRE`: Never expire record; requires Aerospike 2
|
80
|
+
# server versions >= 2.7.2 or Aerospike 3 server versions >= 3.1.4. Do
|
81
|
+
# not use for older servers.
|
82
|
+
# - `Aerospike::TTL::NAMESPACE_DEFAULT`: Default to namespace configuration
|
83
|
+
# variable "default-ttl" on the server.
|
84
|
+
# - `Aerospike::TTL::DONT_UPDATE`: Do not change a record's expiration date
|
85
|
+
# when updating the record. Requires Aerospike server v3.10.1 or later.
|
86
|
+
# - Any value > 0: Actual time-to-live in seconds.
|
87
|
+
@ttl = opt[:ttl] || opt[:expiration] || 0
|
88
|
+
|
89
|
+
# If the transaction results in a record deletion, leave a tombstone for the record.
|
90
|
+
# This prevents deleted records from reappearing after node failures.
|
91
|
+
# Valid for Aerospike Server Enterprise Edition only.
|
92
|
+
#
|
93
|
+
# Default: false (do not tombstone deleted records).
|
94
|
+
@durable_delete = opt.fetch(:durable_delete, false)
|
95
|
+
|
96
|
+
# Send user defined key in addition to hash digest.
|
97
|
+
# If true, the key will be stored with the record on the server.
|
98
|
+
#
|
99
|
+
# Default: false (do not send the user defined key)
|
100
|
+
@send_key = opt.fetch(:send_key, false)
|
101
|
+
|
102
|
+
self
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -22,7 +22,7 @@ module Aerospike
|
|
22
22
|
# Container object for client policy command.
|
23
23
|
class Policy
|
24
24
|
attr_accessor :filter_exp, :priority, :timeout, :max_retries, :sleep_between_retries, :consistency_level,
|
25
|
-
:
|
25
|
+
:fail_on_filtered_out, :replica, :use_compression, :socket_timeout, :read_touch_ttl_percent
|
26
26
|
|
27
27
|
alias total_timeout timeout
|
28
28
|
alias total_timeout= timeout=
|
@@ -31,7 +31,7 @@ module Aerospike
|
|
31
31
|
# Container object for transaction policy attributes used in all database
|
32
32
|
# operation calls.
|
33
33
|
|
34
|
-
# Optional expression filter. If
|
34
|
+
# Optional expression filter. If filter_exp exists and evaluates to false, the
|
35
35
|
# transaction is ignored.
|
36
36
|
#
|
37
37
|
# Default: nil
|
@@ -57,44 +57,7 @@ module Aerospike
|
|
57
57
|
# TODO: Remove for next major release
|
58
58
|
@priority = opt[:priority] || Priority::DEFAULT
|
59
59
|
|
60
|
-
#
|
61
|
-
# Predicate expression filters are applied on the query results on the server.
|
62
|
-
# Predicate expression filters may occur on any bin in the record.
|
63
|
-
# Requires Aerospike Server versions >= 3.12
|
64
|
-
#
|
65
|
-
# Postfix notation is described here: http://wiki.c2.com/?PostfixNotation
|
66
|
-
#
|
67
|
-
# Example:
|
68
|
-
#
|
69
|
-
# (c >= 11 and c <= 20) or (d > 3 and (d < 5)
|
70
|
-
# policy.predexp = [
|
71
|
-
# PredExp.integer_bin("c"),
|
72
|
-
# PredExp.integer_value(11),
|
73
|
-
# PredExp.integer_greater_eq(),
|
74
|
-
# PredExp.integer_bin("c"),
|
75
|
-
# PredExp.integer_value(20),
|
76
|
-
# PredExp.integer_less_eq(),
|
77
|
-
# PredExp.and(2),
|
78
|
-
# PredExp.integer_bin("d"),
|
79
|
-
# PredExp.integer_value(3),
|
80
|
-
# PredExp.integer_greater(),
|
81
|
-
# PredExp.integer_bin("d"),
|
82
|
-
# PredExp.integer_value(5),
|
83
|
-
# PredExp.integer_less(),
|
84
|
-
# PredExp.and(2),
|
85
|
-
# PredExp.or(2)
|
86
|
-
# ]
|
87
|
-
#
|
88
|
-
# # Record last update time > 2017-01-15
|
89
|
-
# policy.predexp = [
|
90
|
-
# PredExp.rec_last_update(),
|
91
|
-
# PredExp.integer_value(Time.new(2017, 1, 15).to_i),
|
92
|
-
# PredExp.integer_greater(),
|
93
|
-
# PredExp.integer_greater()
|
94
|
-
# ]
|
95
|
-
@predexp = opt[:predexp] || nil
|
96
|
-
|
97
|
-
# Throw exception if @predexp is defined and that filter evaluates
|
60
|
+
# Throw exception if @filter_exp is defined and that filter evaluates
|
98
61
|
# to false (transaction ignored). The Aerospike::Exceptions::Aerospike
|
99
62
|
# will contain result code Aerospike::ResultCode::FILTERED_OUT.
|
100
63
|
# This field is not applicable to batch, scan or query commands.
|
@@ -132,6 +95,23 @@ module Aerospike
|
|
132
95
|
# has not yet been exceeded.
|
133
96
|
@max_retries = opt[:max_retries] || 2
|
134
97
|
|
98
|
+
# Determines how record TTL (time to live) is affected on reads. When enabled, the server can
|
99
|
+
# efficiently operate as a read-based LRU cache where the least recently used records are expired.
|
100
|
+
# The value is expressed as a percentage of the TTL sent on the most recent write such that a read
|
101
|
+
# within this interval of the record’s end of life will generate a touch.
|
102
|
+
#
|
103
|
+
# For example, if the most recent write had a TTL of 10 hours and read_touch_ttl_percent is set to
|
104
|
+
# 80, the next read within 8 hours of the record's end of life (equivalent to 2 hours after the most
|
105
|
+
# recent write) will result in a touch, resetting the TTL to another 10 hours.
|
106
|
+
#
|
107
|
+
# Values:
|
108
|
+
#
|
109
|
+
# 0 : Use server config default-read-touch-ttl-pct for the record's namespace/set.
|
110
|
+
# -1 : Do not reset record TTL on reads.
|
111
|
+
# 1 - 100 : Reset record TTL on reads when within this percentage of the most recent write TTL.
|
112
|
+
# Default: 0
|
113
|
+
@read_touch_ttl_percent = opt[:read_touch_ttl_percent] || 0
|
114
|
+
|
135
115
|
# Duration to sleep between retries if a transaction fails and the
|
136
116
|
# timeout was not exceeded. Enter zero to skip sleep.
|
137
117
|
@sleep_between_retries = opt[:sleep_between_retries] || 0.5
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright 2014-2024 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
|
+
# Defines the expected query duration. The server treats the query in different ways depending on the expected duration.
|
19
|
+
# This enum is ignored for aggregation queries, background queries and server versions < 6.0.
|
20
|
+
module QueryDuration
|
21
|
+
|
22
|
+
# The query is expected to return more than 100 records per node. The server optimizes for a large record set in
|
23
|
+
# the following ways:
|
24
|
+
#
|
25
|
+
# Allow query to be run in multiple threads using the server's query threading configuration.
|
26
|
+
# Do not relax read consistency for AP namespaces.
|
27
|
+
# Add the query to the server's query monitor.
|
28
|
+
# Do not add the overall latency to the server's latency histogram.
|
29
|
+
# Do not allow server timeouts.
|
30
|
+
LONG = 0
|
31
|
+
|
32
|
+
# The query is expected to return less than 100 records per node. The server optimizes for a small record set in
|
33
|
+
# the following ways:
|
34
|
+
# Always run the query in one thread and ignore the server's query threading configuration.
|
35
|
+
# Allow query to be inlined directly on the server's service thread.
|
36
|
+
# Relax read consistency for AP namespaces.
|
37
|
+
# Do not add the query to the server's query monitor.
|
38
|
+
# Add the overall latency to the server's latency histogram.
|
39
|
+
# Allow server timeouts. The default server timeout for a short query is 1 second.
|
40
|
+
SHORT = 1
|
41
|
+
|
42
|
+
# Treat query as a LONG query, but relax read consistency for AP namespaces.
|
43
|
+
# This value is treated exactly like LONG for server versions < 7.1.
|
44
|
+
LONG_RELAX_AP = 2
|
45
|
+
|
46
|
+
end # module
|
47
|
+
|
48
|
+
end # module
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# License for the specific language governing permissions and limitations under
|
16
16
|
# the License.
|
17
17
|
|
18
|
+
require 'aerospike/policy/query_duration'
|
18
19
|
require 'aerospike/policy/policy'
|
19
20
|
|
20
21
|
module Aerospike
|
@@ -22,16 +23,10 @@ module Aerospike
|
|
22
23
|
# Container object for query policy command.
|
23
24
|
class QueryPolicy < Policy
|
24
25
|
|
25
|
-
attr_accessor :concurrent_nodes
|
26
|
-
attr_accessor :max_records
|
27
|
-
attr_accessor :include_bin_data
|
28
|
-
attr_accessor :record_queue_size
|
29
|
-
attr_accessor :records_per_second
|
30
|
-
attr_accessor :socket_timeout
|
31
|
-
attr_accessor :short_query
|
26
|
+
attr_accessor :concurrent_nodes, :max_records, :include_bin_data, :record_queue_size, :records_per_second, :socket_timeout, :short_query, :expected_duration
|
32
27
|
|
33
28
|
def initialize(opt={})
|
34
|
-
super
|
29
|
+
super
|
35
30
|
|
36
31
|
# Indicates if bin data is retrieved. If false, only record digests (and
|
37
32
|
# user keys if stored on the server) are retrieved.
|
@@ -74,11 +69,21 @@ module Aerospike
|
|
74
69
|
# Default is 0
|
75
70
|
@records_per_second = opt[:records_per_second] || 0
|
76
71
|
|
72
|
+
# Expected query duration. The server treats the query in different ways depending on the expected duration.
|
73
|
+
# This field is ignored for aggregation queries, background queries and server versions < 6.0.
|
74
|
+
#
|
75
|
+
# Default: QueryDuration::LONG
|
76
|
+
@expected_duration = opt[:expected_duration] || QueryDuration::LONG
|
77
|
+
|
78
|
+
# DEPRECATED
|
77
79
|
# Detemine wether query expected to return less than 100 records.
|
78
80
|
# If true, the server will optimize the query for a small record set.
|
79
81
|
# This field is ignored for aggregation queries, background queries
|
80
82
|
# and server versions 6.0+.
|
81
83
|
#
|
84
|
+
# This field is deprecated and will eventually be removed. Use {expected_duration} instead.
|
85
|
+
# For backwards compatibility: If ShortQuery is true, the query is treated as a short query and
|
86
|
+
# {expected_duration} is ignored. If {short_query} is false, {expected_duration} is used as defaults to {Policy#QueryDuration#LONG}.
|
82
87
|
# Default: false
|
83
88
|
@short_query = opt[:short_query] ||false
|
84
89
|
|
@@ -21,9 +21,7 @@ module Aerospike
|
|
21
21
|
# index name, filters, and operations.
|
22
22
|
class Statement
|
23
23
|
|
24
|
-
attr_accessor :namespace, :set_name, :index_name, :bin_names, :task_id
|
25
|
-
attr_accessor :filters, :package_name, :function_name, :function_args, :operations
|
26
|
-
attr_accessor :predexp, :return_data, :records_per_second
|
24
|
+
attr_accessor :namespace, :set_name, :index_name, :bin_names, :task_id, :filters, :package_name, :function_name, :function_args, :operations, :return_data, :records_per_second
|
27
25
|
|
28
26
|
def initialize(namespace, set_name, bin_names=[])
|
29
27
|
# Namespace determines query Namespace
|
@@ -46,16 +44,6 @@ module Aerospike
|
|
46
44
|
# aggregation function.
|
47
45
|
@filters = []
|
48
46
|
|
49
|
-
# Predicate expressions in postfix notation. If the expression is evaluated to false,
|
50
|
-
# the record will be ommited in the results.
|
51
|
-
#
|
52
|
-
# This method is redundant because PredExp can now be set in the base Policy for
|
53
|
-
# any transaction (including queries).
|
54
|
-
#
|
55
|
-
# NOTE : Policy.predexp takes precedence to this value. This value will be
|
56
|
-
# deprecated in the future.
|
57
|
-
@predexp = nil
|
58
|
-
|
59
47
|
@package_name = nil
|
60
48
|
@function_name = nil
|
61
49
|
@function_args = nil
|
@@ -83,27 +71,23 @@ module Aerospike
|
|
83
71
|
end
|
84
72
|
|
85
73
|
def is_scan?
|
86
|
-
|
74
|
+
filters.nil? || filters.empty?
|
87
75
|
end
|
88
76
|
|
89
77
|
def set_task_id
|
90
|
-
while @task_id == 0
|
91
|
-
@task_id = rand(RAND_MAX)
|
92
|
-
end
|
78
|
+
@task_id = rand(RAND_MAX) while @task_id == 0
|
93
79
|
end
|
94
80
|
|
95
81
|
def reset_task_id
|
96
82
|
@task_id = rand(RAND_MAX)
|
97
|
-
while @task_id == 0
|
98
|
-
@task_id = rand(RAND_MAX)
|
99
|
-
end
|
83
|
+
@task_id = rand(RAND_MAX) while @task_id == 0
|
100
84
|
end
|
101
85
|
|
102
86
|
|
103
87
|
|
104
88
|
private
|
105
89
|
|
106
|
-
RAND_MAX = 2**63 - 1
|
90
|
+
RAND_MAX = (2**63) - 1
|
107
91
|
|
108
92
|
end # class
|
109
93
|
end
|
@@ -168,6 +168,9 @@ module Aerospike
|
|
168
168
|
# Write command loses conflict to XDR.
|
169
169
|
LOST_CONFLICT = 28
|
170
170
|
|
171
|
+
# Write can't complete until XDR finishes shipping.
|
172
|
+
XDR_KEY_BUSY = 32
|
173
|
+
|
171
174
|
# There are no more records left for query.
|
172
175
|
QUERY_END = 50
|
173
176
|
|
@@ -445,6 +448,10 @@ module Aerospike
|
|
445
448
|
when LOST_CONFLICT
|
446
449
|
"Write command loses conflict to XDR."
|
447
450
|
|
451
|
+
# Write can't complete until XDR finishes shipping.
|
452
|
+
when XDR_KEY_BUSY
|
453
|
+
"XDR key busy"
|
454
|
+
|
448
455
|
when QUERY_END
|
449
456
|
"Query end"
|
450
457
|
|
@@ -580,7 +587,6 @@ module Aerospike
|
|
580
587
|
else
|
581
588
|
"ResultCode #{code} unknown in the client. Please file a github issue."
|
582
589
|
end # case
|
583
|
-
|
584
590
|
end
|
585
591
|
|
586
592
|
end # class
|