public abstract class Exp extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Exp.Type
Expression type.
|
Modifier and Type | Field and Description |
---|---|
static int |
MODIFY |
Constructor and Description |
---|
Exp() |
Modifier and Type | Method and Description |
---|---|
static Exp |
abs(Exp value)
Create operator that returns absolute value of a number.
|
static Exp |
add(Exp... exps)
Create "add" (+) operator that applies to a variable number of expressions.
|
static Exp |
and(Exp... exps)
Create "and" (&&) operator that applies to a variable number of expressions.
|
static Exp |
arshift(Exp value,
Exp shift)
Create integer "arithmetic right shift" (>>) operator.
|
static Exp |
bin(String name,
Exp.Type type)
Create bin expression of specified type.
|
static Exp |
binExists(String name)
Create expression that returns if bin of specified name exists.
|
static Exp |
binType(String name)
Create expression that returns bin's integer particle type.
|
static Exp |
blobBin(String name)
Create byte[] bin expression.
|
static Exp |
boolBin(String name)
Create boolean bin expression.
|
static Expression |
build(Exp exp)
Create final expression that contains packed byte instructions used in the wire protocol.
|
static Exp |
ceil(Exp num)
Create expression that rounds a floating point number up to the closest integer value.
|
static Exp |
cond(Exp... exps)
Conditionally select an expression from a variable number of expression pairs
followed by default expression action.
|
static Exp |
count(Exp exp)
Create expression that returns count of integer bits that are set to 1.
|
static Exp |
def(String name,
Exp value)
Assign variable to a
let(Exp...) expression that can be accessed later. |
static Exp |
deviceSize()
Create expression that returns record size on disk.
|
static Exp |
digestModulo(int mod)
Create expression that returns record digest modulo as integer.
|
static Exp |
div(Exp... exps)
Create "divide" (/) operator that applies to a variable number of expressions.
|
static Exp |
eq(Exp left,
Exp right)
Create equal (==) expression.
|
static Exp |
exclusive(Exp... exps)
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 |
floatBin(String name)
Create 64 bit float bin expression.
|
static Exp |
floor(Exp num)
Create expression that rounds a floating point number down to the closest integer value.
|
static Exp |
ge(Exp left,
Exp right)
Create greater than or equal (>=) operation.
|
static Exp |
geo(String val)
Create geospatial json string value.
|
static Exp |
geoBin(String name)
Create geospatial bin expression.
|
static Exp |
geoCompare(Exp left,
Exp right)
Create compare geospatial operation.
|
static Exp |
gt(Exp left,
Exp right)
Create greater than (>) operation.
|
static Exp |
hllBin(String name)
Create hll bin expression.
|
static Exp |
intAnd(Exp... exps)
Create integer "and" (&) operator that is applied to two or more integers.
|
static Exp |
intBin(String name)
Create 64 bit integer bin expression.
|
static Exp |
intNot(Exp exp)
Create integer "not" (~) operator.
|
static Exp |
intOr(Exp... exps)
Create integer "or" (|) operator that is applied to two or more integers.
|
static Exp |
intXor(Exp... exps)
Create integer "xor" (^) operator that is applied to two or more integers.
|
static Exp |
isTombstone()
Create expression that returns if record has been deleted and is still in tombstone state.
|
static Exp |
key(Exp.Type type)
Create record key expression of specified type.
|
static Exp |
keyExists()
Create expression that returns if the primary key is stored in the record meta data
as a boolean expression.
|
static Exp |
lastUpdate()
Create expression that returns record last update time expressed as 64 bit integer
nanoseconds since 1970-01-01 epoch.
|
static Exp |
le(Exp left,
Exp right)
Create less than or equals (<=) operation.
|
static Exp |
let(Exp... exps)
Define variables and expressions in scope.
|
static Exp |
listBin(String name)
Create list bin expression.
|
static Exp |
log(Exp num,
Exp base)
Create "log" operator for logarithm of "num" with base "base".
|
static Exp |
lscan(Exp value,
Exp search)
Create expression that scans integer bits from left (most significant bit) to
right (least significant bit), looking for a search bit value.
|
static Exp |
lshift(Exp value,
Exp shift)
Create integer "left shift" (<<) operator.
|
static Exp |
lt(Exp left,
Exp right)
Create less than (<) operation.
|
static Exp |
mapBin(String name)
Create map bin expression.
|
static Exp |
max(Exp... exps)
Create expression that returns the maximum value in a variable number of expressions.
|
static Exp |
memorySize()
Create expression that returns record size in memory.
|
static Exp |
min(Exp... exps)
Create expression that returns the minimum value in a variable number of expressions.
|
static Exp |
mod(Exp numerator,
Exp denominator)
Create "modulo" (%) operator that determines the remainder of "numerator"
divided by "denominator".
|
static Exp |
mul(Exp... exps)
Create "multiply" (*) operator that applies to a variable number of expressions.
|
static Exp |
ne(Exp left,
Exp right)
Create not equal (!=) expression
|
static Exp |
nil()
Create nil value.
|
static Exp |
not(Exp exp)
Create "not" operator expression.
|
static Exp |
or(Exp... exps)
Create "or" (||) operator that applies to a variable number of expressions.
|
abstract void |
pack(com.aerospike.client.util.Packer packer) |
static Exp |
pow(Exp base,
Exp exponent)
Create "power" operator that raises a "base" to the "exponent" power.
|
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 |
rscan(Exp value,
Exp search)
Create expression that scans integer bits from right (least significant bit) to
left (most significant bit), looking for a search bit value.
|
static Exp |
rshift(Exp value,
Exp shift)
Create integer "logical right shift" (>>>) operator.
|
static Exp |
setName()
Create expression that returns record set name string.
|
static Exp |
sinceUpdate()
Create expression that returns milliseconds since the record was last updated.
|
static Exp |
stringBin(String name)
Create string bin expression.
|
static Exp |
sub(Exp... exps)
Create "subtract" (-) operator that applies to a variable number of expressions.
|
static Exp |
toFloat(Exp num)
Create expression that converts an integer to a float.
|
static Exp |
toInt(Exp num)
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(Calendar val)
Create Calendar value expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer.
|
static Exp |
val(double val)
Create 64 bit floating point value.
|
static Exp |
val(List<?> list)
Create list value.
|
static Exp |
val(long val)
Create 64 bit integer value.
|
static Exp |
val(Map<?,?> map)
Create map value.
|
static Exp |
val(String val)
Create string value.
|
static Exp |
var(String name)
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.
|
public static final int MODIFY
public static Expression build(Exp exp)
public static Exp key(Exp.Type type)
// Integer record key >= 100000
Exp.ge(Exp.key(Type.INT), Exp.val(100000))
public static Exp keyExists()
Policy.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()
public static Exp bin(String name, Exp.Type type)
// String bin "a" == "views"
Exp.eq(Exp.bin("a", Type.STRING), Exp.val("views"))
public static Exp intBin(String name)
// Integer bin "a" == 200
Exp.eq(Exp.intBin("a"), Exp.val(200))
public static Exp floatBin(String name)
// Float bin "a" >= 1.5
Exp.ge(Exp.floatBin("a"), Exp.val(1.5))
public static Exp stringBin(String name)
// String bin "a" == "views"
Exp.eq(Exp.stringBin("a"), Exp.val("views"))
public static Exp boolBin(String name)
// Boolean bin "a" == true
Exp.eq(Exp.boolBin("a"), Exp.val(true))
public static Exp blobBin(String name)
// Blob bin "a" == [1,2,3]
Exp.eq(Exp.blobBin("a"), Exp.val(new byte[] {1, 2, 3}))
public static Exp geoBin(String name)
// Geo bin "a" == region
String region = "{ \"type\": \"AeroCircle\", \"coordinates\": [[-122.0, 37.5], 50000.0] }";
Exp.geoCompare(Exp.geoBin("loc"), Exp.geo(region))
public static Exp listBin(String name)
// Bin a[2] == 3
Exp.eq(ListExp.getByIndex(ListReturnType.VALUE, Type.INT, Exp.val(2), Exp.listBin("a")), Exp.val(3))
public static Exp mapBin(String name)
// Bin a["key"] == "value"
Exp.eq(
MapExp.getByKey(MapReturnType.VALUE, Type.STRING, Exp.val("key"), Exp.mapBin("a")),
Exp.val("value"));
public static Exp hllBin(String name)
// HLL bin "a" count > 7
Exp.gt(HLLExp.getCount(Exp.hllBin("a")), Exp.val(7))
public static Exp binExists(String name)
// Bin "a" exists in record
Exp.binExists("a")
public static Exp binType(String name)
ParticleType
.
// Bin "a" particle type is a list
Exp.eq(Exp.binType("a"), Exp.val(ParticleType.LIST))
public static Exp setName()
// Record set name == "myset"
Exp.eq(Exp.setName(), Exp.val("myset"))
public static Exp deviceSize()
// Record device size >= 100 KB
Exp.ge(Exp.deviceSize(), Exp.val(100 * 1024))
public static Exp memorySize()
Requires server version 5.3.0+
// Record memory size >= 100 KB
Exp.ge(Exp.memorySize(), Exp.val(100 * 1024))
public static Exp lastUpdate()
// Record last update time >= 2020-01-15
Exp.ge(Exp.lastUpdate(), Exp.val(new GregorianCalendar(2020, 0, 15)))
public static Exp sinceUpdate()
// Record last updated more than 2 hours ago
Exp.gt(Exp.sinceUpdate(), Exp.val(2 * 60 * 60 * 1000))
public static Exp voidTime()
// 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))))
public static Exp ttl()
// Record expires in less than 1 hour
Exp.lt(Exp.ttl(), Exp.val(60 * 60))
public static Exp isTombstone()
// Deleted records that are in tombstone state.
Exp.isTombstone()
public static Exp digestModulo(int mod)
// Records that have digest(key) % 3 == 1
Exp.eq(Exp.digestModulo(3), Exp.val(1))
public static Exp regexCompare(String regex, int flags, Exp bin)
// 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"))
regex
- regular expression stringflags
- regular expression bit flags. See RegexFlag
bin
- string bin or string value expressionpublic static Exp geoCompare(Exp left, Exp right)
// 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))
public static Exp val(boolean val)
public static Exp val(long val)
public static Exp val(Calendar val)
public static Exp val(double val)
public static Exp val(byte[] val)
public static Exp nil()
public static Exp not(Exp exp)
// ! (a == 0 || a == 10)
Exp.not(
Exp.or(
Exp.eq(Exp.intBin("a"), Exp.val(0)),
Exp.eq(Exp.intBin("a"), Exp.val(10))))
public static Exp and(Exp... exps)
// (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)))
public static Exp or(Exp... exps)
// a == 0 || b == 0
Exp.or(
Exp.eq(Exp.intBin("a"), Exp.val(0)),
Exp.eq(Exp.intBin("b"), Exp.val(0)));
public static Exp exclusive(Exp... exps)
// exclusive(a == 0, b == 0)
Exp.exclusive(
Exp.eq(Exp.intBin("a"), Exp.val(0)),
Exp.eq(Exp.intBin("b"), Exp.val(0)));
public static Exp eq(Exp left, Exp right)
// a == 11
Exp.eq(Exp.intBin("a"), Exp.val(11))
public static Exp ne(Exp left, Exp right)
// a != 13
Exp.ne(Exp.intBin("a"), Exp.val(13))
public static Exp gt(Exp left, Exp right)
// a > 8
Exp.gt(Exp.intBin("a"), Exp.val(8))
public static Exp ge(Exp left, Exp right)
// a >= 88
Exp.ge(Exp.intBin("a"), Exp.val(88))
public static Exp lt(Exp left, Exp right)
// a < 1000
Exp.lt(Exp.intBin("a"), Exp.val(1000))
public static Exp le(Exp left, Exp right)
// a <= 1
Exp.le(Exp.intBin("a"), Exp.val(1))
public static Exp add(Exp... exps)
// a + b + c == 10
Exp.eq(
Exp.add(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(10));
public static Exp sub(Exp... exps)
// a - b - c > 10
Exp.gt(
Exp.sub(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(10));
public static Exp mul(Exp... exps)
// a * b * c < 100
Exp.lt(
Exp.mul(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(100));
public static Exp div(Exp... exps)
// a / b / c > 1
Exp.gt(
Exp.div(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(1));
public static Exp pow(Exp base, Exp exponent)
// pow(a, 2.0) == 4.0
Exp.eq(
Exp.pow(Exp.floatBin("a"), Exp.val(2.0)),
Exp.val(4.0));
public static Exp log(Exp num, Exp base)
// log(a, 2.0) == 4.0
Exp.eq(
Exp.log(Exp.floatBin("a"), Exp.val(2.0)),
Exp.val(4.0));
public static Exp mod(Exp numerator, Exp denominator)
// a % 10 == 0
Exp.eq(
Exp.mod(Exp.intBin("a"), Exp.val(10)),
Exp.val(0));
public static Exp abs(Exp value)
// abs(a) == 1
Exp.eq(
Exp.abs(Exp.intBin("a")),
Exp.val(1));
public static Exp floor(Exp num)
// floor(2.95) == 2.0
Exp.eq(
Exp.floor(Exp.val(2.95)),
Exp.val(2.0));
public static Exp ceil(Exp num)
// ceil(2.15) >= 3.0
Exp.ge(
Exp.ceil(Exp.val(2.15)),
Exp.val(3.0));
public static Exp toInt(Exp num)
// int(2.5) == 2
Exp.eq(
Exp.toInt(Exp.val(2.5)),
Exp.val(2));
public static Exp toFloat(Exp num)
// float(2) == 2.0
Exp.eq(
Exp.toFloat(Exp.val(2))),
Exp.val(2.0));
public static Exp intAnd(Exp... exps)
// a & 0xff == 0x11
Exp.eq(
Exp.intAnd(Exp.intBin("a"), Exp.val(0xff)),
Exp.val(0x11));
public static Exp intOr(Exp... exps)
// a | 0x10 != 0
Exp.ne(
Exp.intOr(Exp.intBin("a"), Exp.val(0x10)),
Exp.val(0));
public static Exp intXor(Exp... exps)
// a ^ b == 16
Exp.eq(
Exp.intXor(Exp.intBin("a"), Exp.intBin("b")),
Exp.val(16));
public static Exp intNot(Exp exp)
// ~a == 7
Exp.eq(
Exp.intNot(Exp.intBin("a")),
Exp.val(7));
public static Exp lshift(Exp value, Exp shift)
// a << 8 > 0xff
Exp.gt(
Exp.lshift(Exp.intBin("a"), Exp.val(8)),
Exp.val(0xff));
public static Exp rshift(Exp value, Exp shift)
// a >>> 8 > 0xff
Exp.gt(
Exp.rshift(Exp.intBin("a"), Exp.val(8)),
Exp.val(0xff));
public static Exp arshift(Exp value, Exp shift)
// a >> 8 > 0xff
Exp.gt(
Exp.arshift(Exp.intBin("a"), Exp.val(8)),
Exp.val(0xff));
public static Exp count(Exp exp)
// count(a) == 4
Exp.eq(
Exp.count(Exp.intBin("a")),
Exp.val(4));
public static Exp lscan(Exp value, Exp search)
// lscan(a, true) == 4
Exp.eq(
Exp.lscan(Exp.intBin("a"), Exp.val(true)),
Exp.val(4));
public static Exp rscan(Exp value, Exp search)
// rscan(a, true) == 4
Exp.eq(
Exp.rscan(Exp.intBin("a"), Exp.val(true)),
Exp.val(4));
public static Exp min(Exp... exps)
// min(a, b, c) > 0
Exp.gt(
Exp.min(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(0));
public static Exp max(Exp... exps)
// max(a, b, c) > 100
Exp.gt(
Exp.max(Exp.intBin("a"), Exp.intBin("b"), Exp.intBin("c")),
Exp.val(100));
public static Exp cond(Exp... exps)
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));
public static Exp let(Exp... exps)
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))));
public static Exp def(String name, Exp value)
let(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))));
public static Exp var(String name)
// 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))));
public static Exp unknown()
ExpWriteFlags.EVAL_NO_FAIL
or ExpReadFlags.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()));
public static Exp expr(Expression e)
// 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))));
public abstract void pack(com.aerospike.client.util.Packer packer)
Copyright © 2012–2021 Aerospike, Inc. All rights reserved.