Package com.aerospike.client.exp
Class Exp
java.lang.Object
com.aerospike.client.exp.Exp
Expression generator.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Exp
Create operator that returns absolute value of a number.static Exp
Create "add" (+) operator that applies to a variable number of expressions.static Exp
Create "and" (&&) operator that applies to a variable number of expressions.static Exp
Create integer "arithmetic right shift" (>>) operator.static Exp
Create bin expression of specified type.static Exp
Create expression that returns if bin of specified name exists.static Exp
Create expression that returns bin's integer particle type.static Exp
Create byte[] bin expression.static Exp
Create boolean bin expression.static Expression
Create final expression that contains packed byte instructions used in the wire protocol.static Exp
Create expression that rounds a floating point number up to the closest integer value.static Exp
Conditionally select an expression from a variable number of expression pairs followed by default expression action.static Exp
Create expression that returns count of integer bits that are set to 1.static Exp
Assign variable to alet(Exp...)
expression that can be accessed later.static Exp
Create expression that returns record size on disk.static Exp
digestModulo
(int mod) Create expression that returns record digest modulo as integer.static Exp
Create "divide" (/) operator that applies to a variable number of expressions.static Exp
Create equal (==) expression.static Exp
Create expression that returns true if only one of the expressions are true.static Exp
expr
(Expression e) Merge precompiled expression into a new expression tree.static Exp
Create 64 bit float bin expression.static Exp
Create expression that rounds a floating point number down to the closest integer value.static Exp
Create greater than or equal (>=) operation.static Exp
Create geospatial json string value.static Exp
Create geospatial bin expression.static Exp
geoCompare
(Exp left, Exp right) Create compare geospatial operation.static Exp
Create greater than (>) operation.static Exp
Create hll bin expression.static Exp
inf()
Create infinity value for use in CDT range expressions.static Exp
Create integer "and" (&) operator that is applied to two or more integers.static Exp
Create 64 bit integer bin expression.static Exp
Create integer "not" (~) operator.static Exp
Create integer "or" (|) operator that is applied to two or more integers.static Exp
Create integer "xor" (^) operator that is applied to two or more integers.static Exp
Create expression that returns if record has been deleted and is still in tombstone state.static Exp
Create record key expression of specified type.static Exp
Create expression that returns if the primary key is stored in the record meta data as a boolean expression.static Exp
Create expression that returns record last update time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.static Exp
Create less than or equals (<=) operation.static Exp
Define variables and expressions in scope.static Exp
Create list bin expression.static Exp
Create "log" operator for logarithm of "num" with base "base".static Exp
Create expression that scans integer bits from left (most significant bit) to right (least significant bit), looking for a search bit value.static Exp
Create integer "left shift" (<<) operator.static Exp
Create less than (<) operation.static Exp
Create map bin expression.static Exp
Create expression that returns the maximum value in a variable number of expressions.static Exp
Create expression that returns record size in memory.static Exp
Create expression that returns the minimum value in a variable number of expressions.static Exp
Create "modulo" (%) operator that determines the remainder of "numerator" divided by "denominator".static Exp
Create "multiply" (*) operator that applies to a variable number of expressions.static Exp
Create not equal (!=) expressionstatic Exp
nil()
Create nil value.static Exp
Create "not" operator expression.static Exp
Create "or" (||) operator that applies to a variable number of expressions.abstract void
pack
(com.aerospike.client.util.Packer packer) static Exp
Create "power" operator that raises a "base" to the "exponent" power.static Exp
Create expression that returns the record size.static Exp
regexCompare
(String regex, int flags, Exp bin) Create expression that performs a regex match on a string bin or string value expression.static Exp
Create expression that scans integer bits from right (least significant bit) to left (most significant bit), looking for a search bit value.static Exp
Create integer "logical right shift" (>>>) operator.static Exp
setName()
Create expression that returns record set name string.static Exp
Create expression that returns milliseconds since the record was last updated.static Exp
Create string bin expression.static Exp
Create "subtract" (-) operator that applies to a variable number of expressions.static Exp
Create expression that converts an integer to a float.static Exp
Create expression that converts a float to an integer.static Exp
ttl()
Create expression that returns record expiration time (time to live) in integer seconds.static Exp
unknown()
Create unknown value.static Exp
val
(boolean val) Create boolean value.static Exp
val
(byte[] val) Create blob byte[] value.static Exp
val
(double val) Create 64 bit floating point value.static Exp
val
(long val) Create 64 bit integer value.static Exp
Create string value.static Exp
Create Calendar value expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer.static Exp
Create list value.static Exp
Create map value.static Exp
Retrieve expression value from a variable.static Exp
voidTime()
Create expression that returns record expiration time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.static Exp
wildcard()
Create wildcard value for use in CDT expressions.
-
Field Details
-
MODIFY
public static final int MODIFY- See Also:
-
-
Constructor Details
-
Exp
public Exp()
-
-
Method Details
-
build
Create final expression that contains packed byte instructions used in the wire protocol. -
key
Create record key expression of specified type.// Integer record key >= 100000 Exp.ge(Exp.key(Type.INT), Exp.val(100000))
-
keyExists
Create expression that returns if the primary key is stored in the record meta data as a boolean expression. This would occur whenPolicy.sendKey
is true on record write. This expression usually evaluates quickly because record meta data is cached in memory.// Key exists in record meta data Exp.keyExists()
-
bin
Create bin expression of specified type.// String bin "a" == "views" Exp.eq(Exp.bin("a", Type.STRING), Exp.val("views"))
-
intBin
Create 64 bit integer bin expression.// Integer bin "a" == 200 Exp.eq(Exp.intBin("a"), Exp.val(200))
-
floatBin
Create 64 bit float bin expression.// Float bin "a" >= 1.5 Exp.ge(Exp.floatBin("a"), Exp.val(1.5))
-
stringBin
Create string bin expression.// String bin "a" == "views" Exp.eq(Exp.stringBin("a"), Exp.val("views"))
-
boolBin
Create boolean bin expression.// Boolean bin "a" == true Exp.eq(Exp.boolBin("a"), Exp.val(true))
-
blobBin
Create byte[] bin expression.// Blob bin "a" == [1,2,3] Exp.eq(Exp.blobBin("a"), Exp.val(new byte[] {1, 2, 3}))
-
geoBin
Create geospatial bin expression.// Geo bin "a" == region String region = "{ \"type\": \"AeroCircle\", \"coordinates\": [[-122.0, 37.5], 50000.0] }"; Exp.geoCompare(Exp.geoBin("loc"), Exp.geo(region))
-
listBin
Create list bin expression.// Bin a[2] == 3 Exp.eq(ListExp.getByIndex(ListReturnType.VALUE, Type.INT, Exp.val(2), Exp.listBin("a")), Exp.val(3))
-
mapBin
Create map bin expression.// Bin a["key"] == "value" Exp.eq( MapExp.getByKey(MapReturnType.VALUE, Type.STRING, Exp.val("key"), Exp.mapBin("a")), Exp.val("value"));
-
hllBin
Create hll bin expression.// HLL bin "a" count > 7 Exp.gt(HLLExp.getCount(Exp.hllBin("a")), Exp.val(7))
-
binExists
Create expression that returns if bin of specified name exists.// Bin "a" exists in record Exp.binExists("a")
-
binType
Create expression that returns bin's integer particle type. SeeParticleType
.// Bin "a" particle type is a list Exp.eq(Exp.binType("a"), Exp.val(ParticleType.LIST))
-
setName
Create expression that returns record set name string. This expression usually evaluates quickly because record meta data is cached in memory.// Record set name == "myset" Exp.eq(Exp.setName(), Exp.val("myset"))
-
recordSize
Create expression that returns the record size. This expression usually evaluates quickly because record meta data is cached in memory.Requires server version 7.0+. This expression replaces
deviceSize()
andmemorySize()
since those older expressions are equivalent on server version 7.0+.// Record size >= 100 KB Exp.ge(Exp.recordSize(), Exp.val(100 * 1024))
-
deviceSize
Create expression that returns record size on disk. If server storage-engine is memory, then zero is returned. This expression usually evaluates quickly because record meta data is cached in memory.This expression should only be used for server versions less than 7.0. Use
recordSize()
for server version 7.0+.// Record device size >= 100 KB Exp.ge(Exp.deviceSize(), Exp.val(100 * 1024))
-
memorySize
Create expression that returns record size in memory. If server storage-engine is not memory nor data-in-memory, then zero is returned. This expression usually evaluates quickly because record meta data is cached in memory.Requires server version between 5.3 inclusive and 7.0 exclusive. Use
recordSize()
for server version 7.0+.// Record memory size >= 100 KB Exp.ge(Exp.memorySize(), Exp.val(100 * 1024))
-
lastUpdate
Create expression that returns record last update time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch. This expression usually evaluates quickly because record meta data is cached in memory.// Record last update time >= 2020-01-15 Exp.ge(Exp.lastUpdate(), Exp.val(new GregorianCalendar(2020, 0, 15)))
-
sinceUpdate
Create expression that returns milliseconds since the record was last updated. This expression usually evaluates quickly because record meta data is cached in memory.// Record last updated more than 2 hours ago Exp.gt(Exp.sinceUpdate(), Exp.val(2 * 60 * 60 * 1000))
-
voidTime
Create expression that returns record expiration time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch. This expression usually evaluates quickly because record meta data is cached in memory.// Record expires on 2021-01-01 Exp.and( Exp.ge(Exp.voidTime(), Exp.val(new GregorianCalendar(2021, 0, 1))), Exp.lt(Exp.voidTime(), Exp.val(new GregorianCalendar(2021, 0, 2))))
-
ttl
Create expression that returns record expiration time (time to live) in integer seconds. This expression usually evaluates quickly because record meta data is cached in memory.// Record expires in less than 1 hour Exp.lt(Exp.ttl(), Exp.val(60 * 60))
-
isTombstone
Create expression that returns if record has been deleted and is still in tombstone state. This expression usually evaluates quickly because record meta data is cached in memory.// Deleted records that are in tombstone state. Exp.isTombstone()
-
digestModulo
Create expression that returns record digest modulo as integer. This expression usually evaluates quickly because record meta data is cached in memory.// Records that have digest(key) % 3 == 1 Exp.eq(Exp.digestModulo(3), Exp.val(1))
-
regexCompare
Create expression that performs a regex match on a string bin or string value expression.// Select string bin "a" that starts with "prefix" and ends with "suffix". // Ignore case and do not match newline. Exp.regexCompare("prefix.*suffix", RegexFlag.ICASE | RegexFlag.NEWLINE, Exp.stringBin("a"))
- Parameters:
regex
- regular expression stringflags
- regular expression bit flags. SeeRegexFlag
bin
- string bin or string value expression
-
geoCompare
Create compare geospatial operation.// Query region within coordinates. String region = "{ " + " \"type\": \"Polygon\", " + " \"coordinates\": [ " + " [[-122.500000, 37.000000],[-121.000000, 37.000000], " + " [-121.000000, 38.080000],[-122.500000, 38.080000], " + " [-122.500000, 37.000000]] " + " ] " + "}"; Exp.geoCompare(Exp.geoBin("a"), Exp.geo(region))
-
geo
Create geospatial json string value. -
val
Create boolean value. -
val
Create 64 bit integer value. -
val
Create Calendar value expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer. -
val
Create 64 bit floating point value. -
val
Create string value. -
val
Create blob byte[] value. -
val
Create list value. -
val
Create map value. For ordered maps, pass in a TreeMap or a map that implements the SortedMap interface. For unordered maps, pass in a HashMap. -
nil
Create nil value. -
inf
Create infinity value for use in CDT range expressions. -
wildcard
Create wildcard value for use in CDT expressions. -
not
Create "not" operator expression.// ! (a == 0 || a == 10) Exp.not( Exp.or( Exp.eq(Exp.intBin("a"), Exp.val(0)), Exp.eq(Exp.intBin("a"), Exp.val(10))))
-
and
Create "and" (&&) operator that applies to a variable number of expressions.// (a > 5 || a == 0) && b < 3 Exp.and( Exp.or( Exp.gt(Exp.intBin("a"), Exp.val(5)), Exp.eq(Exp.intBin("a"), Exp.val(0))), Exp.lt(Exp.intBin("b"), Exp.val(3)))
-
or
Create "or" (||) operator that applies to a variable number of expressions.// a == 0 || b == 0 Exp.or( Exp.eq(Exp.intBin("a"), Exp.val(0)), Exp.eq(Exp.intBin("b"), Exp.val(0)));
-
exclusive
Create expression that returns true if only one of the expressions are true. Requires server version 5.6.0+.// exclusive(a == 0, b == 0) Exp.exclusive( Exp.eq(Exp.intBin("a"), Exp.val(0)), Exp.eq(Exp.intBin("b"), Exp.val(0)));
-
eq
Create equal (==) expression.// a == 11 Exp.eq(Exp.intBin("a"), Exp.val(11))
-
ne
Create not equal (!=) expression// a != 13 Exp.ne(Exp.intBin("a"), Exp.val(13))
-
gt
Create greater than (>) operation.// a > 8 Exp.gt(Exp.intBin("a"), Exp.val(8))
-
ge
Create greater than or equal (>=) operation.// a >= 88 Exp.ge(Exp.intBin("a"), Exp.val(88))
-
lt
Create less than (<) operation.// a < 1000 Exp.lt(Exp.intBin("a"), Exp.val(1000))
-
le
Create less than or equals (<=) operation.// a <= 1 Exp.le(Exp.intBin("a"), Exp.val(1))
-
add
Create "add" (+) operator that applies to a variable number of expressions. Return sum of all arguments. All arguments must resolve to the same type (integer or float). Requires server version 5.6.0+.// a + b + c == 10 Exp.eq( Exp.add(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(10));
-
sub
Create "subtract" (-) operator that applies to a variable number of expressions. If only one argument is provided, return the negation of that argument. Otherwise, return the sum of the 2nd to Nth argument subtracted from the 1st argument. All arguments must resolve to the same type (integer or float). Requires server version 5.6.0+.// a - b - c > 10 Exp.gt( Exp.sub(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(10));
-
mul
Create "multiply" (*) operator that applies to a variable number of expressions. Return the product of all arguments. If only one argument is supplied, return that argument. All arguments must resolve to the same type (integer or float). Requires server version 5.6.0+.// a * b * c < 100 Exp.lt( Exp.mul(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(100));
-
div
Create "divide" (/) operator that applies to a variable number of expressions. If there is only one argument, returns the reciprocal for that argument. Otherwise, return the first argument divided by the product of the rest. All arguments must resolve to the same type (integer or float). Requires server version 5.6.0+.// a / b / c > 1 Exp.gt( Exp.div(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(1));
-
pow
Create "power" operator that raises a "base" to the "exponent" power. All arguments must resolve to floats. Requires server version 5.6.0+.// pow(a, 2.0) == 4.0 Exp.eq( Exp.pow(Exp.floatBin("a"), Exp.val(2.0)), Exp.val(4.0));
-
log
Create "log" operator for logarithm of "num" with base "base". All arguments must resolve to floats. Requires server version 5.6.0+.// log(a, 2.0) == 4.0 Exp.eq( Exp.log(Exp.floatBin("a"), Exp.val(2.0)), Exp.val(4.0));
-
mod
Create "modulo" (%) operator that determines the remainder of "numerator" divided by "denominator". All arguments must resolve to integers. Requires server version 5.6.0+.// a % 10 == 0 Exp.eq( Exp.mod(Exp.intBin("a"), Exp.val(10)), Exp.val(0));
-
abs
Create operator that returns absolute value of a number. All arguments must resolve to integer or float. Requires server version 5.6.0+.// abs(a) == 1 Exp.eq( Exp.abs(Exp.intBin("a")), Exp.val(1));
-
floor
Create expression that rounds a floating point number down to the closest integer value. The return type is float. Requires server version 5.6.0+.// floor(2.95) == 2.0 Exp.eq( Exp.floor(Exp.val(2.95)), Exp.val(2.0));
-
ceil
Create expression that rounds a floating point number up to the closest integer value. The return type is float. Requires server version 5.6.0+.// ceil(2.15) >= 3.0 Exp.ge( Exp.ceil(Exp.val(2.15)), Exp.val(3.0));
-
toInt
Create expression that converts a float to an integer. Requires server version 5.6.0+.// int(2.5) == 2 Exp.eq( Exp.toInt(Exp.val(2.5)), Exp.val(2));
-
toFloat
Create expression that converts an integer to a float. Requires server version 5.6.0+.// float(2) == 2.0 Exp.eq( Exp.toFloat(Exp.val(2))), Exp.val(2.0));
-
intAnd
Create integer "and" (&) operator that is applied to two or more integers. All arguments must resolve to integers. Requires server version 5.6.0+.// a & 0xff == 0x11 Exp.eq( Exp.intAnd(Exp.intBin("a"), Exp.val(0xff)), Exp.val(0x11));
-
intOr
Create integer "or" (|) operator that is applied to two or more integers. All arguments must resolve to integers. Requires server version 5.6.0+.// a | 0x10 != 0 Exp.ne( Exp.intOr(Exp.intBin("a"), Exp.val(0x10)), Exp.val(0));
-
intXor
Create integer "xor" (^) operator that is applied to two or more integers. All arguments must resolve to integers. Requires server version 5.6.0+.// a ^ b == 16 Exp.eq( Exp.intXor(Exp.intBin("a"), Exp.intBin("b")), Exp.val(16));
-
intNot
Create integer "not" (~) operator. Requires server version 5.6.0+.// ~a == 7 Exp.eq( Exp.intNot(Exp.intBin("a")), Exp.val(7));
-
lshift
Create integer "left shift" (<<) operator. Requires server version 5.6.0+.// a << 8 > 0xff Exp.gt( Exp.lshift(Exp.intBin("a"), Exp.val(8)), Exp.val(0xff));
-
rshift
Create integer "logical right shift" (>>>) operator. Requires server version 5.6.0+.// a >>> 8 > 0xff Exp.gt( Exp.rshift(Exp.intBin("a"), Exp.val(8)), Exp.val(0xff));
-
arshift
Create integer "arithmetic right shift" (>>) operator. Requires server version 5.6.0+.// a >> 8 > 0xff Exp.gt( Exp.arshift(Exp.intBin("a"), Exp.val(8)), Exp.val(0xff));
-
count
Create expression that returns count of integer bits that are set to 1. Requires server version 5.6.0+.// count(a) == 4 Exp.eq( Exp.count(Exp.intBin("a")), Exp.val(4));
-
lscan
Create expression that scans integer bits from left (most significant bit) to right (least significant bit), looking for a search bit value. When the search value is found, the index of that bit (where the most significant bit is index 0) is returned. If "search" is true, the scan will search for the bit value 1. If "search" is false it will search for bit value 0. Requires server version 5.6.0+.// lscan(a, true) == 4 Exp.eq( Exp.lscan(Exp.intBin("a"), Exp.val(true)), Exp.val(4));
-
rscan
Create expression that scans integer bits from right (least significant bit) to left (most significant bit), looking for a search bit value. When the search value is found, the index of that bit (where the most significant bit is index 0) is returned. If "search" is true, the scan will search for the bit value 1. If "search" is false it will search for bit value 0. Requires server version 5.6.0+.// rscan(a, true) == 4 Exp.eq( Exp.rscan(Exp.intBin("a"), Exp.val(true)), Exp.val(4));
-
min
Create expression that returns the minimum value in a variable number of expressions. All arguments must be the same type (integer or float). Requires server version 5.6.0+.// min(a, b, c) > 0 Exp.gt( Exp.min(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(0));
-
max
Create expression that returns the maximum value in a variable number of expressions. All arguments must be the same type (integer or float). Requires server version 5.6.0+.// max(a, b, c) > 100 Exp.gt( Exp.max(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")), Exp.val(100));
-
cond
Conditionally select an expression from a variable number of expression pairs followed by default expression action. Requires server version 5.6.0+.Args Format: bool exp1, action exp1, bool exp2, action exp2, ..., action-default // Apply operator based on type. Exp.cond( Exp.eq(Exp.intBin("type"), Exp.val(0)), Exp.add(Exp.intBin("val1"), Exp.intBin("val2")), Exp.eq(Exp.intBin("type"), Exp.val(1)), Exp.sub(Exp.intBin("val1"), Exp.intBin("val2")), Exp.eq(Exp.intBin("type"), Exp.val(2)), Exp.mul(Exp.intBin("val1"), Exp.intBin("val2")), Exp.val(-1));
-
let
Define variables and expressions in scope. Requires server version 5.6.0+.Args Format: <def1>, <def2>, ..., <exp> def: {@link Exp#def(String, Exp)} exp: Scoped expression
// 5 < a < 10 Exp.let( Exp.def("x", Exp.intBin("a")), Exp.and( Exp.lt(Exp.val(5), Exp.var("x")), Exp.lt(Exp.var("x"), Exp.val(10))));
-
def
Assign variable to alet(Exp...)
expression that can be accessed later. Requires server version 5.6.0+.// 5 < a < 10 Exp.let( Exp.def("x", Exp.intBin("a")), Exp.and( Exp.lt(Exp.val(5), Exp.var("x")), Exp.lt(Exp.var("x"), Exp.val(10))));
-
var
Retrieve expression value from a variable. Requires server version 5.6.0+.// 5 < a < 10 Exp.let( Exp.def("x", Exp.intBin("a")), Exp.and( Exp.lt(Exp.val(5), Exp.var("x")), Exp.lt(Exp.var("x"), Exp.val(10))));
-
unknown
Create unknown value. Used to intentionally fail an expression. The failure can be ignored withExpWriteFlags.EVAL_NO_FAIL
orExpReadFlags.EVAL_NO_FAIL
. Requires server version 5.6.0+.// double v = balance - 100.0; // return (v > 0.0)? v : unknown; Exp.let( Exp.def("v", Exp.sub(Exp.floatBin("balance"), Exp.val(100.0))), Exp.cond( Exp.ge(Exp.var("v"), Exp.val(0.0)), Exp.var("v"), Exp.unknown()));
-
expr
Merge precompiled expression into a new expression tree. Useful for storing common precompiled expressions and then reusing these expressions as part of a greater expression.// Merge precompiled expression into new expression. Expression e = Exp.build(Exp.eq(Exp.intBin("a"), Exp.val(200))); Expression merged = Exp.build(Exp.and(Exp.expr(e), Exp.eq(Exp.intBin("b"), Exp.val(100))));
-
pack
public abstract void pack(com.aerospike.client.util.Packer packer)
-