aerospike 2.29.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +13 -9
  4. data/lib/aerospike/batch_attr.rb +292 -0
  5. data/lib/aerospike/batch_delete.rb +48 -0
  6. data/lib/aerospike/batch_read.rb +97 -0
  7. data/lib/aerospike/batch_record.rb +83 -0
  8. data/lib/aerospike/batch_results.rb +38 -0
  9. data/lib/aerospike/batch_udf.rb +76 -0
  10. data/lib/aerospike/batch_write.rb +79 -0
  11. data/lib/aerospike/cdt/bit_operation.rb +4 -5
  12. data/lib/aerospike/cdt/map_operation.rb +24 -10
  13. data/lib/aerospike/cdt/map_policy.rb +6 -3
  14. data/lib/aerospike/cdt/map_return_type.rb +8 -0
  15. data/lib/aerospike/client.rb +39 -56
  16. data/lib/aerospike/cluster.rb +50 -46
  17. data/lib/aerospike/command/batch_index_command.rb +7 -11
  18. data/lib/aerospike/command/batch_index_node.rb +3 -4
  19. data/lib/aerospike/command/batch_operate_command.rb +151 -0
  20. data/lib/aerospike/command/batch_operate_node.rb +51 -0
  21. data/lib/aerospike/command/command.rb +231 -128
  22. data/lib/aerospike/exp/exp.rb +54 -27
  23. data/lib/aerospike/exp/exp_bit.rb +24 -24
  24. data/lib/aerospike/exp/exp_hll.rb +12 -12
  25. data/lib/aerospike/exp/exp_list.rb +101 -86
  26. data/lib/aerospike/exp/exp_map.rb +118 -110
  27. data/lib/aerospike/exp/operation.rb +2 -2
  28. data/lib/aerospike/info.rb +2 -4
  29. data/lib/aerospike/node.rb +20 -3
  30. data/lib/aerospike/operation.rb +38 -0
  31. data/lib/aerospike/policy/batch_delete_policy.rb +71 -0
  32. data/lib/aerospike/policy/batch_policy.rb +53 -4
  33. data/lib/aerospike/{command/batch_direct_node.rb → policy/batch_read_policy.rb} +17 -19
  34. data/lib/aerospike/policy/batch_udf_policy.rb +75 -0
  35. data/lib/aerospike/policy/batch_write_policy.rb +105 -0
  36. data/lib/aerospike/policy/policy.rb +3 -40
  37. data/lib/aerospike/query/query_command.rb +3 -205
  38. data/lib/aerospike/query/query_executor.rb +2 -2
  39. data/lib/aerospike/query/query_partition_command.rb +4 -230
  40. data/lib/aerospike/query/scan_executor.rb +2 -2
  41. data/lib/aerospike/query/scan_partition_command.rb +3 -3
  42. data/lib/aerospike/query/server_command.rb +2 -2
  43. data/lib/aerospike/query/statement.rb +5 -21
  44. data/lib/aerospike/task/execute_task.rb +2 -2
  45. data/lib/aerospike/utils/buffer.rb +15 -15
  46. data/lib/aerospike/version.rb +1 -1
  47. data/lib/aerospike.rb +13 -12
  48. metadata +16 -14
  49. data/lib/aerospike/command/batch_direct_command.rb +0 -105
  50. data/lib/aerospike/command/batch_direct_exists_command.rb +0 -51
  51. data/lib/aerospike/query/pred_exp/and_or.rb +0 -32
  52. data/lib/aerospike/query/pred_exp/geo_json_value.rb +0 -41
  53. data/lib/aerospike/query/pred_exp/integer_value.rb +0 -32
  54. data/lib/aerospike/query/pred_exp/op.rb +0 -27
  55. data/lib/aerospike/query/pred_exp/regex.rb +0 -32
  56. data/lib/aerospike/query/pred_exp/regex_flags.rb +0 -23
  57. data/lib/aerospike/query/pred_exp/string_value.rb +0 -29
  58. data/lib/aerospike/query/pred_exp.rb +0 -192
@@ -1,105 +0,0 @@
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
- require 'aerospike/command/multi_command'
19
-
20
- module Aerospike
21
-
22
- class BatchDirectCommand < MultiCommand #:nodoc:
23
-
24
- attr_accessor :batch
25
- attr_accessor :policy
26
- attr_accessor :key_map
27
- attr_accessor :bin_names
28
- attr_accessor :results
29
- attr_accessor :read_attr
30
-
31
- def initialize(node, batch, policy, key_map, bin_names, results, read_attr)
32
- super(node)
33
-
34
- @batch = batch
35
- @policy = policy
36
- @key_map = key_map
37
- @bin_names = bin_names
38
- @results = results
39
- @read_attr = read_attr
40
- end
41
-
42
- def write_buffer
43
- # Estimate buffer size
44
- begin_cmd
45
- byte_size = batch.keys.length * DIGEST_SIZE
46
-
47
- @data_offset += batch.namespace.bytesize +
48
- FIELD_HEADER_SIZE + byte_size + FIELD_HEADER_SIZE
49
-
50
- if bin_names
51
- bin_names.each do |bin_name|
52
- estimate_operation_size_for_bin_name(bin_name)
53
- end
54
- end
55
-
56
- size_buffer
57
-
58
- operation_count = 0
59
- if bin_names
60
- operation_count = bin_names.length
61
- end
62
-
63
- write_header(policy, read_attr, 0, 2, operation_count)
64
- write_field_string(batch.namespace, Aerospike::FieldType::NAMESPACE)
65
- write_field_header(byte_size, Aerospike::FieldType::DIGEST_RIPE_ARRAY)
66
-
67
- batch.keys.each do |key|
68
- @data_offset += @data_buffer.write_binary(key.digest, @data_offset)
69
- end
70
-
71
- if bin_names
72
- bin_names.each do |bin_name|
73
- write_operation_for_bin_name(bin_name, Aerospike::Operation::READ)
74
- end
75
- end
76
-
77
- end_cmd
78
- mark_compressed(@policy)
79
- end
80
-
81
- # Parse all results in the batch. Add records to shared list.
82
- # If the record was not found, the bins will be nil.
83
- def parse_row(result_code)
84
- generation = @data_buffer.read_int32(6)
85
- expiration = @data_buffer.read_int32(10)
86
- field_count = @data_buffer.read_int16(18)
87
- op_count = @data_buffer.read_int16(20)
88
-
89
- key = parse_key(field_count)
90
-
91
- item = key_map[key.digest]
92
- if item
93
- if result_code == 0
94
- index = item.index
95
- key = item.key
96
- results[index] = parse_record(key, op_count, generation, expiration)
97
- end
98
- else
99
- Aerospike.logger.warn("Unexpected batch key returned: #{key}")
100
- end
101
- end
102
-
103
- end # class
104
-
105
- end # module
@@ -1,51 +0,0 @@
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
- require 'aerospike/command/batch_direct_command'
19
-
20
- module Aerospike
21
-
22
- class BatchDirectExistsCommand < BatchDirectCommand #:nodoc:
23
-
24
- def initialize(node, batch, policy, key_map, results)
25
- super(node, batch, policy, key_map, nil, results, INFO1_READ | INFO1_NOBINDATA)
26
- end
27
-
28
- # Parse all results in the batch. Add records to shared list.
29
- # If the record was not found, the bins will be nil.
30
- def parse_row(result_code)
31
- field_count = @data_buffer.read_int16(18)
32
- op_count = @data_buffer.read_int16(20)
33
-
34
- if op_count > 0
35
- raise Aerospike::Exceptions::Parse.new('Received bins that were not requested!')
36
- end
37
-
38
- key = parse_key(field_count)
39
- item = key_map[key.digest]
40
-
41
- if item
42
- index = item.index
43
- results[index] = (result_code == 0)
44
- else
45
- Aerospike::logger.debug("Unexpected batch key returned: #{key.namespace}, #{key.digest}")
46
- end
47
- end
48
-
49
- end # class
50
-
51
- end # module
@@ -1,32 +0,0 @@
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
@@ -1,41 +0,0 @@
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
@@ -1,32 +0,0 @@
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
@@ -1,27 +0,0 @@
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
@@ -1,32 +0,0 @@
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
@@ -1,23 +0,0 @@
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
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Aerospike
4
- class PredExp
5
- class StringValue < PredExp
6
- def initialize(value, type)
7
- @value = value
8
- @type = type
9
- end
10
-
11
- def estimate_size
12
- @value.bytesize + 6
13
- end
14
-
15
- def write(buffer, offset)
16
- buffer.write_int16(@type, offset)
17
- offset += 2
18
-
19
- buffer.write_int32(@value.bytesize, offset)
20
- offset += 4
21
-
22
- len = buffer.write_binary(@value, offset)
23
- offset += len
24
-
25
- offset
26
- end
27
- end
28
- end
29
- end
@@ -1,192 +0,0 @@
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