aerospike 3.0.0 → 4.0.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 +21 -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 +6 -10
- 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 +101 -87
- 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 +118 -121
- 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/{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/server_command.rb +1 -0
- data/lib/aerospike/query/statement.rb +5 -21
- 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
data/lib/aerospike/exp/exp.rb
CHANGED
@@ -96,7 +96,7 @@ module Aerospike
|
|
96
96
|
end
|
97
97
|
|
98
98
|
# Create expression that returns if the primary key is stored in the record meta data
|
99
|
-
# as a boolean expression. This would occur when {
|
99
|
+
# as a boolean expression. This would occur when {Policy#send_key}
|
100
100
|
# is true on record write. This expression usually evaluates quickly because record
|
101
101
|
# meta data is cached in memory.
|
102
102
|
#
|
@@ -214,7 +214,7 @@ module Aerospike
|
|
214
214
|
end
|
215
215
|
|
216
216
|
# Create expression that returns bin's integer particle type::
|
217
|
-
# See {
|
217
|
+
# See {ParticleType}.
|
218
218
|
#
|
219
219
|
# ==== Examples
|
220
220
|
# # Bin "a" particle type is a list
|
@@ -225,8 +225,8 @@ module Aerospike
|
|
225
225
|
|
226
226
|
# Create expression that returns the record size. This expression usually evaluates
|
227
227
|
# quickly because record meta data is cached in memory.
|
228
|
-
# Requires server version 7.0+. This expression replaces {
|
229
|
-
# {
|
228
|
+
# Requires server version 7.0+. This expression replaces {#deviceSize()} and
|
229
|
+
# {#memorySize()} since those older expressions are equivalent on server version 7.0+.
|
230
230
|
#
|
231
231
|
# {@code
|
232
232
|
# // Record size >= 100 KB
|
@@ -347,7 +347,7 @@ module Aerospike
|
|
347
347
|
# Exp.regex_compare("prefix.*suffix", RegexFlags.ICASE | RegexFlags.NEWLINE, Exp.str_bin("a"))
|
348
348
|
#
|
349
349
|
# @param regex regular expression string
|
350
|
-
# @param flags regular expression bit flags. See {
|
350
|
+
# @param flags regular expression bit flags. See {Exp::RegexFlags}
|
351
351
|
# @param bin string bin or string value expression
|
352
352
|
def self.regex_compare(regex, flags, bin)
|
353
353
|
Regex.new(bin, regex, flags)
|
@@ -424,6 +424,16 @@ module Aerospike
|
|
424
424
|
Nil.new
|
425
425
|
end
|
426
426
|
|
427
|
+
# Create Infinity value.
|
428
|
+
def self.infinity_val
|
429
|
+
Infinity.new
|
430
|
+
end
|
431
|
+
|
432
|
+
# Create Wildcard value.
|
433
|
+
def self.wildcard_val
|
434
|
+
Wildcard.new
|
435
|
+
end
|
436
|
+
|
427
437
|
#--------------------------------------------------
|
428
438
|
# Boolean Operator
|
429
439
|
#--------------------------------------------------
|
@@ -873,7 +883,7 @@ module Aerospike
|
|
873
883
|
#
|
874
884
|
# ==== Examples
|
875
885
|
# Args Format: <def1>, <def2>, ..., <exp>
|
876
|
-
# def: {
|
886
|
+
# def: {Exp#def(String, Exp)}
|
877
887
|
# exp: Scoped expression
|
878
888
|
#
|
879
889
|
# ==== Examples
|
@@ -887,7 +897,7 @@ module Aerospike
|
|
887
897
|
Let.new(exps)
|
888
898
|
end
|
889
899
|
|
890
|
-
# Assign variable to a {
|
900
|
+
# Assign variable to a {Exp#let(Exp...)} expression that can be accessed later.
|
891
901
|
# Requires server version 5.6.0+.
|
892
902
|
#
|
893
903
|
# ==== Examples
|
@@ -914,27 +924,14 @@ module Aerospike
|
|
914
924
|
def self.var(name)
|
915
925
|
CmdStr.new(VAR, name)
|
916
926
|
end
|
917
|
-
#--------------------------------------------------
|
918
|
-
# Build
|
919
|
-
#--------------------------------------------------
|
920
|
-
|
921
|
-
#
|
922
|
-
# Create final expression that contains packed byte instructions used in the wire protocol.
|
923
|
-
|
924
|
-
def self.build(exp)
|
925
|
-
Packer.use do |packer|
|
926
|
-
exp.pack(packer)
|
927
|
-
@bytes = packer.bytes
|
928
|
-
end
|
929
|
-
end
|
930
927
|
|
931
928
|
#--------------------------------------------------
|
932
929
|
# Miscellaneous
|
933
930
|
#--------------------------------------------------
|
934
931
|
|
935
932
|
# Create unknown value. Used to intentionally fail an expression.
|
936
|
-
# The failure can be ignored with {
|
937
|
-
# or {
|
933
|
+
# The failure can be ignored with {Exp::WriteFlags#EVAL_NO_FAIL}
|
934
|
+
# or {Exp::ReadFlags#EVAL_NO_FAIL}.
|
938
935
|
# Requires server version 5.6.0+.
|
939
936
|
#
|
940
937
|
# ==== Examples
|
@@ -949,7 +946,6 @@ module Aerospike
|
|
949
946
|
Cmd.new(UNKNOWN)
|
950
947
|
end
|
951
948
|
|
952
|
-
|
953
949
|
# # Merge precompiled expression into a new expression tree.
|
954
950
|
# # Useful for storing common precompiled expressions and then reusing
|
955
951
|
# # these expressions as part of a greater expression.
|
@@ -1080,10 +1076,7 @@ module Aerospike
|
|
1080
1076
|
|
1081
1077
|
# For internal use only.
|
1082
1078
|
class Module < Exp
|
1083
|
-
attr_reader :bin
|
1084
|
-
attr_reader :bytes
|
1085
|
-
attr_reader :ret_type
|
1086
|
-
attr_reader :module
|
1079
|
+
attr_reader :bin, :bytes, :ret_type, :module
|
1087
1080
|
|
1088
1081
|
def initialize(bin, bytes, ret_type, modul)
|
1089
1082
|
@bin = bin
|
@@ -1104,8 +1097,7 @@ module Aerospike
|
|
1104
1097
|
end
|
1105
1098
|
|
1106
1099
|
class Bin < Exp
|
1107
|
-
attr_reader :name
|
1108
|
-
attr_reader :type
|
1100
|
+
attr_reader :name, :type
|
1109
1101
|
|
1110
1102
|
def initialize(name, type)
|
1111
1103
|
@name = name
|
@@ -1121,9 +1113,7 @@ module Aerospike
|
|
1121
1113
|
end
|
1122
1114
|
|
1123
1115
|
class Regex < Exp
|
1124
|
-
attr_reader :bin
|
1125
|
-
attr_reader :regex
|
1126
|
-
attr_reader :flags
|
1116
|
+
attr_reader :bin, :regex, :flags
|
1127
1117
|
|
1128
1118
|
def initialize(bin, regex, flags)
|
1129
1119
|
@bin = bin
|
@@ -1149,7 +1139,7 @@ module Aerospike
|
|
1149
1139
|
|
1150
1140
|
def pack(packer)
|
1151
1141
|
# Let wire format: LET <defname1>, <defexp1>, <defname2>, <defexp2>, ..., <scope exp>
|
1152
|
-
count = (@exps.length - 1) * 2 + 2
|
1142
|
+
count = ((@exps.length - 1) * 2) + 2
|
1153
1143
|
packer.write_array_header(count)
|
1154
1144
|
packer.write(LET)
|
1155
1145
|
|
@@ -1160,8 +1150,7 @@ module Aerospike
|
|
1160
1150
|
end
|
1161
1151
|
|
1162
1152
|
class Def < Exp
|
1163
|
-
attr_reader :name
|
1164
|
-
attr_reader :exp
|
1153
|
+
attr_reader :name, :exp
|
1165
1154
|
|
1166
1155
|
def initialize(name, exp)
|
1167
1156
|
@name = name
|
@@ -1175,8 +1164,7 @@ module Aerospike
|
|
1175
1164
|
end
|
1176
1165
|
|
1177
1166
|
class CmdExp < Exp
|
1178
|
-
attr_reader :exps
|
1179
|
-
attr_reader :cmd
|
1167
|
+
attr_reader :exps, :cmd
|
1180
1168
|
|
1181
1169
|
def initialize(cmd, *exps)
|
1182
1170
|
@exps = exps
|
@@ -1193,8 +1181,7 @@ module Aerospike
|
|
1193
1181
|
end
|
1194
1182
|
|
1195
1183
|
class CmdInt < Exp
|
1196
|
-
attr_reader :cmd
|
1197
|
-
attr_reader :val
|
1184
|
+
attr_reader :cmd, :val
|
1198
1185
|
|
1199
1186
|
def initialize(cmd, val)
|
1200
1187
|
@cmd = cmd
|
@@ -1209,8 +1196,7 @@ module Aerospike
|
|
1209
1196
|
end
|
1210
1197
|
|
1211
1198
|
class CmdStr < Exp
|
1212
|
-
attr_reader :str
|
1213
|
-
attr_reader :cmd
|
1199
|
+
attr_reader :str, :cmd
|
1214
1200
|
|
1215
1201
|
def initialize(cmd, str)
|
1216
1202
|
@str = str
|
@@ -1343,6 +1329,18 @@ module Aerospike
|
|
1343
1329
|
end
|
1344
1330
|
end
|
1345
1331
|
|
1332
|
+
class Infinity < Exp
|
1333
|
+
def pack(packer)
|
1334
|
+
InfinityValue.new.pack(packer)
|
1335
|
+
end
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
class Wildcard < Exp
|
1339
|
+
def pack(packer)
|
1340
|
+
WildcardValue.new.pack(packer)
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
|
1346
1344
|
class ExpBytes < Exp
|
1347
1345
|
attr_reader :bytes
|
1348
1346
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# the License.
|
16
16
|
|
17
17
|
module Aerospike
|
18
|
-
# Bit expression generator. See {
|
18
|
+
# Bit expression generator. See {Exp}.
|
19
19
|
#
|
20
20
|
# The bin expression argument in these methods can be a reference to a bin or the
|
21
21
|
# result of another expression. Expressions that modify bin values are only used
|
@@ -42,7 +42,7 @@ module Aerospike
|
|
42
42
|
# Exp.val(2))
|
43
43
|
def self.resize(byte_size, resize_flags, bin, policy: CDT::BitPolicy::DEFAULT)
|
44
44
|
bytes = Exp.pack(nil, RESIZE, byte_size, policy.flags, resize_flags)
|
45
|
-
|
45
|
+
add_write(bin, bytes)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Create expression that inserts value bytes into byte[] bin at byte_offset and returns byte[].
|
@@ -60,7 +60,7 @@ module Aerospike
|
|
60
60
|
# Exp.val(2))
|
61
61
|
def self.insert(byte_offset, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
62
62
|
bytes = Exp.pack(nil, INSERT, byte_offset, value, policy.flags)
|
63
|
-
|
63
|
+
add_write(bin, bytes)
|
64
64
|
end
|
65
65
|
|
66
66
|
# Create expression that removes bytes from byte[] bin at byte_offset for byte_size and returns byte[].
|
@@ -78,7 +78,7 @@ module Aerospike
|
|
78
78
|
# Exp.val(2))
|
79
79
|
def self.remove(byte_offset, byte_size, bin, policy: CDT::BitPolicy::DEFAULT)
|
80
80
|
bytes = Exp.pack(nil, REMOVE, byte_offset, byte_size, policy.flags)
|
81
|
-
|
81
|
+
add_write(bin, bytes)
|
82
82
|
end
|
83
83
|
|
84
84
|
# Create expression that sets value on byte[] bin at bit_offset for bit_size and returns byte[].
|
@@ -97,7 +97,7 @@ module Aerospike
|
|
97
97
|
# Exp.val(2))
|
98
98
|
def self.set(bit_offset, bit_size, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
99
99
|
bytes = Exp.pack(nil, SET, bit_offset, bit_size, value, policy.flags)
|
100
|
-
|
100
|
+
add_write(bin, bytes)
|
101
101
|
end
|
102
102
|
|
103
103
|
# Create expression that performs bitwise "or" on value and byte[] bin at bit_offset for bit_size
|
@@ -111,7 +111,7 @@ module Aerospike
|
|
111
111
|
#
|
112
112
|
def self.or(bit_offset, bit_size, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
113
113
|
bytes = Exp.pack(nil, OR, bit_offset, bit_size, value, policy.flags)
|
114
|
-
|
114
|
+
add_write(bin, bytes)
|
115
115
|
end
|
116
116
|
|
117
117
|
# Create expression that performs bitwise "xor" on value and byte[] bin at bit_offset for bit_size
|
@@ -125,7 +125,7 @@ module Aerospike
|
|
125
125
|
#
|
126
126
|
def self.xor(bit_offset, bit_size, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
127
127
|
bytes = Exp.pack(nil, XOR, bit_offset, bit_size, value, policy.flags)
|
128
|
-
|
128
|
+
add_write(bin, bytes)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Create expression that performs bitwise "and" on value and byte[] bin at bit_offset for bit_size
|
@@ -139,7 +139,7 @@ module Aerospike
|
|
139
139
|
#
|
140
140
|
def self.and(bit_offset, bit_size, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
141
141
|
bytes = Exp.pack(nil, AND, bit_offset, bit_size, value, policy.flags)
|
142
|
-
|
142
|
+
add_write(bin, bytes)
|
143
143
|
end
|
144
144
|
|
145
145
|
# Create expression that negates byte[] bin starting at bit_offset for bit_size and returns byte[].
|
@@ -151,7 +151,7 @@ module Aerospike
|
|
151
151
|
#
|
152
152
|
def self.not(bit_offset, bit_size, bin, policy: CDT::BitPolicy::DEFAULT)
|
153
153
|
bytes = Exp.pack(nil, NOT, bit_offset, bit_size, policy.flags)
|
154
|
-
|
154
|
+
add_write(bin, bytes)
|
155
155
|
end
|
156
156
|
|
157
157
|
# Create expression that shifts left byte[] bin starting at bit_offset for bit_size and returns byte[].
|
@@ -164,7 +164,7 @@ module Aerospike
|
|
164
164
|
#
|
165
165
|
def self.lshift(bit_offset, bit_size, shift, bin, policy: CDT::BitPolicy::DEFAULT)
|
166
166
|
bytes = Exp.pack(nil, LSHIFT, bit_offset, bit_size, shift, policy.flags)
|
167
|
-
|
167
|
+
add_write(bin, bytes)
|
168
168
|
end
|
169
169
|
|
170
170
|
# Create expression that shifts right byte[] bin starting at bit_offset for bit_size and returns byte[].
|
@@ -177,12 +177,12 @@ module Aerospike
|
|
177
177
|
#
|
178
178
|
def self.rshift(bit_offset, bit_size, shift, bin, policy: CDT::BitPolicy::DEFAULT)
|
179
179
|
bytes = Exp.pack(nil, RSHIFT, bit_offset, bit_size, shift, policy.flags)
|
180
|
-
|
180
|
+
add_write(bin, bytes)
|
181
181
|
end
|
182
182
|
|
183
183
|
# Create expression that adds value to byte[] bin starting at bit_offset for bit_size and returns byte[].
|
184
184
|
# BitSize must be <= 64. Signed indicates if bits should be treated as a signed number.
|
185
|
-
# If add overflows/underflows, {
|
185
|
+
# If add overflows/underflows, {BitOverflowAction} is used.
|
186
186
|
#
|
187
187
|
# bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
|
188
188
|
# bit_offset = 24
|
@@ -192,13 +192,13 @@ module Aerospike
|
|
192
192
|
# bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b10000101]
|
193
193
|
#
|
194
194
|
def self.add(bit_offset, bit_size, value, signed, bit_overflow_action, bin, policy: CDT::BitPolicy::DEFAULT)
|
195
|
-
bytes =
|
196
|
-
|
195
|
+
bytes = pack_math(ADD, policy, bit_offset, bit_size, value, signed, bit_overflow_action)
|
196
|
+
add_write(bin, bytes)
|
197
197
|
end
|
198
198
|
|
199
199
|
# Create expression that subtracts value from byte[] bin starting at bit_offset for bit_size and returns byte[].
|
200
200
|
# BitSize must be <= 64. Signed indicates if bits should be treated as a signed number.
|
201
|
-
# If add overflows/underflows, {
|
201
|
+
# If add overflows/underflows, {BitOverflowAction} is used.
|
202
202
|
#
|
203
203
|
# bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
|
204
204
|
# bit_offset = 24
|
@@ -208,8 +208,8 @@ module Aerospike
|
|
208
208
|
# bin result = [0b00000001, 0b01000010, 0b00000011, 0b0000011, 0b10000101]
|
209
209
|
#
|
210
210
|
def self.subtract(bit_offset, bit_size, value, signed, bit_overflow_action, bin, policy: CDT::BitPolicy::DEFAULT)
|
211
|
-
bytes =
|
212
|
-
|
211
|
+
bytes = pack_math(SUBTRACT, policy, bit_offset, bit_size, value, signed, bit_overflow_action)
|
212
|
+
add_write(bin, bytes)
|
213
213
|
end
|
214
214
|
|
215
215
|
# Create expression that sets value to byte[] bin starting at bit_offset for bit_size and returns byte[].
|
@@ -223,7 +223,7 @@ module Aerospike
|
|
223
223
|
#
|
224
224
|
def self.set_int(bit_offset, bit_size, value, bin, policy: CDT::BitPolicy::DEFAULT)
|
225
225
|
bytes = Exp.pack(nil, SET_INT, bit_offset, bit_size, value, policy.flags)
|
226
|
-
|
226
|
+
add_write(bin, bytes)
|
227
227
|
end
|
228
228
|
|
229
229
|
# Create expression that returns bits from byte[] bin starting at bit_offset for bit_size.
|
@@ -240,7 +240,7 @@ module Aerospike
|
|
240
240
|
# Exp.val(new byte[] {(byte)0b10000000}))
|
241
241
|
def self.get(bit_offset, bit_size, bin)
|
242
242
|
bytes = Exp.pack(nil, GET, bit_offset, bit_size)
|
243
|
-
|
243
|
+
add_read(bin, bytes, Exp::Type::BLOB)
|
244
244
|
end
|
245
245
|
|
246
246
|
# Create expression that returns integer count of set bits from byte[] bin starting at
|
@@ -256,7 +256,7 @@ module Aerospike
|
|
256
256
|
# Exp.le(BitExp.count(Exp.val(0), Exp.val(5), Exp.blobBin("a")), Exp.val(2))
|
257
257
|
def self.count(bit_offset, bit_size, bin)
|
258
258
|
bytes = Exp.pack(nil, COUNT, bit_offset, bit_size)
|
259
|
-
|
259
|
+
add_read(bin, bytes, Exp::Type::INT)
|
260
260
|
end
|
261
261
|
|
262
262
|
# Create expression that returns integer bit offset of the first specified value bit in byte[] bin
|
@@ -278,7 +278,7 @@ module Aerospike
|
|
278
278
|
# @param bin bin or blob value expression
|
279
279
|
def self.lscan(bit_offset, bit_size, value, bin)
|
280
280
|
bytes = Exp.pack(nil, LSCAN, bit_offset, bit_size, value)
|
281
|
-
|
281
|
+
add_read(bin, bytes, Exp::Type::INT)
|
282
282
|
end
|
283
283
|
|
284
284
|
# Create expression that returns integer bit offset of the last specified value bit in byte[] bin
|
@@ -301,7 +301,7 @@ module Aerospike
|
|
301
301
|
# @param bin bin or blob value expression
|
302
302
|
def self.rscan(bit_offset, bit_size, value, bin)
|
303
303
|
bytes = Exp.pack(nil, RSCAN, bit_offset, bit_size, value)
|
304
|
-
|
304
|
+
add_read(bin, bytes, Exp::Type::INT)
|
305
305
|
end
|
306
306
|
|
307
307
|
# Create expression that returns integer from byte[] bin starting at bit_offset for bit_size.
|
@@ -317,8 +317,8 @@ module Aerospike
|
|
317
317
|
# # getInt(a) == 16899
|
318
318
|
# Exp.eq(BitExp.getInt(Exp.val(8), Exp.val(16), false, Exp.blobBin("a")), Exp.val(16899))
|
319
319
|
def self.get_int(bit_offset, bit_size, signed, bin)
|
320
|
-
bytes =
|
321
|
-
|
320
|
+
bytes = pack_get_int(bit_offset, bit_size, signed)
|
321
|
+
add_read(bin, bytes, Exp::Type::INT)
|
322
322
|
end
|
323
323
|
|
324
324
|
private
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# the License.
|
16
16
|
|
17
17
|
module Aerospike
|
18
|
-
# HyperLogLog (HLL) expression generator. See {
|
18
|
+
# HyperLogLog (HLL) expression generator. See {Exp}.
|
19
19
|
#
|
20
20
|
# The bin expression argument in these methods can be a reference to a bin or the
|
21
21
|
# result of another expression. Expressions that modify bin values are only used
|
@@ -25,14 +25,14 @@ module Aerospike
|
|
25
25
|
|
26
26
|
# Create expression that creates a new HLL or resets an existing HLL with minhash bits.
|
27
27
|
#
|
28
|
-
# @param policy write policy, use {
|
28
|
+
# @param policy write policy, use {HLLPolicy#Default} for default
|
29
29
|
# @param index_bit_count number of index bits. Must be between 4 and 16 inclusive.
|
30
30
|
# @param min_hash_bit_count number of min hash bits. Must be between 4 and 51 inclusive.
|
31
31
|
# Also, index_bit_count + min_hash_bit_count must be <= 64. Optional.
|
32
32
|
# @param bin HLL bin or value expression
|
33
33
|
def self.init(index_bit_count, bin, min_hash_bit_count: Exp.int_val(-1), policy: CDT::HLLPolicy::DEFAULT)
|
34
34
|
bytes = Exp.pack(nil, INIT, index_bit_count, min_hash_bit_count, policy.flags)
|
35
|
-
|
35
|
+
add_write(bin, bytes)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Create expression that adds values to a HLL set and returns HLL set. If HLL bin does not
|
@@ -45,7 +45,7 @@ module Aerospike
|
|
45
45
|
# HLLExp.add(HLLPolicy.Default, Exp.val(list), Exp.val(10), Exp.val(20), Exp.hllBin("a"))),
|
46
46
|
# Exp.val(7))
|
47
47
|
#
|
48
|
-
# @param policy write policy, use {
|
48
|
+
# @param policy write policy, use {HLLPolicy#Default} for default
|
49
49
|
# @param list list bin or value expression of values to be added
|
50
50
|
# @param index_bit_count number of index bits expression. Must be between 4 and 16 inclusive.
|
51
51
|
# @param min_hash_bit_count number of min hash bits expression. Must be between 4 and 51 inclusive.
|
@@ -53,7 +53,7 @@ module Aerospike
|
|
53
53
|
# @param bin HLL bin or value expression
|
54
54
|
def self.add(list, bin, policy: CDT::HLLPolicy::DEFAULT, index_bit_count: Exp.val(-1), min_hash_bit_count: Exp.val(-1))
|
55
55
|
bytes = Exp.pack(nil, ADD, list, index_bit_count, min_hash_bit_count, policy.flags)
|
56
|
-
|
56
|
+
add_write(bin, bytes)
|
57
57
|
end
|
58
58
|
|
59
59
|
# Create expression that returns estimated number of elements in the HLL bin.
|
@@ -63,7 +63,7 @@ module Aerospike
|
|
63
63
|
# Exp.gt(HLLExp.getCount(Exp.hllBin("a")), Exp.val(7))
|
64
64
|
def self.get_count(bin)
|
65
65
|
bytes = Exp.pack(nil, COUNT)
|
66
|
-
|
66
|
+
add_read(bin, bytes, Exp::Type::INT)
|
67
67
|
end
|
68
68
|
|
69
69
|
# Create expression that returns a HLL object that is the union of all specified HLL objects
|
@@ -77,7 +77,7 @@ module Aerospike
|
|
77
77
|
# HLLExp.getUnion(Exp.val(list), Exp.hllBin("b"))
|
78
78
|
def self.get_union(list, bin)
|
79
79
|
bytes = Exp.pack(nil, UNION, list)
|
80
|
-
|
80
|
+
add_read(bin, bytes, Exp::Type::HLL)
|
81
81
|
end
|
82
82
|
|
83
83
|
# Create expression that returns estimated number of elements that would be contained by
|
@@ -91,7 +91,7 @@ module Aerospike
|
|
91
91
|
# HLLExp.getUnionCount(Exp.val(list), Exp.hllBin("b"))
|
92
92
|
def self.get_union_count(list, bin)
|
93
93
|
bytes = Exp.pack(nil, UNION_COUNT, list)
|
94
|
-
|
94
|
+
add_read(bin, bytes, Exp::Type::INT)
|
95
95
|
end
|
96
96
|
|
97
97
|
# Create expression that returns estimated number of elements that would be contained by
|
@@ -105,7 +105,7 @@ module Aerospike
|
|
105
105
|
# HLLExp.getIntersectCount(Exp.val(list), Exp.hllBin("b"))
|
106
106
|
def self.get_intersect_count(list, bin)
|
107
107
|
bytes = Exp.pack(nil, INTERSECT_COUNT, list)
|
108
|
-
|
108
|
+
add_read(bin, bytes, Exp::Type::INT)
|
109
109
|
end
|
110
110
|
|
111
111
|
# Create expression that returns estimated similarity of these HLL objects as a
|
@@ -116,7 +116,7 @@ module Aerospike
|
|
116
116
|
# Exp.ge(HLLExp.getSimilarity(Exp.hllBin("a"), Exp.hllBin("b")), Exp.val(0.75))
|
117
117
|
def self.get_similarity(list, bin)
|
118
118
|
bytes = Exp.pack(nil, SIMILARITY, list)
|
119
|
-
|
119
|
+
add_read(bin, bytes, Exp::Type::FLOAT)
|
120
120
|
end
|
121
121
|
|
122
122
|
# Create expression that returns index_bit_count and min_hash_bit_count used to create HLL bin
|
@@ -130,7 +130,7 @@ module Aerospike
|
|
130
130
|
# Exp.val(10))
|
131
131
|
def self.describe(bin)
|
132
132
|
bytes = Exp.pack(nil, DESCRIBE)
|
133
|
-
|
133
|
+
add_read(bin, bytes, Exp::Type::LIST)
|
134
134
|
end
|
135
135
|
|
136
136
|
# Create expression that returns one if HLL bin may contain all items in the list.
|
@@ -142,7 +142,7 @@ module Aerospike
|
|
142
142
|
# Exp.eq(HLLExp.mayContain(Exp.val(list), Exp.hllBin("a")), Exp.val(1))
|
143
143
|
def self.may_contain(list, bin)
|
144
144
|
bytes = Exp.pack(nil, MAY_CONTAIN, list)
|
145
|
-
|
145
|
+
add_read(bin, bytes, Exp::Type::INT)
|
146
146
|
end
|
147
147
|
|
148
148
|
private
|