aerospike 2.9.1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -4
  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/list_operation.rb +1 -1
  9. data/lib/aerospike/cdt/map_operation.rb +1 -1
  10. data/lib/aerospike/cdt/map_order.rb +1 -1
  11. data/lib/aerospike/cdt/map_policy.rb +1 -1
  12. data/lib/aerospike/cdt/map_return_type.rb +1 -1
  13. data/lib/aerospike/cdt/map_write_mode.rb +1 -1
  14. data/lib/aerospike/client.rb +31 -17
  15. data/lib/aerospike/cluster.rb +139 -17
  16. data/lib/aerospike/cluster/partition.rb +1 -1
  17. data/lib/aerospike/cluster/partition_parser.rb +169 -0
  18. data/lib/aerospike/cluster/rack_parser.rb +117 -0
  19. data/lib/aerospike/command/admin_command.rb +1 -1
  20. data/lib/aerospike/command/batch_direct_command.rb +2 -1
  21. data/lib/aerospike/command/batch_direct_exists_command.rb +1 -1
  22. data/lib/aerospike/command/batch_direct_node.rb +3 -3
  23. data/lib/aerospike/command/batch_index_command.rb +11 -2
  24. data/lib/aerospike/command/batch_index_node.rb +2 -2
  25. data/lib/aerospike/command/batch_item.rb +1 -1
  26. data/lib/aerospike/command/command.rb +157 -11
  27. data/lib/aerospike/command/delete_command.rb +21 -5
  28. data/lib/aerospike/command/execute_command.rb +1 -1
  29. data/lib/aerospike/command/exists_command.rb +21 -5
  30. data/lib/aerospike/command/field_type.rb +3 -1
  31. data/lib/aerospike/command/multi_command.rb +55 -5
  32. data/lib/aerospike/command/operate_command.rb +6 -1
  33. data/lib/aerospike/command/read_command.rb +63 -20
  34. data/lib/aerospike/command/read_header_command.rb +18 -6
  35. data/lib/aerospike/command/roles.rb +1 -1
  36. data/lib/aerospike/command/single_command.rb +9 -3
  37. data/lib/aerospike/command/touch_command.rb +48 -4
  38. data/lib/aerospike/command/unsupported_particle_type_validator.rb +1 -1
  39. data/lib/aerospike/command/write_command.rb +13 -4
  40. data/lib/aerospike/connection/create.rb +1 -1
  41. data/lib/aerospike/features.rb +3 -1
  42. data/lib/aerospike/geo_json.rb +70 -1
  43. data/lib/aerospike/host.rb +1 -1
  44. data/lib/aerospike/info.rb +1 -1
  45. data/lib/aerospike/key.rb +1 -1
  46. data/lib/aerospike/language.rb +1 -1
  47. data/lib/aerospike/node.rb +21 -7
  48. data/lib/aerospike/node/rebalance.rb +50 -0
  49. data/lib/aerospike/node/refresh/info.rb +4 -1
  50. data/lib/aerospike/node/refresh/partitions.rb +6 -15
  51. data/lib/aerospike/node/refresh/racks.rb +47 -0
  52. data/lib/aerospike/node/refresh/reset.rb +1 -0
  53. data/lib/aerospike/node/verify/rebalance_generation.rb +43 -0
  54. data/lib/aerospike/node_validator.rb +45 -40
  55. data/lib/aerospike/operation.rb +6 -1
  56. data/lib/aerospike/policy/admin_policy.rb +1 -1
  57. data/lib/aerospike/policy/batch_policy.rb +1 -1
  58. data/lib/aerospike/policy/client_policy.rb +16 -1
  59. data/lib/aerospike/policy/commit_level.rb +1 -1
  60. data/lib/aerospike/policy/consistency_level.rb +1 -1
  61. data/lib/aerospike/policy/generation_policy.rb +1 -1
  62. data/lib/aerospike/policy/operate_policy.rb +1 -1
  63. data/lib/aerospike/policy/policy.rb +64 -2
  64. data/lib/aerospike/policy/priority.rb +1 -1
  65. data/lib/aerospike/policy/query_policy.rb +8 -1
  66. data/lib/aerospike/policy/record_bin_multiplicity.rb +1 -1
  67. data/lib/aerospike/policy/record_exists_action.rb +1 -1
  68. data/lib/aerospike/policy/replica.rb +45 -0
  69. data/lib/aerospike/policy/scan_policy.rb +8 -1
  70. data/lib/aerospike/policy/write_policy.rb +1 -1
  71. data/lib/aerospike/query/filter.rb +1 -1
  72. data/lib/aerospike/query/pred_exp.rb +192 -0
  73. data/lib/aerospike/query/pred_exp/and_or.rb +32 -0
  74. data/lib/aerospike/query/pred_exp/geo_json_value.rb +41 -0
  75. data/lib/aerospike/query/pred_exp/integer_value.rb +32 -0
  76. data/lib/aerospike/query/pred_exp/op.rb +27 -0
  77. data/lib/aerospike/query/pred_exp/regex.rb +32 -0
  78. data/lib/aerospike/query/pred_exp/regex_flags.rb +23 -0
  79. data/lib/aerospike/query/pred_exp/string_value.rb +29 -0
  80. data/lib/aerospike/query/query_command.rb +27 -1
  81. data/lib/aerospike/query/recordset.rb +5 -5
  82. data/lib/aerospike/query/scan_command.rb +1 -1
  83. data/lib/aerospike/query/statement.rb +12 -3
  84. data/lib/aerospike/query/stream_command.rb +1 -1
  85. data/lib/aerospike/record.rb +1 -1
  86. data/lib/aerospike/result_code.rb +13 -7
  87. data/lib/aerospike/socket/base.rb +4 -3
  88. data/lib/aerospike/task/execute_task.rb +1 -1
  89. data/lib/aerospike/task/index_task.rb +1 -1
  90. data/lib/aerospike/task/task.rb +1 -1
  91. data/lib/aerospike/task/udf_register_task.rb +1 -1
  92. data/lib/aerospike/task/udf_remove_task.rb +1 -1
  93. data/lib/aerospike/ttl.rb +1 -1
  94. data/lib/aerospike/udf.rb +1 -1
  95. data/lib/aerospike/user_role.rb +1 -1
  96. data/lib/aerospike/utils/buffer.rb +14 -4
  97. data/lib/aerospike/utils/packer.rb +1 -1
  98. data/lib/aerospike/utils/pool.rb +1 -1
  99. data/lib/aerospike/utils/unpacker.rb +7 -2
  100. data/lib/aerospike/value/particle_type.rb +1 -1
  101. data/lib/aerospike/value/value.rb +59 -29
  102. data/lib/aerospike/version.rb +1 -1
  103. metadata +19 -8
  104. data/lib/aerospike/cluster/partition_tokenizer_new.rb +0 -130
  105. data/lib/aerospike/cluster/partition_tokenizer_old.rb +0 -135
@@ -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.
@@ -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
@@ -0,0 +1,29 @@
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