aerospike 2.29.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -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_operation.rb +24 -10
- data/lib/aerospike/cdt/map_policy.rb +6 -3
- data/lib/aerospike/cdt/map_return_type.rb +8 -0
- data/lib/aerospike/client.rb +39 -56
- 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 +231 -128
- data/lib/aerospike/exp/exp.rb +54 -27
- 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 -86
- data/lib/aerospike/exp/exp_map.rb +118 -110
- data/lib/aerospike/exp/operation.rb +2 -2
- data/lib/aerospike/info.rb +2 -4
- data/lib/aerospike/node.rb +20 -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/{command/batch_direct_node.rb → policy/batch_read_policy.rb} +17 -19
- 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 +3 -40
- data/lib/aerospike/query/query_command.rb +3 -205
- data/lib/aerospike/query/query_executor.rb +2 -2
- data/lib/aerospike/query/query_partition_command.rb +4 -230
- data/lib/aerospike/query/scan_executor.rb +2 -2
- data/lib/aerospike/query/scan_partition_command.rb +3 -3
- data/lib/aerospike/query/server_command.rb +2 -2
- data/lib/aerospike/query/statement.rb +5 -21
- data/lib/aerospike/task/execute_task.rb +2 -2
- data/lib/aerospike/utils/buffer.rb +15 -15
- data/lib/aerospike/version.rb +1 -1
- data/lib/aerospike.rb +13 -12
- metadata +16 -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/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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbbb3eae452fb9c1bbe7a0a99e7505b4fa774396b9591edc80ae707abb9896e0
|
4
|
+
data.tar.gz: cd2bf9f22247dbc8f49581507b17f6347edf0a6f46a0c307f87eae45c3bf775b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88c12b118fcdf74f170a06ac3158b47f3e81076ee7c851d5ca06ea80b82d2b668c2df6588444e22c011dd43cbddce6586ecaaa30c895e54cefd47573e75b55ac
|
7
|
+
data.tar.gz: ffc436ee1b5696765fdc8ab00f87ef0c6e33afea3ae3ddc2d63dcd01fed91e62f3ddb8b109acf9fae65bc5bcabd9c1f36af8c60b87e86fb25c8b1528ed5e926b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,36 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [4.0.0] 2024-08-14
|
6
|
+
|
7
|
+
- **New Features**
|
8
|
+
- [CLIENT-2177] Add support for `MapReturnType#MAP_ORDERED` and `MapReturnType#MAP_UNORDERED`.
|
9
|
+
- [CLIENT-2308] Add `Exp#infinity_val` and `Exp#wildcard_val`.
|
10
|
+
- [CLIENT_1731] Support Batch Operations.
|
11
|
+
|
12
|
+
- **Updates**
|
13
|
+
- [CLIENT-3055] Remove Unsupported Server Features (`Predexp` and `BatchDirect`).
|
14
|
+
|
15
|
+
- **Improvements**
|
16
|
+
- [CLIENT-3056] Fix Github Actions Workflow. Tests still fail due to runner constraints, but we are now on the right track.
|
17
|
+
- [CLIENT-2682] Code Coverage - obtain current code coverage numbers for automated unit/integration functional tests.
|
18
|
+
|
19
|
+
- **Fixes**
|
20
|
+
- [CLIENT-3080] Set correct return types in list/map read expressions.
|
21
|
+
Set `bool` return type for list read expressions with `ListReturnType.EXISTS`.
|
22
|
+
Set `bool` return type for map read expressions with `MapReturnType.EXISTS`.
|
23
|
+
Set `map` return type for map read expressions with `MapReturnType.UNORDERED_MAP` or `MapReturnType.ORDERED_MAP`.
|
24
|
+
- [CLIENT-3072] Fix an issue where `Statement#return_data` is not respected.
|
25
|
+
|
26
|
+
## [3.0.0] 2023-12-15
|
27
|
+
Notice: This version of the client only supports Aerospike Server v6.0 and later. Some features will work for the older server versions.
|
28
|
+
- **new_features**
|
29
|
+
- [CLIENT-2575] - Support Exp.recordSize().
|
30
|
+
- [CLIENT-2621] - Support persistent map indexes.
|
31
|
+
|
32
|
+
- **improvements**
|
33
|
+
- [CLIENT-2590] - Required Updates Following Server-Side Changes: SINDEX Support for 'Blob' Type Elements.
|
34
|
+
|
5
35
|
## [2.29.0] 2023-08-24
|
6
36
|
- **Updates**
|
7
37
|
- [CLIENT-2526] Support for set quota for user defined roles
|
data/README.md
CHANGED
@@ -11,14 +11,18 @@ An Aerospike library for Ruby.
|
|
11
11
|
|
12
12
|
This library is compatible with Ruby 2.3+ and supports Linux, Mac OS X and various other BSDs.
|
13
13
|
|
14
|
-
- [
|
15
|
-
- [
|
16
|
-
- [
|
17
|
-
- [
|
18
|
-
- [
|
19
|
-
- [
|
20
|
-
- [
|
21
|
-
- [
|
14
|
+
- [Aerospike Ruby Client ](#aerospike-ruby-client---)
|
15
|
+
- [Usage:](#usage)
|
16
|
+
- [Prerequisites](#prerequisites)
|
17
|
+
- [Installation](#installation)
|
18
|
+
- [Installation from Ruby gems](#installation-from-ruby-gems)
|
19
|
+
- [Installation from source](#installation-from-source)
|
20
|
+
- [Tests](#tests)
|
21
|
+
- [Examples](#examples)
|
22
|
+
- [Tools](#tools)
|
23
|
+
- [Benchmarks](#benchmarks)
|
24
|
+
- [API Documentation](#api-documentation)
|
25
|
+
- [License](#license)
|
22
26
|
|
23
27
|
|
24
28
|
## Usage:
|
@@ -97,7 +101,7 @@ This library is packaged with a number of tests.
|
|
97
101
|
|
98
102
|
To run all the test cases:
|
99
103
|
|
100
|
-
$ AEROSPIKE_HOSTS="<host:port>[,<
|
104
|
+
$ AEROSPIKE_HOSTS="<host:port>[,<host:port>]" AEROSPIKE_USER="<user>" AEROSPIKE_PASSWORD="<pass>" bundle exec rspec
|
101
105
|
|
102
106
|
<a name="Examples"></a>
|
103
107
|
## Examples
|
@@ -0,0 +1,292 @@
|
|
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
|
+
|
20
|
+
class BatchAttr
|
21
|
+
|
22
|
+
attr_reader :filter_exp, :read_attr, :write_attr, :info_attr, :expiration, :generation, :has_write, :send_key
|
23
|
+
|
24
|
+
def initialize(ops = nil, opt = {})
|
25
|
+
rp = create_policy(opt, BatchPolicy, nil)
|
26
|
+
wp = create_policy(opt, BatchWritePolicy, nil)
|
27
|
+
|
28
|
+
read_all_bins = false
|
29
|
+
read_header = false
|
30
|
+
has_read = false
|
31
|
+
has_write_op = false
|
32
|
+
|
33
|
+
ops&.each do |op|
|
34
|
+
case op.op_type
|
35
|
+
when Operation::BIT_READ, Operation::EXP_READ, Operation::HLL_READ, Operation::CDT_READ, Operation::READ # Read all bins if no bin is specified.
|
36
|
+
read_all_bins = op.bin_name.nil?
|
37
|
+
has_read = true
|
38
|
+
|
39
|
+
when Operation::READ_HEADER
|
40
|
+
read_header = true
|
41
|
+
has_read = true
|
42
|
+
|
43
|
+
else
|
44
|
+
has_write_op = true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if has_write_op
|
49
|
+
set_batch_write(wp)
|
50
|
+
|
51
|
+
if has_read
|
52
|
+
@read_attr |= Aerospike::INFO1_READ
|
53
|
+
|
54
|
+
if read_all_bins
|
55
|
+
@read_attr |= Aerospike::INFO1_GET_ALL
|
56
|
+
elsif read_header
|
57
|
+
@read_attr |= Aerospike::INFO1_NOBINDATA
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
set_batch_read(rp)
|
62
|
+
|
63
|
+
if read_all_bins
|
64
|
+
@read_attr |= Aerospike::INFO1_GET_ALL
|
65
|
+
elsif read_header
|
66
|
+
@read_attr |= Aerospike::INFO1_NOBINDATA
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def set_read(rp)
|
72
|
+
@filter_exp = nil
|
73
|
+
@read_attr = Aerospike::INFO1_READ
|
74
|
+
|
75
|
+
@write_attr = 0
|
76
|
+
@info_attr = 0
|
77
|
+
|
78
|
+
@expiration = 0
|
79
|
+
@generation = 0
|
80
|
+
@has_write = false
|
81
|
+
@send_key = false
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_batch_read(rp)
|
85
|
+
@filter_exp = rp.filter_exp
|
86
|
+
@read_attr = Aerospike::INFO1_READ
|
87
|
+
|
88
|
+
@write_attr = 0
|
89
|
+
@info_attr = 0
|
90
|
+
|
91
|
+
@expiration = 0
|
92
|
+
@generation = 0
|
93
|
+
@has_write = false
|
94
|
+
@send_key = false
|
95
|
+
end
|
96
|
+
|
97
|
+
def adjust_read(ops)
|
98
|
+
read_all_bins = false
|
99
|
+
read_header = false
|
100
|
+
|
101
|
+
ops.each do |op|
|
102
|
+
case op.op_type
|
103
|
+
when Operation::BIT_READ, Operation::EXP_READ, Operation::HLL_READ, Operation::CDT_READ, Operation::READ # Read all bins if no bin is specified.
|
104
|
+
read_all_bins = op.bin_name.nil?
|
105
|
+
when Operation::READ_HEADER
|
106
|
+
read_header = true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
if read_all_bins
|
111
|
+
@read_attr |= Aerospike::INFO1_GET_ALL
|
112
|
+
elsif read_header
|
113
|
+
@read_attr |= Aerospike::INFO1_NOBINDATA
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def adjust_read_all_bins(read_all_bins)
|
118
|
+
@read_attr |= read_all_bins ? Aerospike::INFO1_GET_ALL : Aerospike::INFO1_NOBINDATA
|
119
|
+
end
|
120
|
+
|
121
|
+
def set_write(wp)
|
122
|
+
@filter_exp = nil
|
123
|
+
@read_attr = 0
|
124
|
+
@write_attr = Aerospike::INFO2_WRITE | Aerospike::INFO2_RESPOND_ALL_OPS
|
125
|
+
@info_attr = 0
|
126
|
+
@expiration = 0
|
127
|
+
@generation = 0
|
128
|
+
@has_write = true
|
129
|
+
@send_key = wp.send_key
|
130
|
+
end
|
131
|
+
|
132
|
+
def set_batch_write(wp)
|
133
|
+
@filter_exp = wp.filter_exp
|
134
|
+
@read_attr = 0
|
135
|
+
@write_attr = Aerospike::INFO2_WRITE | Aerospike::INFO2_RESPOND_ALL_OPS
|
136
|
+
@info_attr = 0
|
137
|
+
@expiration = wp.expiration
|
138
|
+
@has_write = true
|
139
|
+
@send_key = wp.send_key
|
140
|
+
|
141
|
+
case wp.generation_policy
|
142
|
+
when GenerationPolicy::NONE
|
143
|
+
@generation = 0
|
144
|
+
when GenerationPolicy::EXPECT_GEN_EQUAL
|
145
|
+
@generation = wp.generation
|
146
|
+
@write_attr |= Aerospike::INFO2_GENERATION
|
147
|
+
when GenerationPolicy::EXPECT_GEN_GT
|
148
|
+
@generation = wp.generation
|
149
|
+
@write_attr |= Aerospike::INFO2_GENERATION_GT
|
150
|
+
else
|
151
|
+
@generation = 0
|
152
|
+
end
|
153
|
+
|
154
|
+
case wp.record_exists_action
|
155
|
+
when RecordExistsAction::UPDATE
|
156
|
+
# NOOP
|
157
|
+
when RecordExistsAction::UPDATE_ONLY
|
158
|
+
@info_attr |= Aerospike::INFO3_UPDATE_ONLY
|
159
|
+
when RecordExistsAction::REPLACE
|
160
|
+
@info_attr |= Aerospike::INFO3_CREATE_OR_REPLACE
|
161
|
+
when RecordExistsAction::REPLACE_ONLY
|
162
|
+
@info_attr |= Aerospike::INFO3_REPLACE_ONLY
|
163
|
+
when RecordExistsAction::CREATE_ONLY
|
164
|
+
@write_attr |= Aerospike::INFO2_CREATE_ONLY
|
165
|
+
end
|
166
|
+
|
167
|
+
if wp.durable_delete
|
168
|
+
@write_attr |= Aerospike::INFO2_DURABLE_DELETE
|
169
|
+
end
|
170
|
+
|
171
|
+
if wp.commit_level == CommitLevel::COMMIT_MASTER
|
172
|
+
@info_attr |= Aerospike::INFO3_COMMIT_MASTER
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def adjust_write(ops)
|
177
|
+
read_all_bins = false
|
178
|
+
read_header = false
|
179
|
+
has_read = false
|
180
|
+
|
181
|
+
ops.each do |op|
|
182
|
+
case op.op_type
|
183
|
+
when Operation::BIT_READ, Operation::EXP_READ, Operation::HLL_READ, Operation::CDT_READ, Operation::READ # Read all bins if no bin is specified.
|
184
|
+
read_all_bins = op.bin_name.nil?
|
185
|
+
has_read = true
|
186
|
+
|
187
|
+
when Operation::READ_HEADER
|
188
|
+
read_header = true
|
189
|
+
has_read = true
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
if has_read
|
195
|
+
@read_attr |= Aerospike::INFO1_READ
|
196
|
+
|
197
|
+
if read_all_bins
|
198
|
+
@read_attr |= Aerospike::INFO1_GET_ALL
|
199
|
+
elsif read_header
|
200
|
+
@read_attr |= Aerospike::INFO1_NOBINDATA
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def set_udf(up)
|
206
|
+
@filter_exp = nil
|
207
|
+
@read_attr = 0
|
208
|
+
@write_attr = Aerospike::INFO2_WRITE
|
209
|
+
@info_attr = 0
|
210
|
+
@expiration = 0
|
211
|
+
@generation = 0
|
212
|
+
@has_write = true
|
213
|
+
@send_key = up.send_key
|
214
|
+
end
|
215
|
+
|
216
|
+
def set_batch_udf(up)
|
217
|
+
@filter_exp = up.filter_exp
|
218
|
+
@read_attr = 0
|
219
|
+
@write_attr = Aerospike::INFO2_WRITE
|
220
|
+
@info_attr = 0
|
221
|
+
@expiration = up.expiration
|
222
|
+
@generation = 0
|
223
|
+
@has_write = true
|
224
|
+
@send_key = up.send_key
|
225
|
+
|
226
|
+
if up.durable_delete
|
227
|
+
@write_attr |= Aerospike::INFO2_DURABLE_DELETE
|
228
|
+
end
|
229
|
+
|
230
|
+
if up.commit_level == CommitLevel::COMMIT_MASTER
|
231
|
+
@info_attr |= Aerospike::INFO3_COMMIT_MASTER
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def set_delete(dp)
|
236
|
+
@filter_exp = nil
|
237
|
+
@read_attr = 0
|
238
|
+
@write_attr = Aerospike::INFO2_WRITE | Aerospike::INFO2_RESPOND_ALL_OPS | Aerospike::INFO2_DELETE
|
239
|
+
@info_attr = 0
|
240
|
+
@expiration = 0
|
241
|
+
@generation = 0
|
242
|
+
@has_write = true
|
243
|
+
@send_key = dp.send_key
|
244
|
+
end
|
245
|
+
|
246
|
+
def set_batch_delete(dp)
|
247
|
+
@filter_exp = dp.filter_exp
|
248
|
+
@read_attr = 0
|
249
|
+
@write_attr = Aerospike::INFO2_WRITE | Aerospike::INFO2_RESPOND_ALL_OPS | Aerospike::INFO2_DELETE
|
250
|
+
@info_attr = 0
|
251
|
+
@expiration = 0
|
252
|
+
@has_write = true
|
253
|
+
@send_key = dp.send_key
|
254
|
+
|
255
|
+
case dp.generation_policy
|
256
|
+
when GenerationPolicy::NONE
|
257
|
+
@generation = 0
|
258
|
+
when GenerationPolicy::EXPECT_GEN_EQUAL
|
259
|
+
@generation = dp.generation
|
260
|
+
@write_attr |= Aerospike::INFO2_GENERATION
|
261
|
+
when GenerationPolicy::EXPECT_GEN_GT
|
262
|
+
@generation = dp.generation
|
263
|
+
@write_attr |= Aerospike::INFO2_GENERATION_GT
|
264
|
+
else
|
265
|
+
@generation = 0
|
266
|
+
end
|
267
|
+
|
268
|
+
if dp.durable_delete
|
269
|
+
@write_attr |= Aerospike::INFO2_DURABLE_DELETE
|
270
|
+
end
|
271
|
+
|
272
|
+
if dp.commit_level == CommitLevel::COMMIT_MASTER
|
273
|
+
@info_attr |= Aerospike::INFO3_COMMIT_MASTER
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
private
|
278
|
+
|
279
|
+
def create_policy(policy, policy_klass, default_policy = nil)
|
280
|
+
case policy
|
281
|
+
when nil
|
282
|
+
default_policy || policy_klass.new
|
283
|
+
when policy_klass
|
284
|
+
policy
|
285
|
+
when Hash
|
286
|
+
policy_klass.new(policy)
|
287
|
+
else
|
288
|
+
raise TypeError, "policy should be a #{policy_klass.name} instance or a Hash"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
# Batch delete operation.
|
20
|
+
class BatchDelete < BatchRecord
|
21
|
+
# Optional delete policy.
|
22
|
+
attr_accessor :policy
|
23
|
+
|
24
|
+
# Initialize policy and key.
|
25
|
+
def initialize(key, opt = {})
|
26
|
+
super(key, has_write: true)
|
27
|
+
@policy = BatchRecord.create_policy(opt, BatchDeletePolicy, DEFAULT_BATCH_DELETE_POLICY)
|
28
|
+
end
|
29
|
+
|
30
|
+
def ==(other) # :nodoc:
|
31
|
+
other && other.instance_of?(self.class) && @policy == other.policy
|
32
|
+
end
|
33
|
+
|
34
|
+
DEFAULT_BATCH_DELETE_POLICY = BatchDeletePolicy.new
|
35
|
+
|
36
|
+
# Return wire protocol size. For internal use only.
|
37
|
+
def size # :nodoc:
|
38
|
+
size = 6 # gen(2) + exp(4) = 6
|
39
|
+
|
40
|
+
size += @policy&.filter_exp&.size if @policy&.filter_exp
|
41
|
+
if @policy&.send_key
|
42
|
+
size += @key.user_key.estimate_size + Aerospike::FIELD_HEADER_SIZE + 1
|
43
|
+
end
|
44
|
+
|
45
|
+
size
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,97 @@
|
|
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
|
+
# Batch key and read only operations with default policy.
|
18
|
+
# Used in batch read commands where different bins are needed for each key.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
|
22
|
+
class BatchRead < BatchRecord
|
23
|
+
|
24
|
+
# Optional read policy.
|
25
|
+
attr_accessor :policy
|
26
|
+
|
27
|
+
# Bins to retrieve for this key. bin_names are mutually exclusive with
|
28
|
+
# {BatchRead#ops}.
|
29
|
+
attr_accessor :bin_names
|
30
|
+
|
31
|
+
# Optional operations for this key. ops are mutually exclusive with
|
32
|
+
# {BatchRead#bin_names}. A bin_name can be emulated with
|
33
|
+
# {Operation#get(bin_name)}
|
34
|
+
attr_accessor :ops
|
35
|
+
|
36
|
+
# If true, ignore bin_names and read all bins.
|
37
|
+
# If false and bin_names are set, read specified bin_names.
|
38
|
+
# If false and bin_names are not set, read record header (generation, expiration) only.
|
39
|
+
attr_accessor :read_all_bins
|
40
|
+
|
41
|
+
# Initialize batch key and bins to retrieve.
|
42
|
+
def self.read_bins(key, bin_names, opt = {})
|
43
|
+
br = BatchRead.new(key)
|
44
|
+
br.policy = BatchRecord.create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY)
|
45
|
+
br.bin_names = bin_names
|
46
|
+
br.read_all_bins = false
|
47
|
+
br
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initialize batch key and read_all_bins indicator.
|
51
|
+
def self.read_all_bins(key, opt = {})
|
52
|
+
br = BatchRead.new(key)
|
53
|
+
br.policy = create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY)
|
54
|
+
br.read_all_bins = true
|
55
|
+
br
|
56
|
+
end
|
57
|
+
|
58
|
+
# Initialize batch key and read operations.
|
59
|
+
def self.ops(key, ops, opt = {})
|
60
|
+
br = BatchRead.new(key)
|
61
|
+
br.policy = create_policy(opt, BatchReadPolicy, DEFAULT_BATCH_READ_POLICY)
|
62
|
+
br.ops = ops
|
63
|
+
br.read_all_bins = false
|
64
|
+
br
|
65
|
+
end
|
66
|
+
|
67
|
+
# Optimized reference equality check to determine batch wire protocol repeat flag.
|
68
|
+
# For internal use only.
|
69
|
+
def ==(other) # :nodoc:
|
70
|
+
other && other.instance_of?(self.class) &&
|
71
|
+
@bin_names.sort == other.bin_names.sort && @ops.sort == other.ops.sort &&
|
72
|
+
@policy == other.policy && @read_all_bins == other.read_all_bins
|
73
|
+
end
|
74
|
+
|
75
|
+
DEFAULT_BATCH_READ_POLICY = BatchReadPolicy.new
|
76
|
+
|
77
|
+
# Return wire protocol size. For internal use only.
|
78
|
+
def size # :nodoc:
|
79
|
+
size = 0
|
80
|
+
size += @policy&.filter_exp&.size if @policy&.filter_exp
|
81
|
+
|
82
|
+
@bin_names&.each do |bin_name|
|
83
|
+
size += bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE
|
84
|
+
end
|
85
|
+
|
86
|
+
@ops&.each do |op|
|
87
|
+
if op.is_write?
|
88
|
+
raise AerospikeException.new(ResultCode::PARAMETER_ERROR, "Write operations not allowed in batch read")
|
89
|
+
end
|
90
|
+
size += op.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE
|
91
|
+
size += op.value.estimate_size
|
92
|
+
end
|
93
|
+
|
94
|
+
size
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,83 @@
|
|
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
|
+
# Batch key and record result.
|
20
|
+
class BatchRecord
|
21
|
+
# Key.
|
22
|
+
attr_reader :key
|
23
|
+
|
24
|
+
# Record result after batch command has completed. Will be null if record was not found
|
25
|
+
# or an error occurred. See {BatchRecord#result_code}.
|
26
|
+
attr_reader :record
|
27
|
+
|
28
|
+
# Result code for this returned record. See {ResultCode}.
|
29
|
+
# If not {ResultCode#OK}, the record will be null.
|
30
|
+
attr_accessor :result_code
|
31
|
+
|
32
|
+
# Is it possible that the write transaction may have completed even though an error
|
33
|
+
# occurred for this record. This may be the case when a client error occurs (like timeout)
|
34
|
+
# after the command was sent to the server.
|
35
|
+
attr_accessor :in_doubt
|
36
|
+
|
37
|
+
# Does this command contain a write operation. For internal use only.
|
38
|
+
attr_reader :has_write
|
39
|
+
|
40
|
+
# Constructor.
|
41
|
+
def initialize(key, result_code: ResultCode::NO_RESPONSE, in_doubt: false, has_write: false)
|
42
|
+
@key = key
|
43
|
+
@record = record
|
44
|
+
@result_code = result_code
|
45
|
+
@in_doubt = in_doubt
|
46
|
+
@has_write = has_write
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.create_policy(policy, policy_klass, default_policy = nil) # :nodoc:
|
50
|
+
case policy
|
51
|
+
when nil
|
52
|
+
default_policy || policy_klass.new
|
53
|
+
when policy_klass
|
54
|
+
policy
|
55
|
+
when Hash
|
56
|
+
policy_klass.new(policy)
|
57
|
+
else
|
58
|
+
raise TypeError, "policy should be a #{policy_klass.name} instance or a Hash"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Prepare for upcoming batch call. Reset result fields because this instance might be
|
63
|
+
# reused. For internal use only.
|
64
|
+
def prepare # :nodoc:
|
65
|
+
@record = nil
|
66
|
+
@result_code = ResultCode::NO_RESPONSE
|
67
|
+
@in_doubt = false
|
68
|
+
end
|
69
|
+
|
70
|
+
# Set record result. For internal use only.
|
71
|
+
def record=(record) # :nodoc:
|
72
|
+
@record = record
|
73
|
+
@result_code = ResultCode::OK
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set error result. For internal use only.
|
77
|
+
def set_error(result_code, in_doubt) # :nodoc:
|
78
|
+
@result_code = result_code
|
79
|
+
@in_doubt = in_doubt
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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
|
+
# Batch key and read only operations with default policy.
|
18
|
+
# Used in batch read commands where different bins are needed for each key.
|
19
|
+
|
20
|
+
module Aerospike
|
21
|
+
|
22
|
+
# Batch record results.
|
23
|
+
class BatchResults
|
24
|
+
|
25
|
+
# Record results.
|
26
|
+
attr_accessor :records
|
27
|
+
|
28
|
+
# Indicates if all records returned success.
|
29
|
+
attr_accessor :status
|
30
|
+
|
31
|
+
# Constructor.
|
32
|
+
def intialize(records, status)
|
33
|
+
@records = records
|
34
|
+
@status = status
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|