aerospike 2.9.0 → 2.13.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 +51 -4
- data/README.md +1 -1
- data/lib/aerospike.rb +12 -4
- data/lib/aerospike/aerospike_exception.rb +7 -1
- data/lib/aerospike/atomic/atomic.rb +1 -1
- data/lib/aerospike/bin.rb +1 -1
- data/lib/aerospike/cdt/list_operation.rb +1 -1
- data/lib/aerospike/cdt/map_operation.rb +1 -1
- data/lib/aerospike/cdt/map_order.rb +1 -1
- data/lib/aerospike/cdt/map_policy.rb +1 -1
- data/lib/aerospike/cdt/map_return_type.rb +1 -1
- data/lib/aerospike/cdt/map_write_mode.rb +1 -1
- data/lib/aerospike/client.rb +10 -11
- data/lib/aerospike/cluster.rb +92 -17
- data/lib/aerospike/cluster/partition.rb +1 -1
- data/lib/aerospike/cluster/partition_parser.rb +169 -0
- data/lib/aerospike/command/admin_command.rb +2 -3
- data/lib/aerospike/command/batch_direct_command.rb +1 -1
- data/lib/aerospike/command/batch_direct_exists_command.rb +1 -1
- data/lib/aerospike/command/batch_direct_node.rb +3 -3
- data/lib/aerospike/command/batch_index_command.rb +10 -2
- data/lib/aerospike/command/batch_index_node.rb +2 -2
- data/lib/aerospike/command/batch_item.rb +1 -1
- data/lib/aerospike/command/command.rb +102 -11
- data/lib/aerospike/command/delete_command.rb +21 -5
- data/lib/aerospike/command/execute_command.rb +1 -1
- data/lib/aerospike/command/exists_command.rb +21 -5
- data/lib/aerospike/command/field_type.rb +3 -1
- data/lib/aerospike/command/multi_command.rb +11 -4
- data/lib/aerospike/command/operate_command.rb +6 -1
- data/lib/aerospike/command/read_command.rb +29 -18
- data/lib/aerospike/command/read_header_command.rb +18 -6
- data/lib/aerospike/command/roles.rb +1 -1
- data/lib/aerospike/command/single_command.rb +9 -3
- data/lib/aerospike/command/touch_command.rb +14 -3
- data/lib/aerospike/command/unsupported_particle_type_validator.rb +1 -1
- data/lib/aerospike/command/write_command.rb +13 -4
- data/lib/aerospike/connection/create.rb +1 -1
- data/lib/aerospike/features.rb +1 -1
- data/lib/aerospike/geo_json.rb +70 -1
- data/lib/aerospike/host.rb +1 -1
- data/lib/aerospike/info.rb +1 -1
- data/lib/aerospike/key.rb +1 -1
- data/lib/aerospike/language.rb +1 -1
- data/lib/aerospike/node.rb +3 -6
- data/lib/aerospike/node/refresh/partitions.rb +6 -15
- data/lib/aerospike/node_validator.rb +45 -40
- data/lib/aerospike/operation.rb +6 -1
- data/lib/aerospike/policy/admin_policy.rb +1 -1
- data/lib/aerospike/policy/batch_policy.rb +1 -1
- data/lib/aerospike/policy/client_policy.rb +1 -1
- data/lib/aerospike/policy/commit_level.rb +1 -1
- data/lib/aerospike/policy/consistency_level.rb +1 -1
- data/lib/aerospike/policy/generation_policy.rb +1 -1
- data/lib/aerospike/policy/operate_policy.rb +1 -1
- data/lib/aerospike/policy/policy.rb +57 -3
- data/lib/aerospike/policy/priority.rb +1 -1
- data/lib/aerospike/policy/query_policy.rb +8 -1
- data/lib/aerospike/policy/record_bin_multiplicity.rb +1 -1
- data/lib/aerospike/policy/record_exists_action.rb +1 -1
- data/lib/aerospike/policy/replica.rb +38 -0
- data/lib/aerospike/policy/scan_policy.rb +8 -1
- data/lib/aerospike/policy/write_policy.rb +1 -1
- data/lib/aerospike/query/filter.rb +1 -1
- data/lib/aerospike/query/pred_exp.rb +192 -0
- data/lib/aerospike/query/pred_exp/and_or.rb +32 -0
- data/lib/aerospike/query/pred_exp/geo_json_value.rb +41 -0
- data/lib/aerospike/query/pred_exp/integer_value.rb +32 -0
- data/lib/aerospike/query/pred_exp/op.rb +27 -0
- data/lib/aerospike/query/pred_exp/regex.rb +32 -0
- data/lib/aerospike/query/pred_exp/regex_flags.rb +23 -0
- data/lib/aerospike/query/pred_exp/string_value.rb +29 -0
- data/lib/aerospike/query/query_command.rb +27 -1
- data/lib/aerospike/query/recordset.rb +5 -5
- data/lib/aerospike/query/scan_command.rb +1 -1
- data/lib/aerospike/query/statement.rb +12 -3
- data/lib/aerospike/query/stream_command.rb +9 -10
- data/lib/aerospike/record.rb +1 -1
- data/lib/aerospike/result_code.rb +13 -20
- data/lib/aerospike/socket/base.rb +1 -1
- data/lib/aerospike/task/execute_task.rb +1 -1
- data/lib/aerospike/task/index_task.rb +1 -1
- data/lib/aerospike/task/task.rb +1 -1
- data/lib/aerospike/task/udf_register_task.rb +1 -1
- data/lib/aerospike/task/udf_remove_task.rb +1 -1
- data/lib/aerospike/ttl.rb +1 -1
- data/lib/aerospike/udf.rb +1 -1
- data/lib/aerospike/user_role.rb +1 -1
- data/lib/aerospike/utils/buffer.rb +1 -1
- data/lib/aerospike/utils/packer.rb +1 -1
- data/lib/aerospike/utils/pool.rb +1 -1
- data/lib/aerospike/utils/unpacker.rb +7 -2
- data/lib/aerospike/value/particle_type.rb +1 -1
- data/lib/aerospike/value/value.rb +59 -29
- data/lib/aerospike/version.rb +1 -1
- metadata +15 -8
- data/lib/aerospike/cluster/partition_tokenizer_new.rb +0 -130
- data/lib/aerospike/cluster/partition_tokenizer_old.rb +0 -135
@@ -0,0 +1,38 @@
|
|
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
|
+
# Distribute reads across all nodes in cluster in round-robin fashion.
|
32
|
+
# This option is useful when the replication factor equals the number
|
33
|
+
# of nodes in the cluster and the overhead of requesting proles is not desired.
|
34
|
+
RANDOM = 4
|
35
|
+
|
36
|
+
end # module
|
37
|
+
|
38
|
+
end # module
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2014-
|
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
|
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
AND = 1
|
6
|
+
OR = 2
|
7
|
+
NOT = 3
|
8
|
+
INTEGER_VALUE = 10
|
9
|
+
STRING_VALUE = 11
|
10
|
+
GEOJSON_VALUE = 12
|
11
|
+
INTEGER_BIN = 100
|
12
|
+
STRING_BIN = 101
|
13
|
+
GEOJSON_BIN = 102
|
14
|
+
LIST_BIN = 103
|
15
|
+
MAP_BIN = 104
|
16
|
+
INTEGER_VAR = 120
|
17
|
+
STRING_VAR = 121
|
18
|
+
GEOJSON_VAR = 122
|
19
|
+
RECSIZE = 150
|
20
|
+
LAST_UPDATE = 151
|
21
|
+
VOID_TIME = 152
|
22
|
+
INTEGER_EQUAL = 200
|
23
|
+
INTEGER_UNEQUAL = 201
|
24
|
+
INTEGER_GREATER = 202
|
25
|
+
INTEGER_GREATEREQ = 203
|
26
|
+
INTEGER_LESS = 204
|
27
|
+
INTEGER_LESSEQ = 205
|
28
|
+
STRING_EQUAL = 210
|
29
|
+
STRING_UNEQUAL = 211
|
30
|
+
STRING_REGEX = 212
|
31
|
+
GEOJSON_WITHIN = 220
|
32
|
+
GEOJSON_CONTAINS = 221
|
33
|
+
LIST_ITERATE_OR = 250
|
34
|
+
MAPKEY_ITERATE_OR = 251
|
35
|
+
MAPVAL_ITERATE_OR = 252
|
36
|
+
LIST_ITERATE_AND = 253
|
37
|
+
MAPKEY_ITERATE_AND = 254
|
38
|
+
MAPVAL_ITERATE_AND = 255
|
39
|
+
|
40
|
+
def self.and(nexp)
|
41
|
+
AndOr.new(AND, nexp)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.or(nexp)
|
45
|
+
AndOr.new(OR, nexp)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.not
|
49
|
+
Op.new(NOT)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.integer_value(value)
|
53
|
+
IntegerValue.new(value, INTEGER_VALUE)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.string_value(value)
|
57
|
+
StringValue.new(value, STRING_VALUE)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.geojson_value(value)
|
61
|
+
raise(ArgumentError, "value must be a GeoJSON object!") unless value.is_a?(Aerospike::GeoJSON)
|
62
|
+
GeoJsonValue.new(value.to_s, GEOJSON_VALUE)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.integer_bin(name)
|
66
|
+
StringValue.new(name, INTEGER_BIN)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.string_bin(name)
|
70
|
+
StringValue.new(name, STRING_BIN)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.geojson_bin(name)
|
74
|
+
StringValue.new(name, GEOJSON_BIN)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.list_bin(name)
|
78
|
+
StringValue.new(name, LIST_BIN)
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.map_bin(name)
|
82
|
+
StringValue.new(name, MAP_BIN)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.integer_var(name)
|
86
|
+
StringValue.new(name, INTEGER_VAR)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.string_var(name)
|
90
|
+
StringValue.new(name, STRING_VAR)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.geojson_var(name)
|
94
|
+
StringValue.new(name, GEOJSON_VAR)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.record_size
|
98
|
+
Op.new(RECSIZE)
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.last_update
|
102
|
+
Op.new(LAST_UPDATE)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.void_time
|
106
|
+
Op.new(VOID_TIME)
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.integer_equal
|
110
|
+
Op.new(INTEGER_EQUAL)
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.integer_unequal
|
114
|
+
Op.new(INTEGER_UNEQUAL)
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.integer_greater
|
118
|
+
Op.new(INTEGER_GREATER)
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.integer_greater_eq
|
122
|
+
Op.new(INTEGER_GREATEREQ)
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.integer_less
|
126
|
+
Op.new(INTEGER_LESS)
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.integer_less_eq
|
130
|
+
Op.new(INTEGER_LESSEQ)
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.string_equal
|
134
|
+
Op.new(STRING_EQUAL)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.string_unequal
|
138
|
+
Op.new(STRING_UNEQUAL)
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.string_regex(flags)
|
142
|
+
Regex.new(STRING_REGEX, flags)
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.geojson_within
|
146
|
+
Op.new(GEOJSON_WITHIN)
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.geojson_contains
|
150
|
+
Op.new(GEOJSON_CONTAINS)
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.list_iterate_or(var_name)
|
154
|
+
StringValue.new(var_name, LIST_ITERATE_OR)
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.list_iterate_and(var_name)
|
158
|
+
StringValue.new(var_name, LIST_ITERATE_AND)
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.mapkey_iterate_or(var_name)
|
162
|
+
StringValue.new(var_name, MAPKEY_ITERATE_OR)
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.mapkey_iterate_and(var_name)
|
166
|
+
StringValue.new(var_name, MAPKEY_ITERATE_AND)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.mapval_iterate_or(var_name)
|
170
|
+
StringValue.new(var_name, MAPVAL_ITERATE_OR)
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.mapval_iterate_and(var_name)
|
174
|
+
StringValue.new(var_name, MAPVAL_ITERATE_AND)
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
def self.estimate_size(predexp)
|
180
|
+
return 0 unless predexp
|
181
|
+
predexp.map(&:estimate_size).inject { |sum, size| sum + size }
|
182
|
+
end
|
183
|
+
|
184
|
+
def self.write(predexp, buffer, offset)
|
185
|
+
predexp.each do |p|
|
186
|
+
offset = p.write(buffer, offset)
|
187
|
+
end
|
188
|
+
|
189
|
+
offset
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
class AndOr < PredExp
|
6
|
+
def initialize(op, nexp)
|
7
|
+
@op = op
|
8
|
+
@nexp = nexp
|
9
|
+
end
|
10
|
+
|
11
|
+
def estimate_size
|
12
|
+
8
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(buffer, offset)
|
16
|
+
# write type
|
17
|
+
buffer.write_int16(@op, offset)
|
18
|
+
offset += 2
|
19
|
+
|
20
|
+
# write length
|
21
|
+
buffer.write_int32(2, offset)
|
22
|
+
offset += 4
|
23
|
+
|
24
|
+
# write predicate count
|
25
|
+
buffer.write_int16(@nexp, offset)
|
26
|
+
offset += 2
|
27
|
+
|
28
|
+
offset
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
class GeoJsonValue < PredExp
|
6
|
+
def initialize(value, type)
|
7
|
+
@value = value
|
8
|
+
@type = type
|
9
|
+
end
|
10
|
+
|
11
|
+
def estimate_size
|
12
|
+
@value.bytesize + 9
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(buffer, offset)
|
16
|
+
# tag
|
17
|
+
buffer.write_uint16(@type, offset)
|
18
|
+
offset += 2
|
19
|
+
|
20
|
+
# len
|
21
|
+
buffer.write_uint32(@value.bytesize + 3, offset)
|
22
|
+
offset += 4
|
23
|
+
|
24
|
+
# flags
|
25
|
+
|
26
|
+
buffer.write_byte(0, offset)
|
27
|
+
offset += 1
|
28
|
+
|
29
|
+
# ncells
|
30
|
+
buffer.write_uint16(0, offset)
|
31
|
+
offset += 2
|
32
|
+
|
33
|
+
# value
|
34
|
+
len = buffer.write_binary(@value, offset)
|
35
|
+
offset += len
|
36
|
+
|
37
|
+
offset
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
class IntegerValue < PredExp
|
6
|
+
def initialize(value, type)
|
7
|
+
@value = value
|
8
|
+
@type = type
|
9
|
+
end
|
10
|
+
|
11
|
+
def estimate_size
|
12
|
+
14
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(buffer, offset)
|
16
|
+
# Write type
|
17
|
+
buffer.write_int16(@type, offset)
|
18
|
+
offset += 2
|
19
|
+
|
20
|
+
# Write length
|
21
|
+
buffer.write_int32(8, offset)
|
22
|
+
offset += 4
|
23
|
+
|
24
|
+
# Write value.
|
25
|
+
buffer.write_int64(@value, offset)
|
26
|
+
offset += 8
|
27
|
+
|
28
|
+
offset
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
class Op < PredExp
|
6
|
+
def initialize(op)
|
7
|
+
@op = op
|
8
|
+
end
|
9
|
+
|
10
|
+
def estimate_size
|
11
|
+
6
|
12
|
+
end
|
13
|
+
|
14
|
+
def write(buffer, offset)
|
15
|
+
# write type
|
16
|
+
buffer.write_int16(@op, offset)
|
17
|
+
offset += 2
|
18
|
+
|
19
|
+
# write zero length
|
20
|
+
buffer.write_int32(0, offset)
|
21
|
+
offset += 4
|
22
|
+
|
23
|
+
offset
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
class Regex < PredExp
|
6
|
+
def initialize(op, flag = Flags::NONE)
|
7
|
+
@op = op
|
8
|
+
@flag = flag
|
9
|
+
end
|
10
|
+
|
11
|
+
def estimate_size
|
12
|
+
10
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(buffer, offset)
|
16
|
+
# write op type
|
17
|
+
buffer.write_int16(@op, offset)
|
18
|
+
offset += 2
|
19
|
+
|
20
|
+
# write length
|
21
|
+
buffer.write_int32(4, offset)
|
22
|
+
offset += 4
|
23
|
+
|
24
|
+
# write predicate count
|
25
|
+
buffer.write_int32(@flag, offset)
|
26
|
+
offset += 4
|
27
|
+
|
28
|
+
offset
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# fr# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aerospike
|
4
|
+
class PredExp
|
5
|
+
# Regex bit flags
|
6
|
+
module RegexFlags
|
7
|
+
# Regex defaults
|
8
|
+
NONE = 0
|
9
|
+
|
10
|
+
# Use POSIX Extended Regular Expression syntax when interpreting regex.
|
11
|
+
EXTENDED = 1
|
12
|
+
|
13
|
+
# Do not differentiate case.
|
14
|
+
ICASE = 2
|
15
|
+
|
16
|
+
# Do not report position of matches.
|
17
|
+
NOSUB = 4
|
18
|
+
|
19
|
+
# Match-any-character operators don't match a newline.
|
20
|
+
NEWLINE = 8
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|