aerospike 2.24.0 → 2.26.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 +27 -0
- data/lib/aerospike/cdt/context.rb +136 -69
- data/lib/aerospike/cdt/map_policy.rb +16 -2
- data/lib/aerospike/cdt/map_return_type.rb +9 -1
- data/lib/aerospike/client.rb +30 -32
- data/lib/aerospike/command/command.rb +104 -98
- data/lib/aerospike/command/operate_args.rb +99 -0
- data/lib/aerospike/command/operate_command.rb +6 -11
- data/lib/aerospike/exp/exp.rb +401 -334
- data/lib/aerospike/exp/exp_bit.rb +388 -0
- data/lib/aerospike/exp/exp_hll.rb +169 -0
- data/lib/aerospike/exp/exp_list.rb +403 -0
- data/lib/aerospike/exp/exp_map.rb +493 -0
- data/lib/aerospike/exp/operation.rb +56 -0
- data/lib/aerospike/features.rb +13 -0
- data/lib/aerospike/operation.rb +20 -22
- data/lib/aerospike/policy/policy.rb +25 -12
- data/lib/aerospike/query/filter.rb +44 -32
- data/lib/aerospike/query/query_executor.rb +7 -9
- data/lib/aerospike/query/query_partition_command.rb +32 -31
- data/lib/aerospike/query/recordset.rb +9 -9
- data/lib/aerospike/query/scan_executor.rb +7 -5
- data/lib/aerospike/task/execute_task.rb +17 -14
- data/lib/aerospike/utils/buffer.rb +46 -38
- data/lib/aerospike/utils/packer.rb +7 -6
- data/lib/aerospike/value/value.rb +21 -51
- data/lib/aerospike/version.rb +1 -1
- data/lib/aerospike.rb +156 -148
- metadata +8 -2
data/lib/aerospike/exp/exp.rb
CHANGED
@@ -17,8 +17,26 @@
|
|
17
17
|
module Aerospike
|
18
18
|
class Exp
|
19
19
|
|
20
|
+
# Regex bit flags
|
21
|
+
module RegexFlags
|
22
|
+
# Regex defaults
|
23
|
+
NONE = 0
|
24
|
+
|
25
|
+
# Use POSIX Extended Regular Expression syntax when interpreting regex.
|
26
|
+
EXTENDED = 1
|
27
|
+
|
28
|
+
# Do not differentiate case.
|
29
|
+
ICASE = 2
|
30
|
+
|
31
|
+
# Do not report position of matches.
|
32
|
+
NOSUB = 4
|
33
|
+
|
34
|
+
# Match-any-character operators don't match a newline.
|
35
|
+
NEWLINE = 8
|
36
|
+
end
|
37
|
+
|
20
38
|
# Expression type.
|
21
|
-
module Type
|
39
|
+
module Type #:nodoc:
|
22
40
|
NIL = 0
|
23
41
|
BOOL = 1
|
24
42
|
INT = 2
|
@@ -31,6 +49,7 @@ module Aerospike
|
|
31
49
|
HLL = 9
|
32
50
|
end # module type
|
33
51
|
|
52
|
+
# Expression write flags.
|
34
53
|
module WriteFlags
|
35
54
|
# Default. Allow create or update.
|
36
55
|
DEFAULT = 0
|
@@ -58,6 +77,7 @@ module Aerospike
|
|
58
77
|
EVAL_NO_FAIL = 16
|
59
78
|
end # module WriteFlags
|
60
79
|
|
80
|
+
# Expression write flags.
|
61
81
|
module ReadFlags
|
62
82
|
# Default.
|
63
83
|
DEFAULT = 0
|
@@ -70,13 +90,13 @@ module Aerospike
|
|
70
90
|
#
|
71
91
|
# ==== Examples
|
72
92
|
# # Integer record key >= 100000
|
73
|
-
# Exp.ge(Exp.key(Type::INT), Exp.
|
93
|
+
# Exp.ge(Exp.key(Type::INT), Exp.int_val(100000))
|
74
94
|
def self.key(type)
|
75
|
-
|
95
|
+
CmdInt.new(KEY, type)
|
76
96
|
end
|
77
97
|
|
78
98
|
# Create expression that returns if the primary key is stored in the record meta data
|
79
|
-
# as a boolean expression. This would occur when {@link
|
99
|
+
# as a boolean expression. This would occur when {@link Policy#send_key}
|
80
100
|
# is true on record write. This expression usually evaluates quickly because record
|
81
101
|
# meta data is cached in memory.
|
82
102
|
#
|
@@ -84,7 +104,7 @@ module Aerospike
|
|
84
104
|
# # Key exists in record meta data
|
85
105
|
# Exp.key_exists
|
86
106
|
def self.key_exists
|
87
|
-
|
107
|
+
Cmd.new(KEY_EXISTS)
|
88
108
|
end
|
89
109
|
|
90
110
|
#--------------------------------------------------
|
@@ -94,85 +114,85 @@ module Aerospike
|
|
94
114
|
# Create bin expression of specified type.
|
95
115
|
#
|
96
116
|
# ==== Examples
|
97
|
-
#
|
98
|
-
#
|
117
|
+
# # String bin "a" == "views"
|
118
|
+
# Exp.eq(Exp.bin("a", Type::STRING), Exp.str_val("views"))
|
99
119
|
def self.bin(name, type)
|
100
|
-
|
120
|
+
Bin.new(name, type)
|
101
121
|
end
|
102
122
|
|
103
123
|
# Create 64 bit integer bin expression.
|
104
124
|
#
|
105
125
|
# ==== Examples
|
106
|
-
#
|
107
|
-
#
|
126
|
+
# # Integer bin "a" == 200
|
127
|
+
# Exp.eq(Exp.int_bin("a"), Exp.val(200))
|
108
128
|
def self.int_bin(name)
|
109
|
-
|
129
|
+
Bin.new(name, Type::INT)
|
110
130
|
end
|
111
131
|
|
112
132
|
# Create 64 bit float bin expression.
|
113
133
|
#
|
114
134
|
# ==== Examples
|
115
|
-
#
|
116
|
-
#
|
135
|
+
# # Float bin "a" >= 1.5
|
136
|
+
# Exp.ge(Exp.float_bin("a"), Exp.int_val(1.5))
|
117
137
|
def self.float_bin(name)
|
118
|
-
|
138
|
+
Bin.new(name, Type::FLOAT)
|
119
139
|
end
|
120
140
|
|
121
141
|
# Create string bin expression.
|
122
142
|
#
|
123
143
|
# ==== Examples
|
124
|
-
#
|
125
|
-
#
|
126
|
-
def self.
|
127
|
-
|
144
|
+
# # String bin "a" == "views"
|
145
|
+
# Exp.eq(Exp.str_bin("a"), Exp.str_val("views"))
|
146
|
+
def self.str_bin(name)
|
147
|
+
Bin.new(name, Type::STRING)
|
128
148
|
end
|
129
149
|
|
130
150
|
# Create boolean bin expression.
|
131
151
|
#
|
132
152
|
# ==== Examples
|
133
|
-
#
|
134
|
-
#
|
153
|
+
# # Boolean bin "a" == true
|
154
|
+
# Exp.eq(Exp.bool_bin("a"), Exp.val(true))
|
135
155
|
def self.bool_bin(name)
|
136
|
-
|
156
|
+
Bin.new(name, Type::BOOL)
|
137
157
|
end
|
138
158
|
|
139
159
|
# Create bin expression.
|
140
160
|
#
|
141
161
|
# ==== Examples
|
142
|
-
#
|
143
|
-
#
|
162
|
+
# # Blob bin "a" == [1,2,3]
|
163
|
+
# Exp.eq(Exp.blob_bin("a"), Exp.val(new {1, 2, 3}))
|
144
164
|
def self.blob_bin(name)
|
145
|
-
|
165
|
+
Bin.new(name, Type::BLOB)
|
146
166
|
end
|
147
167
|
|
148
168
|
# Create geospatial bin expression.
|
149
169
|
#
|
150
170
|
# ==== Examples
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
171
|
+
# # Geo bin "a" == region
|
172
|
+
# String region = "{ \"type\": \"AeroCircle\", \"coordinates\": [[-122.0, 37.5], 50000.0] }"
|
173
|
+
# Exp.geo_compare(Exp.geo_bin("loc"), Exp.geo(region))
|
154
174
|
def self.geo_bin(name)
|
155
|
-
|
175
|
+
Bin.new(name, Type::GEO)
|
156
176
|
end
|
157
177
|
|
158
178
|
# Create list bin expression.
|
159
179
|
#
|
160
180
|
# ==== Examples
|
161
|
-
#
|
162
|
-
#
|
181
|
+
# # Bin a[2] == 3
|
182
|
+
# Exp.eq(ListExp.get_by_index(ListReturnType::VALUE, Type::INT, Exp.val(2), Exp.list_bin("a")), Exp.val(3))
|
163
183
|
def self.list_bin(name)
|
164
|
-
|
184
|
+
Bin.new(name, Type::LIST)
|
165
185
|
end
|
166
186
|
|
167
187
|
# Create map bin expression.
|
168
188
|
#
|
169
189
|
# ==== Examples
|
170
|
-
#
|
171
|
-
#
|
172
|
-
# MapExp.get_by_key(MapReturnType::VALUE, Type::STRING, Exp.
|
173
|
-
# Exp.
|
190
|
+
# # Bin a["key"] == "value"
|
191
|
+
# Exp.eq(
|
192
|
+
# MapExp.get_by_key(MapReturnType::VALUE, Type::STRING, Exp.str_val("key"), Exp.map_bin("a")),
|
193
|
+
# Exp.str_val("value"))
|
174
194
|
def self.map_bin(name)
|
175
|
-
|
195
|
+
Bin.new(name, Type::MAP)
|
176
196
|
end
|
177
197
|
|
178
198
|
# Create hll bin expression.
|
@@ -181,26 +201,26 @@ module Aerospike
|
|
181
201
|
# # HLL bin "a" count > 7
|
182
202
|
# Exp.gt(HLLExp.get_count(Exp.hll_bin("a")), Exp.val(7))
|
183
203
|
def self.hll_bin(name)
|
184
|
-
|
204
|
+
Bin.new(name, Type::HLL)
|
185
205
|
end
|
186
206
|
|
187
207
|
# Create expression that returns if bin of specified name exists.
|
188
208
|
#
|
189
209
|
# ==== Examples
|
190
|
-
#
|
191
|
-
#
|
210
|
+
# # Bin "a" exists in record
|
211
|
+
# Exp.bin_exists("a")
|
192
212
|
def self.bin_exists(name)
|
193
|
-
return Exp.ne(Exp.bin_type(name), Exp.
|
213
|
+
return Exp.ne(Exp.bin_type(name), Exp.int_val(0))
|
194
214
|
end
|
195
215
|
|
196
216
|
# Create expression that returns bin's integer particle type::
|
197
|
-
# See {@link
|
217
|
+
# See {@link ParticleType}.
|
198
218
|
#
|
199
219
|
# ==== Examples
|
200
|
-
#
|
201
|
-
#
|
220
|
+
# # Bin "a" particle type is a list
|
221
|
+
# Exp.eq(Exp.bin_type("a"), Exp.val(ParticleType::LIST))
|
202
222
|
def self.bin_type(name)
|
203
|
-
|
223
|
+
CmdStr.new(BIN_TYPE, name)
|
204
224
|
end
|
205
225
|
|
206
226
|
#--------------------------------------------------
|
@@ -211,10 +231,10 @@ module Aerospike
|
|
211
231
|
# evaluates quickly because record meta data is cached in memory.
|
212
232
|
#
|
213
233
|
# ==== Examples
|
214
|
-
#
|
215
|
-
#
|
234
|
+
# # Record set name == "myset"
|
235
|
+
# Exp.eq(Exp.set_name, Exp.str_val("myset"))
|
216
236
|
def self.set_name
|
217
|
-
|
237
|
+
Cmd.new(SET_NAME)
|
218
238
|
end
|
219
239
|
|
220
240
|
# Create expression that returns record size on disk. If server storage-engine is
|
@@ -222,23 +242,23 @@ module Aerospike
|
|
222
242
|
# record meta data is cached in memory.
|
223
243
|
#
|
224
244
|
# ==== Examples
|
225
|
-
#
|
226
|
-
#
|
245
|
+
# # Record device size >= 100 KB
|
246
|
+
# Exp.ge(Exp.device_size, Exp.int_val(100 * 1024))
|
227
247
|
def self.device_size
|
228
|
-
|
248
|
+
Cmd.new(DEVICE_SIZE)
|
229
249
|
end
|
230
250
|
|
231
251
|
# Create expression that returns record size in memory. If server storage-engine is
|
232
252
|
# not memory nor data-in-memory, then zero is returned. This expression usually evaluates
|
233
253
|
# quickly because record meta data is cached in memory.
|
234
|
-
#
|
254
|
+
#
|
235
255
|
# Requires server version 5.3.0+
|
236
256
|
#
|
237
257
|
# ==== Examples
|
238
|
-
#
|
239
|
-
#
|
258
|
+
# # Record memory size >= 100 KB
|
259
|
+
# Exp.ge(Exp.memory_size, Exp.int_val(100 * 1024))
|
240
260
|
def self.memory_size
|
241
|
-
|
261
|
+
Cmd.new(MEMORY_SIZE)
|
242
262
|
end
|
243
263
|
|
244
264
|
# Create expression that returns record last update time expressed as 64 bit integer
|
@@ -246,20 +266,20 @@ module Aerospike
|
|
246
266
|
# record meta data is cached in memory.
|
247
267
|
#
|
248
268
|
# ==== Examples
|
249
|
-
#
|
250
|
-
#
|
269
|
+
# # Record last update time >= 2020-01-15
|
270
|
+
# Exp.ge(Exp.last_update, Exp.val(new GregorianCalendar(2020, 0, 15)))
|
251
271
|
def self.last_update
|
252
|
-
|
272
|
+
Cmd.new(LAST_UPDATE)
|
253
273
|
end
|
254
274
|
|
255
275
|
# Create expression that returns milliseconds since the record was last updated.
|
256
276
|
# This expression usually evaluates quickly because record meta data is cached in memory.
|
257
277
|
#
|
258
278
|
# ==== Examples
|
259
|
-
#
|
260
|
-
#
|
279
|
+
# # Record last updated more than 2 hours ago
|
280
|
+
# Exp.gt(Exp.since_update, Exp.val(2 * 60 * 60 * 1000))
|
261
281
|
def self.since_update
|
262
|
-
|
282
|
+
Cmd.new(SINCE_UPDATE)
|
263
283
|
end
|
264
284
|
|
265
285
|
# Create expression that returns record expiration time expressed as 64 bit integer
|
@@ -267,42 +287,42 @@ module Aerospike
|
|
267
287
|
# record meta data is cached in memory.
|
268
288
|
#
|
269
289
|
# ==== Examples
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
290
|
+
# # Record expires on 2021-01-01
|
291
|
+
# Exp.and(
|
292
|
+
# Exp.ge(Exp.void_time, Exp.val(new GregorianCalendar(2021, 0, 1))),
|
293
|
+
# Exp.lt(Exp.void_time, Exp.val(new GregorianCalendar(2021, 0, 2))))
|
274
294
|
def self.void_time
|
275
|
-
|
295
|
+
Cmd.new(VOID_TIME)
|
276
296
|
end
|
277
297
|
|
278
298
|
# Create expression that returns record expiration time (time to live) in integer seconds.
|
279
299
|
# This expression usually evaluates quickly because record meta data is cached in memory.
|
280
300
|
#
|
281
301
|
# ==== Examples
|
282
|
-
#
|
283
|
-
#
|
302
|
+
# # Record expires in less than 1 hour
|
303
|
+
# Exp.lt(Exp.ttl, Exp.val(60 * 60))
|
284
304
|
def self.ttl
|
285
|
-
|
305
|
+
Cmd.new(TTL)
|
286
306
|
end
|
287
307
|
|
288
308
|
# Create expression that returns if record has been deleted and is still in tombstone state.
|
289
309
|
# This expression usually evaluates quickly because record meta data is cached in memory.
|
290
310
|
#
|
291
311
|
# ==== Examples
|
292
|
-
#
|
293
|
-
#
|
312
|
+
# # Deleted records that are in tombstone state.
|
313
|
+
# Exp.is_tombstone
|
294
314
|
def self.is_tombstone
|
295
|
-
|
315
|
+
Cmd.new(IS_TOMBSTONE)
|
296
316
|
end
|
297
317
|
|
298
318
|
# Create expression that returns record digest modulo as integer. This expression usually
|
299
319
|
# evaluates quickly because record meta data is cached in memory.
|
300
320
|
#
|
301
321
|
# ==== Examples
|
302
|
-
#
|
303
|
-
#
|
322
|
+
# # Records that have digest(key) % 3 == 1
|
323
|
+
# Exp.eq(Exp.digest_modulo(3), Exp.int_val(1))
|
304
324
|
def self.digest_modulo(mod)
|
305
|
-
|
325
|
+
CmdInt.new(DIGEST_MODULO, mod)
|
306
326
|
end
|
307
327
|
|
308
328
|
# Create expression that performs a regex match on a string bin or string value expression.
|
@@ -310,13 +330,13 @@ module Aerospike
|
|
310
330
|
# ==== Examples
|
311
331
|
# # Select string bin "a" that starts with "prefix" and ends with "suffix".
|
312
332
|
# # Ignore case and do not match newline.
|
313
|
-
# Exp.regex_compare("prefix.*suffix",
|
333
|
+
# Exp.regex_compare("prefix.*suffix", RegexFlags.ICASE | RegexFlags.NEWLINE, Exp.str_bin("a"))
|
314
334
|
#
|
315
335
|
# @param regex regular expression string
|
316
|
-
# @param flags regular expression bit flags. See {@link
|
336
|
+
# @param flags regular expression bit flags. See {@link Exp::RegexFlags}
|
317
337
|
# @param bin string bin or string value expression
|
318
338
|
def self.regex_compare(regex, flags, bin)
|
319
|
-
|
339
|
+
Regex.new(bin, regex, flags)
|
320
340
|
end
|
321
341
|
|
322
342
|
#--------------------------------------------------
|
@@ -327,23 +347,23 @@ module Aerospike
|
|
327
347
|
#
|
328
348
|
# ==== Examples
|
329
349
|
# # Query region within coordinates.
|
330
|
-
#
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
#
|
335
|
-
#
|
336
|
-
#
|
337
|
-
#
|
338
|
-
#
|
339
|
-
#
|
350
|
+
# region =
|
351
|
+
# "{ " +
|
352
|
+
# " \"type\": \"Polygon\", " +
|
353
|
+
# " \"coordinates\": [ " +
|
354
|
+
# " [[-122.500000, 37.000000],[-121.000000, 37.000000], " +
|
355
|
+
# " [-121.000000, 38.080000],[-122.500000, 38.080000], " +
|
356
|
+
# " [-122.500000, 37.000000]] " +
|
357
|
+
# " ] " +
|
358
|
+
# "}"
|
359
|
+
# Exp.geo_compare(Exp.geo_bin("a"), Exp.geo(region))
|
340
360
|
def self.geo_compare(left, right)
|
341
|
-
|
361
|
+
CmdExp.new(GEO, left, right)
|
342
362
|
end
|
343
363
|
|
344
364
|
# Create geospatial json string value.
|
345
365
|
def self.geo(val)
|
346
|
-
|
366
|
+
Geo.new(val)
|
347
367
|
end
|
348
368
|
|
349
369
|
#--------------------------------------------------
|
@@ -351,43 +371,43 @@ module Aerospike
|
|
351
371
|
#--------------------------------------------------
|
352
372
|
|
353
373
|
# Create boolean value.
|
354
|
-
def self.
|
355
|
-
|
374
|
+
def self.bool_val(val)
|
375
|
+
Bool.new(val)
|
356
376
|
end
|
357
377
|
|
358
378
|
# Create 64 bit integer value.
|
359
|
-
def self.
|
360
|
-
|
379
|
+
def self.int_val(val)
|
380
|
+
Int.new(val)
|
361
381
|
end
|
362
382
|
|
363
383
|
# Create 64 bit floating point value.
|
364
|
-
def self.
|
365
|
-
|
384
|
+
def self.float_val(val)
|
385
|
+
Float.new(val)
|
366
386
|
end
|
367
387
|
|
368
388
|
# Create string value.
|
369
|
-
def self.
|
370
|
-
|
389
|
+
def self.str_val(val)
|
390
|
+
Str.new(val)
|
371
391
|
end
|
372
392
|
|
373
393
|
# Create blob byte value.
|
374
|
-
def self.
|
375
|
-
|
394
|
+
def self.blob_val(val)
|
395
|
+
Blob.new(val)
|
376
396
|
end
|
377
397
|
|
378
398
|
# Create list value.
|
379
|
-
def self.
|
380
|
-
|
399
|
+
def self.list_val(*list)
|
400
|
+
ListVal.new(list)
|
381
401
|
end
|
382
402
|
|
383
403
|
# Create map value.
|
384
|
-
def self.
|
385
|
-
|
404
|
+
def self.map_val(map)
|
405
|
+
MapVal.new(map)
|
386
406
|
end
|
387
407
|
|
388
408
|
# Create nil value.
|
389
|
-
def self.
|
390
|
-
|
409
|
+
def self.nil_val
|
410
|
+
Nil.new
|
391
411
|
end
|
392
412
|
|
393
413
|
#--------------------------------------------------
|
@@ -397,103 +417,103 @@ module Aerospike
|
|
397
417
|
# Create "not" operator expression.
|
398
418
|
#
|
399
419
|
# ==== Examples
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
420
|
+
# # ! (a == 0 || a == 10)
|
421
|
+
# Exp.not(
|
422
|
+
# Exp.or(
|
423
|
+
# Exp.eq(Exp.int_bin("a"), Exp.val(0)),
|
424
|
+
# Exp.eq(Exp.int_bin("a"), Exp.int_val(10))))
|
405
425
|
def self.not(exp)
|
406
|
-
|
426
|
+
CmdExp.new(NOT, exp)
|
407
427
|
end
|
408
428
|
|
409
429
|
# Create "and" (&&) operator that applies to a variable number of expressions.
|
410
430
|
#
|
411
431
|
# ==== Examples
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
432
|
+
# # (a > 5 || a == 0) && b < 3
|
433
|
+
# Exp.and(
|
434
|
+
# Exp.or(
|
435
|
+
# Exp.gt(Exp.int_bin("a"), Exp.val(5)),
|
436
|
+
# Exp.eq(Exp.int_bin("a"), Exp.val(0))),
|
437
|
+
# Exp.lt(Exp.int_bin("b"), Exp.val(3)))
|
418
438
|
def self.and(*exps)
|
419
|
-
|
439
|
+
CmdExp.new(AND, *exps)
|
420
440
|
end
|
421
441
|
|
422
442
|
# Create "or" (||) operator that applies to a variable number of expressions.
|
423
443
|
#
|
424
444
|
# ==== Examples
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
445
|
+
# # a == 0 || b == 0
|
446
|
+
# Exp.or(
|
447
|
+
# Exp.eq(Exp.int_bin("a"), Exp.val(0)),
|
448
|
+
# Exp.eq(Exp.int_bin("b"), Exp.val(0)))
|
429
449
|
def self.or(*exps)
|
430
|
-
|
450
|
+
CmdExp.new(OR, *exps)
|
431
451
|
end
|
432
452
|
|
433
453
|
# Create expression that returns true if only one of the expressions are true.
|
434
454
|
# Requires server version 5.6.0+.
|
435
455
|
#
|
436
456
|
# ==== Examples
|
437
|
-
#
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
457
|
+
# # exclusive(a == 0, b == 0)
|
458
|
+
# Exp.exclusive(
|
459
|
+
# Exp.eq(Exp.int_bin("a"), Exp.val(0)),
|
460
|
+
# Exp.eq(Exp.int_bin("b"), Exp.val(0)))
|
441
461
|
def self.exclusive(*exps)
|
442
|
-
|
462
|
+
CmdExp.new(EXCLUSIVE, *exps)
|
443
463
|
end
|
444
464
|
|
445
465
|
# Create equal (==) expression.
|
446
466
|
#
|
447
467
|
# ==== Examples
|
448
|
-
#
|
449
|
-
#
|
468
|
+
# # a == 11
|
469
|
+
# Exp.eq(Exp.int_bin("a"), Exp.int_val(11))
|
450
470
|
def self.eq(left, right)
|
451
|
-
|
471
|
+
CmdExp.new(EQ, left, right)
|
452
472
|
end
|
453
473
|
|
454
474
|
# Create not equal (!=) expression
|
455
475
|
#
|
456
476
|
# ==== Examples
|
457
|
-
#
|
458
|
-
#
|
477
|
+
# # a != 13
|
478
|
+
# Exp.ne(Exp.int_bin("a"), Exp.int_val(13))
|
459
479
|
def self.ne(left, right)
|
460
|
-
|
480
|
+
CmdExp.new(NE, left, right)
|
461
481
|
end
|
462
482
|
|
463
483
|
# Create greater than (>) operation.
|
464
484
|
#
|
465
485
|
# ==== Examples
|
466
|
-
#
|
467
|
-
#
|
486
|
+
# # a > 8
|
487
|
+
# Exp.gt(Exp.int_bin("a"), Exp.val(8))
|
468
488
|
def self.gt(left, right)
|
469
|
-
|
489
|
+
CmdExp.new(GT, left, right)
|
470
490
|
end
|
471
491
|
|
472
492
|
# Create greater than or equal (>=) operation.
|
473
493
|
#
|
474
494
|
# ==== Examples
|
475
|
-
#
|
476
|
-
#
|
495
|
+
# # a >= 88
|
496
|
+
# Exp.ge(Exp.int_bin("a"), Exp.val(88))
|
477
497
|
def self.ge(left, right)
|
478
|
-
|
498
|
+
CmdExp.new(GE, left, right)
|
479
499
|
end
|
480
500
|
|
481
501
|
# Create less than (<) operation.
|
482
502
|
#
|
483
503
|
# ==== Examples
|
484
|
-
#
|
485
|
-
#
|
504
|
+
# # a < 1000
|
505
|
+
# Exp.lt(Exp.int_bin("a"), Exp.int_val(1000))
|
486
506
|
def self.lt(left, right)
|
487
|
-
|
507
|
+
CmdExp.new(LT, left, right)
|
488
508
|
end
|
489
509
|
|
490
510
|
# Create less than or equals (<=) operation.
|
491
511
|
#
|
492
512
|
# ==== Examples
|
493
|
-
#
|
494
|
-
#
|
513
|
+
# # a <= 1
|
514
|
+
# Exp.le(Exp.int_bin("a"), Exp.int_val(1))
|
495
515
|
def self.le(left, right)
|
496
|
-
|
516
|
+
CmdExp.new(LE, left, right)
|
497
517
|
end
|
498
518
|
|
499
519
|
#--------------------------------------------------
|
@@ -505,12 +525,12 @@ module Aerospike
|
|
505
525
|
# Requires server version 5.6.0+.
|
506
526
|
#
|
507
527
|
# ==== Examples
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
528
|
+
# # a + b + c == 10
|
529
|
+
# Exp.eq(
|
530
|
+
# Exp.add(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
531
|
+
# Exp.int_val(10))
|
512
532
|
def self.add(*exps)
|
513
|
-
|
533
|
+
CmdExp.new(ADD, *exps)
|
514
534
|
end
|
515
535
|
|
516
536
|
# Create "subtract" (-) operator that applies to a variable number of expressions.
|
@@ -520,12 +540,12 @@ module Aerospike
|
|
520
540
|
# Requires server version 5.6.0+.
|
521
541
|
#
|
522
542
|
# ==== Examples
|
523
|
-
#
|
524
|
-
#
|
525
|
-
#
|
526
|
-
#
|
543
|
+
# # a - b - c > 10
|
544
|
+
# Exp.gt(
|
545
|
+
# Exp.sub(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
546
|
+
# Exp.int_val(10))
|
527
547
|
def self.sub(*exps)
|
528
|
-
|
548
|
+
CmdExp.new(SUB, *exps)
|
529
549
|
end
|
530
550
|
|
531
551
|
# Create "multiply" (*) operator that applies to a variable number of expressions.
|
@@ -534,12 +554,12 @@ module Aerospike
|
|
534
554
|
# Requires server version 5.6.0+.
|
535
555
|
#
|
536
556
|
# ==== Examples
|
537
|
-
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
557
|
+
# # a * b * c < 100
|
558
|
+
# Exp.lt(
|
559
|
+
# Exp.mul(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
560
|
+
# Exp.int_val(100))
|
541
561
|
def self.mul(*exps)
|
542
|
-
|
562
|
+
CmdExp.new(MUL, *exps)
|
543
563
|
end
|
544
564
|
|
545
565
|
# Create "divide" (/) operator that applies to a variable number of expressions.
|
@@ -549,12 +569,12 @@ module Aerospike
|
|
549
569
|
# Requires server version 5.6.0+.
|
550
570
|
#
|
551
571
|
# ==== Examples
|
552
|
-
#
|
553
|
-
#
|
554
|
-
#
|
555
|
-
#
|
572
|
+
# # a / b / c > 1
|
573
|
+
# Exp.gt(
|
574
|
+
# Exp.div(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
575
|
+
# Exp.int_val(1))
|
556
576
|
def self.div(*exps)
|
557
|
-
|
577
|
+
CmdExp.new(DIV, *exps)
|
558
578
|
end
|
559
579
|
|
560
580
|
# Create "power" operator that raises a "base" to the "exponent" power.
|
@@ -562,12 +582,12 @@ module Aerospike
|
|
562
582
|
# Requires server version 5.6.0+.
|
563
583
|
#
|
564
584
|
# ==== Examples
|
565
|
-
#
|
566
|
-
#
|
567
|
-
#
|
568
|
-
#
|
585
|
+
# # pow(a, 2.0) == 4.0
|
586
|
+
# Exp.eq(
|
587
|
+
# Exp.pow(Exp.float_bin("a"), Exp.val(2.0)),
|
588
|
+
# Exp.val(4.0))
|
569
589
|
def self.pow(base, exponent)
|
570
|
-
|
590
|
+
CmdExp.new(POW, base, exponent)
|
571
591
|
end
|
572
592
|
|
573
593
|
# Create "log" operator for logarithm of "num" with base "base".
|
@@ -575,12 +595,12 @@ module Aerospike
|
|
575
595
|
# Requires server version 5.6.0+.
|
576
596
|
#
|
577
597
|
# ==== Examples
|
578
|
-
#
|
579
|
-
#
|
580
|
-
#
|
581
|
-
#
|
598
|
+
# # log(a, 2.0) == 4.0
|
599
|
+
# Exp.eq(
|
600
|
+
# Exp.log(Exp.float_bin("a"), Exp.val(2.0)),
|
601
|
+
# Exp.val(4.0))
|
582
602
|
def self.log(num, base)
|
583
|
-
|
603
|
+
CmdExp.new(LOG, num, base)
|
584
604
|
end
|
585
605
|
|
586
606
|
# Create "modulo" (%) operator that determines the remainder of "numerator"
|
@@ -588,12 +608,12 @@ module Aerospike
|
|
588
608
|
# Requires server version 5.6.0+.
|
589
609
|
#
|
590
610
|
# ==== Examples
|
591
|
-
#
|
592
|
-
#
|
593
|
-
#
|
594
|
-
#
|
611
|
+
# # a % 10 == 0
|
612
|
+
# Exp.eq(
|
613
|
+
# Exp.mod(Exp.int_bin("a"), Exp.int_val(10)),
|
614
|
+
# Exp.val(0))
|
595
615
|
def self.mod(numerator, denominator)
|
596
|
-
|
616
|
+
CmdExp.new(MOD, numerator, denominator)
|
597
617
|
end
|
598
618
|
|
599
619
|
# Create operator that returns absolute value of a number.
|
@@ -601,60 +621,60 @@ module Aerospike
|
|
601
621
|
# Requires server version 5.6.0+.
|
602
622
|
#
|
603
623
|
# ==== Examples
|
604
|
-
#
|
605
|
-
#
|
606
|
-
#
|
607
|
-
#
|
624
|
+
# # abs(a) == 1
|
625
|
+
# Exp.eq(
|
626
|
+
# Exp.abs(Exp.int_bin("a")),
|
627
|
+
# Exp.int_val(1))
|
608
628
|
def self.abs(value)
|
609
|
-
|
629
|
+
CmdExp.new(ABS, value)
|
610
630
|
end
|
611
631
|
|
612
632
|
# Create expression that rounds a floating point number down to the closest integer value.
|
613
633
|
# The return type is float. Requires server version 5.6.0+.
|
614
634
|
#
|
615
635
|
# ==== Examples
|
616
|
-
#
|
617
|
-
#
|
618
|
-
#
|
619
|
-
#
|
636
|
+
# # floor(2.95) == 2.0
|
637
|
+
# Exp.eq(
|
638
|
+
# Exp.floor(Exp.val(2.95)),
|
639
|
+
# Exp.val(2.0))
|
620
640
|
def self.floor(num)
|
621
|
-
|
641
|
+
CmdExp.new(FLOOR, num)
|
622
642
|
end
|
623
643
|
|
624
644
|
# Create expression that rounds a floating point number up to the closest integer value.
|
625
645
|
# The return type is float. Requires server version 5.6.0+.
|
626
646
|
#
|
627
647
|
# ==== Examples
|
628
|
-
#
|
629
|
-
#
|
630
|
-
#
|
631
|
-
#
|
648
|
+
# # ceil(2.15) >= 3.0
|
649
|
+
# Exp.ge(
|
650
|
+
# Exp.ceil(Exp.val(2.15)),
|
651
|
+
# Exp.val(3.0))
|
632
652
|
def self.ceil(num)
|
633
|
-
|
653
|
+
CmdExp.new(CEIL, num)
|
634
654
|
end
|
635
655
|
|
636
656
|
# Create expression that converts a float to an integer.
|
637
657
|
# Requires server version 5.6.0+.
|
638
658
|
#
|
639
659
|
# ==== Examples
|
640
|
-
#
|
641
|
-
#
|
642
|
-
#
|
643
|
-
#
|
660
|
+
# # int(2.5) == 2
|
661
|
+
# Exp.eq(
|
662
|
+
# Exp.to_int(Exp.val(2.5)),
|
663
|
+
# Exp.val(2))
|
644
664
|
def self.to_int(num)
|
645
|
-
|
665
|
+
CmdExp.new(TO_INT, num)
|
646
666
|
end
|
647
667
|
|
648
668
|
# Create expression that converts an integer to a float.
|
649
669
|
# Requires server version 5.6.0+.
|
650
670
|
#
|
651
671
|
# ==== Examples
|
652
|
-
#
|
653
|
-
#
|
654
|
-
#
|
655
|
-
#
|
672
|
+
# # float(2) == 2.0
|
673
|
+
# Exp.eq(
|
674
|
+
# Exp.to_float(Exp.val(2))),
|
675
|
+
# Exp.val(2.0))
|
656
676
|
def self.to_float(num)
|
657
|
-
|
677
|
+
CmdExp.new(TO_FLOAT, num)
|
658
678
|
end
|
659
679
|
|
660
680
|
# Create integer "and" (&) operator that is applied to two or more integers.
|
@@ -662,12 +682,12 @@ module Aerospike
|
|
662
682
|
# Requires server version 5.6.0+.
|
663
683
|
#
|
664
684
|
# ==== Examples
|
665
|
-
#
|
666
|
-
#
|
667
|
-
#
|
668
|
-
#
|
685
|
+
# # a & 0xff == 0x11
|
686
|
+
# Exp.eq(
|
687
|
+
# Exp.int_and(Exp.int_bin("a"), Exp.val(0xff)),
|
688
|
+
# Exp.val(0x11))
|
669
689
|
def self.int_and(*exps)
|
670
|
-
|
690
|
+
CmdExp.new(INT_AND, *exps)
|
671
691
|
end
|
672
692
|
|
673
693
|
# Create integer "or" (|) operator that is applied to two or more integers.
|
@@ -675,12 +695,12 @@ module Aerospike
|
|
675
695
|
# Requires server version 5.6.0+.
|
676
696
|
#
|
677
697
|
# ==== Examples
|
678
|
-
#
|
679
|
-
#
|
680
|
-
#
|
681
|
-
#
|
698
|
+
# # a | 0x10 != 0
|
699
|
+
# Exp.ne(
|
700
|
+
# Exp.int_or(Exp.int_bin("a"), Exp.val(0x10)),
|
701
|
+
# Exp.val(0))
|
682
702
|
def self.int_or(*exps)
|
683
|
-
|
703
|
+
CmdExp.new(INT_OR, *exps)
|
684
704
|
end
|
685
705
|
|
686
706
|
# Create integer "xor" (^) operator that is applied to two or more integers.
|
@@ -688,72 +708,72 @@ module Aerospike
|
|
688
708
|
# Requires server version 5.6.0+.
|
689
709
|
#
|
690
710
|
# ==== Examples
|
691
|
-
#
|
692
|
-
#
|
693
|
-
#
|
694
|
-
#
|
711
|
+
# # a ^ b == 16
|
712
|
+
# Exp.eq(
|
713
|
+
# Exp.int_xor(Exp.int_bin("a"), Exp.int_bin("b")),
|
714
|
+
# Exp.int_val(16))
|
695
715
|
def self.int_xor(*exps)
|
696
|
-
|
716
|
+
CmdExp.new(INT_XOR, *exps)
|
697
717
|
end
|
698
718
|
|
699
719
|
# Create integer "not" (~) operator.
|
700
720
|
# Requires server version 5.6.0+.
|
701
721
|
#
|
702
722
|
# ==== Examples
|
703
|
-
#
|
704
|
-
#
|
705
|
-
#
|
706
|
-
#
|
723
|
+
# # ~a == 7
|
724
|
+
# Exp.eq(
|
725
|
+
# Exp.int_not(Exp.int_bin("a")),
|
726
|
+
# Exp.val(7))
|
707
727
|
def self.int_not(exp)
|
708
|
-
|
728
|
+
CmdExp.new(INT_NOT, exp)
|
709
729
|
end
|
710
730
|
|
711
731
|
# Create integer "left shift" (<<) operator.
|
712
732
|
# Requires server version 5.6.0+.
|
713
733
|
#
|
714
734
|
# ==== Examples
|
715
|
-
#
|
716
|
-
#
|
717
|
-
#
|
718
|
-
#
|
735
|
+
# # a << 8 > 0xff
|
736
|
+
# Exp.gt(
|
737
|
+
# Exp.lshift(Exp.int_bin("a"), Exp.val(8)),
|
738
|
+
# Exp.val(0xff))
|
719
739
|
def self.lshift(value, shift)
|
720
|
-
|
740
|
+
CmdExp.new(INT_LSHIFT, value, shift)
|
721
741
|
end
|
722
742
|
|
723
743
|
# Create integer "logical right shift" (>>>) operator.
|
724
744
|
# Requires server version 5.6.0+.
|
725
745
|
#
|
726
746
|
# ==== Examples
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
#
|
747
|
+
# # a >>> 8 > 0xff
|
748
|
+
# Exp.gt(
|
749
|
+
# Exp.rshift(Exp.int_bin("a"), Exp.val(8)),
|
750
|
+
# Exp.val(0xff))
|
731
751
|
def self.rshift(value, shift)
|
732
|
-
|
752
|
+
CmdExp.new(INT_RSHIFT, value, shift)
|
733
753
|
end
|
734
754
|
|
735
755
|
# Create integer "arithmetic right shift" (>>) operator.
|
736
756
|
# Requires server version 5.6.0+.
|
737
757
|
#
|
738
758
|
# ==== Examples
|
739
|
-
#
|
740
|
-
#
|
741
|
-
#
|
742
|
-
#
|
759
|
+
# # a >> 8 > 0xff
|
760
|
+
# Exp.gt(
|
761
|
+
# Exp.arshift(Exp.int_bin("a"), Exp.val(8)),
|
762
|
+
# Exp.val(0xff))
|
743
763
|
def self.arshift(value, shift)
|
744
|
-
|
764
|
+
CmdExp.new(INT_ARSHIFT, value, shift)
|
745
765
|
end
|
746
766
|
|
747
767
|
# Create expression that returns count of integer bits that are set to 1.
|
748
768
|
# Requires server version 5.6.0+.
|
749
769
|
#
|
750
770
|
# ==== Examples
|
751
|
-
#
|
752
|
-
#
|
753
|
-
#
|
754
|
-
#
|
771
|
+
# # count(a) == 4
|
772
|
+
# Exp.eq(
|
773
|
+
# Exp.count(Exp.int_bin("a")),
|
774
|
+
# Exp.val(4))
|
755
775
|
def self.count(exp)
|
756
|
-
|
776
|
+
CmdExp.new(INT_COUNT, exp)
|
757
777
|
end
|
758
778
|
|
759
779
|
# Create expression that scans integer bits from left (most significant bit) to
|
@@ -764,12 +784,12 @@ module Aerospike
|
|
764
784
|
# Requires server version 5.6.0+.
|
765
785
|
#
|
766
786
|
# ==== Examples
|
767
|
-
#
|
768
|
-
#
|
769
|
-
#
|
770
|
-
#
|
787
|
+
# # lscan(a, true) == 4
|
788
|
+
# Exp.eq(
|
789
|
+
# Exp.lscan(Exp.int_bin("a"), Exp.val(true)),
|
790
|
+
# Exp.val(4))
|
771
791
|
def self.lscan(value, search)
|
772
|
-
|
792
|
+
CmdExp.new(INT_LSCAN, value, search)
|
773
793
|
end
|
774
794
|
|
775
795
|
# Create expression that scans integer bits from right (least significant bit) to
|
@@ -780,12 +800,12 @@ module Aerospike
|
|
780
800
|
# Requires server version 5.6.0+.
|
781
801
|
#
|
782
802
|
# ==== Examples
|
783
|
-
#
|
784
|
-
#
|
785
|
-
#
|
786
|
-
#
|
803
|
+
# # rscan(a, true) == 4
|
804
|
+
# Exp.eq(
|
805
|
+
# Exp.rscan(Exp.int_bin("a"), Exp.val(true)),
|
806
|
+
# Exp.val(4))
|
787
807
|
def self.rscan(value, search)
|
788
|
-
|
808
|
+
CmdExp.new(INT_RSCAN, value, search)
|
789
809
|
end
|
790
810
|
|
791
811
|
# Create expression that returns the minimum value in a variable number of expressions.
|
@@ -793,12 +813,12 @@ module Aerospike
|
|
793
813
|
# Requires server version 5.6.0+.
|
794
814
|
#
|
795
815
|
# ==== Examples
|
796
|
-
#
|
797
|
-
#
|
798
|
-
#
|
799
|
-
#
|
816
|
+
# # min(a, b, c) > 0
|
817
|
+
# Exp.gt(
|
818
|
+
# Exp.min(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
819
|
+
# Exp.val(0))
|
800
820
|
def self.min(*exps)
|
801
|
-
|
821
|
+
CmdExp.new(MIN, *exps)
|
802
822
|
end
|
803
823
|
|
804
824
|
# Create expression that returns the maximum value in a variable number of expressions.
|
@@ -806,12 +826,12 @@ module Aerospike
|
|
806
826
|
# Requires server version 5.6.0+.
|
807
827
|
#
|
808
828
|
# ==== Examples
|
809
|
-
#
|
810
|
-
#
|
811
|
-
#
|
812
|
-
#
|
829
|
+
# # max(a, b, c) > 100
|
830
|
+
# Exp.gt(
|
831
|
+
# Exp.max(Exp.int_bin("a"), Exp.int_bin("b"), Exp.int_bin("c")),
|
832
|
+
# Exp.int_val(100))
|
813
833
|
def self.max(*exps)
|
814
|
-
|
834
|
+
CmdExp.new(MAX, *exps)
|
815
835
|
end
|
816
836
|
|
817
837
|
#--------------------------------------------------
|
@@ -825,13 +845,13 @@ module Aerospike
|
|
825
845
|
# Args Format: bool exp1, action exp1, bool exp2, action exp2, ..., action-default
|
826
846
|
#
|
827
847
|
# # Apply operator based on type::
|
828
|
-
#
|
829
|
-
#
|
830
|
-
#
|
831
|
-
#
|
832
|
-
#
|
848
|
+
# Exp.cond(
|
849
|
+
# Exp.eq(Exp.int_bin("type"), Exp.val(0)), Exp.add(Exp.int_bin("val1"), Exp.int_bin("val2")),
|
850
|
+
# Exp.eq(Exp.int_bin("type"), Exp.int_val(1)), Exp.sub(Exp.int_bin("val1"), Exp.int_bin("val2")),
|
851
|
+
# Exp.eq(Exp.int_bin("type"), Exp.val(2)), Exp.mul(Exp.int_bin("val1"), Exp.int_bin("val2")),
|
852
|
+
# Exp.val(-1))
|
833
853
|
def self.cond(*exps)
|
834
|
-
|
854
|
+
CmdExp.new(COND, *exps)
|
835
855
|
end
|
836
856
|
|
837
857
|
# Define variables and expressions in scope.
|
@@ -848,9 +868,9 @@ module Aerospike
|
|
848
868
|
# Exp.def("x", Exp.int_bin("a")),
|
849
869
|
# Exp.and(
|
850
870
|
# Exp.lt(Exp.val(5), Exp.var("x")),
|
851
|
-
# Exp.lt(Exp.var("x"), Exp.
|
871
|
+
# Exp.lt(Exp.var("x"), Exp.int_val(10))))
|
852
872
|
def self.let(*exps)
|
853
|
-
|
873
|
+
Let.new(exps)
|
854
874
|
end
|
855
875
|
|
856
876
|
# Assign variable to a {@link Exp#let(Exp...)} expression that can be accessed later.
|
@@ -862,9 +882,9 @@ module Aerospike
|
|
862
882
|
# Exp.def("x", Exp.int_bin("a")),
|
863
883
|
# Exp.and(
|
864
884
|
# Exp.lt(Exp.val(5), Exp.var("x")),
|
865
|
-
# Exp.lt(Exp.var("x"), Exp.
|
885
|
+
# Exp.lt(Exp.var("x"), Exp.int_val(10))))
|
866
886
|
def self.def(name, value)
|
867
|
-
|
887
|
+
Def.new(name, value)
|
868
888
|
end
|
869
889
|
|
870
890
|
# Retrieve expression value from a variable.
|
@@ -876,9 +896,9 @@ module Aerospike
|
|
876
896
|
# Exp.def("x", Exp.int_bin("a")),
|
877
897
|
# Exp.and(
|
878
898
|
# Exp.lt(Exp.val(5), Exp.var("x")),
|
879
|
-
# Exp.lt(Exp.var("x"), Exp.
|
899
|
+
# Exp.lt(Exp.var("x"), Exp.int_val(10))))
|
880
900
|
def self.var(name)
|
881
|
-
|
901
|
+
CmdStr.new(VAR, name)
|
882
902
|
end
|
883
903
|
|
884
904
|
#--------------------------------------------------
|
@@ -886,20 +906,20 @@ module Aerospike
|
|
886
906
|
#--------------------------------------------------
|
887
907
|
|
888
908
|
# Create unknown value. Used to intentionally fail an expression.
|
889
|
-
# The failure can be ignored with {@link
|
890
|
-
# or {@link
|
909
|
+
# The failure can be ignored with {@link Exp::WriteFlags#EVAL_NO_FAIL}
|
910
|
+
# or {@link Exp::ReadFlags#EVAL_NO_FAIL}.
|
891
911
|
# Requires server version 5.6.0+.
|
892
912
|
#
|
893
913
|
# ==== Examples
|
894
914
|
# # double v = balance - 100.0
|
895
915
|
# # return (v > 0.0)? v : unknown
|
896
916
|
# Exp.let(
|
897
|
-
# Exp.def("v", Exp.sub(Exp.float_bin("balance"), Exp.
|
917
|
+
# Exp.def("v", Exp.sub(Exp.float_bin("balance"), Exp.int_val(100.0))),
|
898
918
|
# Exp.cond(
|
899
919
|
# Exp.ge(Exp.var("v"), Exp.val(0.0)), Exp.var("v"),
|
900
920
|
# Exp.unknown))
|
901
921
|
def self.unknown
|
902
|
-
|
922
|
+
Cmd.new(UNKNOWN)
|
903
923
|
end
|
904
924
|
|
905
925
|
# # Merge precompiled expression into a new expression tree.
|
@@ -909,7 +929,7 @@ module Aerospike
|
|
909
929
|
# # ==== Examples
|
910
930
|
# # # Merge precompiled expression into new expression.
|
911
931
|
# # Expression e = Exp.build(Exp.eq(Exp.int_bin("a"), Exp.val(200)))
|
912
|
-
# # Expression merged = Exp.build(Exp.and(Exp.expr(e), Exp.eq(Exp.int_bin("b"), Exp.
|
932
|
+
# # Expression merged = Exp.build(Exp.and(Exp.expr(e), Exp.eq(Exp.int_bin("b"), Exp.int_val(100))))
|
913
933
|
# def self.expr(Expression e)
|
914
934
|
# new ExpBytes.new(e)
|
915
935
|
# end
|
@@ -919,6 +939,28 @@ module Aerospike
|
|
919
939
|
#--------------------------------------------------
|
920
940
|
MODIFY = 0x40
|
921
941
|
|
942
|
+
def bytes
|
943
|
+
if @bytes.nil?
|
944
|
+
Packer.use do |packer|
|
945
|
+
pack(packer)
|
946
|
+
@bytes = packer.bytes
|
947
|
+
end
|
948
|
+
end
|
949
|
+
@bytes
|
950
|
+
end
|
951
|
+
|
952
|
+
# Estimate expression size in wire protocol.
|
953
|
+
# For internal use only.
|
954
|
+
def size
|
955
|
+
bytes.length
|
956
|
+
end
|
957
|
+
|
958
|
+
# Write expression in wire protocol.
|
959
|
+
# For internal use only.
|
960
|
+
def write(buf, offset)
|
961
|
+
buf.write_binary(bytes, offset)
|
962
|
+
end
|
963
|
+
|
922
964
|
private
|
923
965
|
|
924
966
|
UNKNOWN = 0
|
@@ -978,8 +1020,33 @@ module Aerospike
|
|
978
1020
|
CALL = 127
|
979
1021
|
NANOS_PER_MILLIS = 1000000
|
980
1022
|
|
981
|
-
def pack(
|
982
|
-
|
1023
|
+
def self.pack(ctx, command, *vals)
|
1024
|
+
Packer.use do |packer|
|
1025
|
+
# ctx is not support for bit commands
|
1026
|
+
packer.write_array_header(vals.to_a.length + 1)
|
1027
|
+
packer.write(command)
|
1028
|
+
vals.each do |v|
|
1029
|
+
if v.is_a?(Exp)
|
1030
|
+
v.pack(packer)
|
1031
|
+
else
|
1032
|
+
Value.of(v).pack(packer)
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
return packer.bytes
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
def self.pack_ctx(packer, ctx)
|
1040
|
+
unless ctx.to_a.empty?
|
1041
|
+
packer.write_array_header(3)
|
1042
|
+
packer.write(0xff)
|
1043
|
+
packer.write_array_header(ctx.length * 2)
|
1044
|
+
|
1045
|
+
ctx.each do |c|
|
1046
|
+
packer.write(c.id)
|
1047
|
+
c.value.pack(packer)
|
1048
|
+
end
|
1049
|
+
end
|
983
1050
|
end
|
984
1051
|
|
985
1052
|
# For internal use only.
|
@@ -997,12 +1064,13 @@ module Aerospike
|
|
997
1064
|
end
|
998
1065
|
|
999
1066
|
def pack(packer)
|
1000
|
-
packer.
|
1001
|
-
packer.
|
1002
|
-
packer.
|
1003
|
-
packer.
|
1004
|
-
packer.pack_byte_array(bytes, 0, bytes.length)
|
1005
|
-
|
1067
|
+
packer.write_array_header(5)
|
1068
|
+
packer.write(Exp::CALL)
|
1069
|
+
packer.write(@ret_type)
|
1070
|
+
packer.write(@module)
|
1071
|
+
# packer.pack_byte_array(@bytes, 0, @bytes.length)
|
1072
|
+
packer.write_raw(@bytes)
|
1073
|
+
@bin.pack(packer)
|
1006
1074
|
end
|
1007
1075
|
end
|
1008
1076
|
|
@@ -1016,10 +1084,10 @@ module Aerospike
|
|
1016
1084
|
end
|
1017
1085
|
|
1018
1086
|
def pack(packer)
|
1019
|
-
packer.
|
1020
|
-
packer.
|
1021
|
-
packer.
|
1022
|
-
packer.
|
1087
|
+
packer.write_array_header(3)
|
1088
|
+
packer.write(BIN)
|
1089
|
+
packer.write(@type)
|
1090
|
+
packer.write(@name)
|
1023
1091
|
end
|
1024
1092
|
end
|
1025
1093
|
|
@@ -1035,11 +1103,11 @@ module Aerospike
|
|
1035
1103
|
end
|
1036
1104
|
|
1037
1105
|
def pack(packer)
|
1038
|
-
packer.
|
1039
|
-
packer.
|
1040
|
-
packer.
|
1041
|
-
packer.
|
1042
|
-
bin.pack(packer)
|
1106
|
+
packer.write_array_header(4)
|
1107
|
+
packer.write(REGEX)
|
1108
|
+
packer.write(@flags)
|
1109
|
+
packer.write(@regex)
|
1110
|
+
@bin.pack(packer)
|
1043
1111
|
end
|
1044
1112
|
end
|
1045
1113
|
|
@@ -1052,11 +1120,11 @@ module Aerospike
|
|
1052
1120
|
|
1053
1121
|
def pack(packer)
|
1054
1122
|
# Let wire format: LET <defname1>, <defexp1>, <defname2>, <defexp2>, ..., <scope exp>
|
1055
|
-
count = (exps.length - 1) * 2 + 2
|
1056
|
-
packer.
|
1057
|
-
packer.
|
1123
|
+
count = (@exps.length - 1) * 2 + 2
|
1124
|
+
packer.write_array_header(count)
|
1125
|
+
packer.write(LET)
|
1058
1126
|
|
1059
|
-
exps.each do |exp|
|
1127
|
+
@exps.each do |exp|
|
1060
1128
|
exp.pack(packer)
|
1061
1129
|
end
|
1062
1130
|
end
|
@@ -1072,8 +1140,8 @@ module Aerospike
|
|
1072
1140
|
end
|
1073
1141
|
|
1074
1142
|
def pack(packer)
|
1075
|
-
packer.
|
1076
|
-
exp
|
1143
|
+
packer.write(@name)
|
1144
|
+
@exp.pack(packer)
|
1077
1145
|
end
|
1078
1146
|
end
|
1079
1147
|
|
@@ -1081,16 +1149,15 @@ module Aerospike
|
|
1081
1149
|
attr_reader :exps
|
1082
1150
|
attr_reader :cmd
|
1083
1151
|
|
1084
|
-
def initialize(cmd, exps)
|
1152
|
+
def initialize(cmd, *exps)
|
1085
1153
|
@exps = exps
|
1086
1154
|
@cmd = cmd
|
1087
1155
|
end
|
1088
1156
|
|
1089
1157
|
def pack(packer)
|
1090
|
-
packer.
|
1091
|
-
packer.
|
1092
|
-
|
1093
|
-
exps.each do |exp|
|
1158
|
+
packer.write_array_header(@exps.length + 1)
|
1159
|
+
packer.write(@cmd)
|
1160
|
+
@exps.each do |exp|
|
1094
1161
|
exp.pack(packer)
|
1095
1162
|
end
|
1096
1163
|
end
|
@@ -1106,9 +1173,9 @@ module Aerospike
|
|
1106
1173
|
end
|
1107
1174
|
|
1108
1175
|
def pack(packer)
|
1109
|
-
packer.
|
1110
|
-
|
1111
|
-
|
1176
|
+
packer.write_array_header(2)
|
1177
|
+
Value.of(@cmd).pack(packer)
|
1178
|
+
Value.of(@val).pack(packer)
|
1112
1179
|
end
|
1113
1180
|
end
|
1114
1181
|
|
@@ -1122,9 +1189,9 @@ module Aerospike
|
|
1122
1189
|
end
|
1123
1190
|
|
1124
1191
|
def pack(packer)
|
1125
|
-
packer.
|
1126
|
-
|
1127
|
-
packer.
|
1192
|
+
packer.write_array_header(2)
|
1193
|
+
Value.of(@cmd).pack(packer)
|
1194
|
+
packer.write(@str)
|
1128
1195
|
end
|
1129
1196
|
end
|
1130
1197
|
|
@@ -1136,8 +1203,8 @@ module Aerospike
|
|
1136
1203
|
end
|
1137
1204
|
|
1138
1205
|
def pack(packer)
|
1139
|
-
packer.
|
1140
|
-
packer.
|
1206
|
+
packer.write_array_header(1)
|
1207
|
+
packer.write(@cmd)
|
1141
1208
|
end
|
1142
1209
|
end
|
1143
1210
|
|
@@ -1149,7 +1216,7 @@ module Aerospike
|
|
1149
1216
|
end
|
1150
1217
|
|
1151
1218
|
def pack(packer)
|
1152
|
-
|
1219
|
+
BoolValue.new(@val).pack(packer)
|
1153
1220
|
end
|
1154
1221
|
end
|
1155
1222
|
|
@@ -1157,11 +1224,11 @@ module Aerospike
|
|
1157
1224
|
attr_reader :val
|
1158
1225
|
|
1159
1226
|
def initialize(val)
|
1160
|
-
@val = val
|
1227
|
+
@val = val.to_i
|
1161
1228
|
end
|
1162
1229
|
|
1163
1230
|
def pack(packer)
|
1164
|
-
|
1231
|
+
IntegerValue.new(@val).pack(packer)
|
1165
1232
|
end
|
1166
1233
|
end
|
1167
1234
|
|
@@ -1169,11 +1236,11 @@ module Aerospike
|
|
1169
1236
|
attr_reader :val
|
1170
1237
|
|
1171
1238
|
def initialize(val)
|
1172
|
-
@val = val
|
1239
|
+
@val = val.to_f
|
1173
1240
|
end
|
1174
1241
|
|
1175
1242
|
def pack(packer)
|
1176
|
-
|
1243
|
+
FloatValue.new(@val).pack(packer)
|
1177
1244
|
end
|
1178
1245
|
end
|
1179
1246
|
|
@@ -1185,7 +1252,7 @@ module Aerospike
|
|
1185
1252
|
end
|
1186
1253
|
|
1187
1254
|
def pack(packer)
|
1188
|
-
|
1255
|
+
StringValue.new(@val).pack(packer)
|
1189
1256
|
end
|
1190
1257
|
end
|
1191
1258
|
|
@@ -1197,7 +1264,7 @@ module Aerospike
|
|
1197
1264
|
end
|
1198
1265
|
|
1199
1266
|
def pack(packer)
|
1200
|
-
|
1267
|
+
Value.of(@val).pack(packer)
|
1201
1268
|
end
|
1202
1269
|
end
|
1203
1270
|
|
@@ -1209,7 +1276,7 @@ module Aerospike
|
|
1209
1276
|
end
|
1210
1277
|
|
1211
1278
|
def pack(packer)
|
1212
|
-
|
1279
|
+
BytesValue.new(@val).pack(packer)
|
1213
1280
|
end
|
1214
1281
|
end
|
1215
1282
|
|
@@ -1223,9 +1290,9 @@ module Aerospike
|
|
1223
1290
|
def pack(packer)
|
1224
1291
|
# List values need an extra array and QUOTED in order to distinguish
|
1225
1292
|
# between a multiple argument array call and a local list.
|
1226
|
-
packer.
|
1227
|
-
packer.
|
1228
|
-
|
1293
|
+
packer.write_array_header(2)
|
1294
|
+
packer.write(QUOTED)
|
1295
|
+
Value.of(@list).pack(packer)
|
1229
1296
|
end
|
1230
1297
|
end
|
1231
1298
|
|
@@ -1237,13 +1304,13 @@ module Aerospike
|
|
1237
1304
|
end
|
1238
1305
|
|
1239
1306
|
def pack(packer)
|
1240
|
-
|
1307
|
+
Value.of(@map).pack(packer)
|
1241
1308
|
end
|
1242
1309
|
end
|
1243
1310
|
|
1244
1311
|
class Nil < Exp
|
1245
1312
|
def pack(packer)
|
1246
|
-
packer
|
1313
|
+
Value.of(nil).pack(packer)
|
1247
1314
|
end
|
1248
1315
|
end
|
1249
1316
|
|
@@ -1251,11 +1318,11 @@ module Aerospike
|
|
1251
1318
|
attr_reader :bytes
|
1252
1319
|
|
1253
1320
|
def initialize(e)
|
1254
|
-
@bytes = e.
|
1321
|
+
@bytes = e.bytes
|
1255
1322
|
end
|
1256
1323
|
|
1257
1324
|
def pack(packer)
|
1258
|
-
|
1325
|
+
Value.of(@bytes).pack(packer)
|
1259
1326
|
end
|
1260
1327
|
end
|
1261
1328
|
end # class Exp
|