Arithmetic
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
Arithmetic expressions compute numeric results—integers or floats—from bins, constants, and nested expressions. Use them in read/write operation expressions (for example projection or computed writes), inside comparison expressions when you need a derived value on the left or right, and anywhere the client API accepts a numeric expression.
Operators include add, sub, mul, div, pow, log, mod, abs, floor, ceil, min, max, to_int, to_float, and integer bitwise helpers (int_and, int_or, int_xor, int_not, shifts, int_count, int_lscan, int_rscan). Operand types must match the operator (for example, pow and log use floats; bitwise operations use integers). These operations require Database 5.6.0 or later unless noted otherwise.
Numeric operations typically act on children of the same type only. For example, Exp.add(Exp.val(1), Exp.val(2.0)) is an error as float cannot be added to an integer. Exp.toFloat(...) and Exp.toInt(...) can be used to convert numeric types.
For boolean filters on records (true/false/unknown), wrap numeric results in a comparison or combine with logic expressions. Nested document scenarios often compose arithmetic with path or map/list expressions.
The Developer SDK’s AEL text syntax expresses the same arithmetic inline, for example ($.price * $.qty) > 1000.
Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the Exp builder on the other seven. See the AEL reference for AEL grammar.
Ops
abs(value)Returns the absolute value of value. The result keeps the type it was given: an integer operand yields an integer, a float operand yields a float.
| Name | Type | Description |
|---|---|---|
value | integer or float | Number to take the absolute value of. Any expression that evaluates to an integer or a float. |
integer or float Find records where the absolute value of the difference between integer bins x1 and x2 is greater than 1.
String exp = "abs($.x1 - $.x2) > 1";exp = "abs($.x1 - $.x2) > 1"use aerospike::expressions::{gt, int_bin, int_val, num_abs, num_sub};
let exp = gt(num_abs(num_sub(vec![int_bin("x1".into()), int_bin("x2".into())])), int_val(1));Expression exp = Exp.Build( Exp.GT( Exp.Abs(Exp.Sub(Exp.IntBin("x1"), Exp.IntBin("x2"))), Exp.Val(1)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpNumAbs(as.ExpNumSub(as.ExpIntBin("x1"), as.ExpIntBin("x2"))), as.ExpIntVal(1))// The Node.js client's exp.abs builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_abs(as_exp_sub( as_exp_bin_int("x1"), as_exp_bin_int("x2"))), as_exp_int(1)));Expression exp = Exp.build( Exp.gt( Exp.abs(Exp.sub( Exp.intBin("x1"), Exp.intBin("x2"))), Exp.val(1)));from aerospike_helpers.expressions import Abs, GT, IntBin, Sub
exp = GT(Abs(Sub(IntBin("x1"), IntBin("x2"))), 1).compile()add(arg0, arg1, ...)Returns the sum of its arguments. Every argument must be the same numeric type — all integers or all floats. Mixing them is rejected.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | First number to add. |
arg1 | integer or float | Second number to add. |
... | integer or float | Any further numbers to add. |
integer or float Find records where the sum of integer bins apples and bananas is greater than 10.
String exp = "$.apples + $.bananas > 10";exp = "$.apples + $.bananas > 10"use aerospike::expressions::{gt, int_bin, int_val, num_add};
let exp = gt(num_add(vec![int_bin("apples".into()), int_bin("bananas".into())]), int_val(10));Expression exp = Exp.Build( Exp.GT( Exp.Add(Exp.IntBin("apples"), Exp.IntBin("bananas")), Exp.Val(10)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpNumAdd(as.ExpIntBin("apples"), as.ExpIntBin("bananas")), as.ExpIntVal(10))const exp = Aerospike.exp
const filterExp = exp.gt( exp.add(exp.binInt('apples'), exp.binInt('bananas')), exp.int(10))as_exp_build(predexp, as_exp_cmp_gt( as_exp_add( as_exp_bin_int("apples"), as_exp_bin_int("bananas")), as_exp_int(10)));Expression exp = Exp.build( Exp.gt( Exp.add( Exp.intBin("apples"), Exp.intBin("bananas")), Exp.val(10)));from aerospike_helpers.expressions import Add, GT, IntBin
exp = GT(Add(IntBin("apples"), IntBin("bananas")), 10).compile()ceil(value)Returns value rounded up to the nearest whole number, as a float.
| Name | Type | Description |
|---|---|---|
value | float | Float to round up. |
float Find records where the ceiling of float bin value equals 2.0.
String exp = "ceil($.value) == 2.0";exp = "ceil($.value) == 2.0"use aerospike::expressions::{eq, float_bin, float_val, num_ceil};
let exp = eq(num_ceil(float_bin("value".into())), float_val(2.0));Expression exp = Exp.Build( Exp.EQ( Exp.Ceil(Exp.FloatBin("value")), Exp.Val(2.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpNumCeil(as.ExpFloatBin("value")), as.ExpFloatVal(2.0))// The Node.js client's exp.ceil builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_eq( as_exp_ceil(as_exp_bin_float("value")), as_exp_float(2.0)));Expression exp = Exp.build( Exp.eq( Exp.ceil(Exp.floatBin("value")), Exp.val(2.0)));from aerospike_helpers.expressions import Ceil, Eq, FloatBin
exp = Eq(Ceil(FloatBin("value")), 2.0).compile()div(arg0, arg1, ...)Returns its arguments divided from left to right, so div(10, 5, 2) is (10 / 5) / 2. Integer operands divide as integers, so div(10, 4) is 2 rather than 2.5. Dividing by zero fails the expression. Every argument must be the same numeric type — all integers or all floats. Mixing them is rejected.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | Number to divide. |
arg1 | integer or float | Number to divide by. |
... | integer or float | Any further divisors, applied left to right. |
integer or float Find records where candy divided by kids (as floats) is less than 1.0.
String exp = "$.candy:INT.toFloat() / $.kids:INT.toFloat() < 1.0";exp = "$.candy:INT.toFloat() / $.kids:INT.toFloat() < 1.0"use aerospike::expressions::{float_val, int_bin, lt, num_div, to_float};
let exp = lt( num_div(vec![ to_float(int_bin("candy".into())), to_float(int_bin("kids".into())), ]), float_val(1.0));Expression exp = Exp.Build( Exp.LT( Exp.Div(Exp.ToFloat(Exp.IntBin("candy")), Exp.ToFloat(Exp.IntBin("kids"))), Exp.Val(1.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpNumDiv(as.ExpToFloat(as.ExpIntBin("candy")), as.ExpToFloat(as.ExpIntBin("kids"))), as.ExpFloatVal(1.0))// The Node.js client's exp.toFloat builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_lt( as_exp_div( as_exp_to_float(as_exp_bin_int("candy")), as_exp_to_float(as_exp_bin_int("kids"))), as_exp_float(1.0)));Expression exp = Exp.build( Exp.lt( Exp.div( Exp.toFloat(Exp.intBin("candy")), Exp.toFloat(Exp.intBin("kids"))), Exp.val(1.0)));from aerospike_helpers.expressions import Div, FloatBin, IntBin, LT, ToFloat
exp = LT( Div(ToFloat(IntBin("candy")), ToFloat(IntBin("kids"))), 1.0,).compile()floor(value)Returns value rounded down to the nearest whole number, as a float.
| Name | Type | Description |
|---|---|---|
value | float | Float to round down. |
float Find records where the floor of float bin value equals 2.0.
String exp = "floor($.value) == 2.0";exp = "floor($.value) == 2.0"use aerospike::expressions::{eq, float_bin, float_val, num_floor};
let exp = eq(num_floor(float_bin("value".into())), float_val(2.0));Expression exp = Exp.Build( Exp.EQ( Exp.Floor(Exp.FloatBin("value")), Exp.Val(2.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpNumFloor(as.ExpFloatBin("value")), as.ExpFloatVal(2.0))// The Node.js client's exp.floor builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_eq( as_exp_floor(as_exp_bin_float("value")), as_exp_float(2.0)));Expression exp = Exp.build( Exp.eq( Exp.floor(Exp.floatBin("value")), Exp.val(2.0)));from aerospike_helpers.expressions import Eq, FloatBin, Floor
exp = Eq(Floor(FloatBin("value")), 2.0).compile()int_and(arg0, arg1, ...)Returns the bitwise AND of two or more integers.
| Name | Type | Description |
|---|---|---|
arg0 | integer | First integer. |
arg1 | integer | Second integer. |
... | integer | Any further integers. |
integer Find records where integer bin flags bitwise-AND mask 0xF is non-zero.
String exp = "($.flags & 0xF) != 0";exp = "($.flags & 0xF) != 0"use aerospike::expressions::{int_and, int_bin, int_val, ne};
let exp = ne(int_and(vec![int_bin("flags".into()), int_val(0xf)]), int_val(0));Expression exp = Exp.Build( Exp.NE( Exp.IntAnd(Exp.IntBin("flags"), Exp.Val(0xF)), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpNotEq( as.ExpIntAnd(as.ExpIntBin("flags"), as.ExpIntVal(0xF)), as.ExpIntVal(0))const exp = Aerospike.exp
const filterExp = exp.ne( exp.intAnd(exp.binInt('flags'), exp.int(0xf)), exp.int(0))as_exp_build(predexp, as_exp_cmp_ne( as_exp_int_and(as_exp_bin_int("flags"), as_exp_int(0xF)), as_exp_int(0)));Expression exp = Exp.build( Exp.ne( Exp.intAnd(Exp.intBin("flags"), Exp.val(0xF)), Exp.val(0)));from aerospike_helpers.expressions import IntAnd, IntBin, NE
exp = NE(IntAnd(IntBin("flags"), 0xF), 0).compile()int_arshift(value, by_numbits)Returns value shifted right by by_numbits bits, preserving the sign, so int_arshift(-8, 1) is -4.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to shift. |
by_numbits | integer | Number of bit positions to shift by. |
integer Find records where arithmetic right-shift of integer bin value by 3 bits (divide by 8) is less than 1000.
String exp = "($.value >> 3) < 1000";exp = "($.value >> 3) < 1000"use aerospike::expressions::{int_arshift, int_bin, int_val, lt};
let exp = lt(int_arshift(int_bin("value".into()), int_val(3)), int_val(1000));Expression exp = Exp.Build( Exp.LT( Exp.ARshift(Exp.IntBin("value"), Exp.Val(3)), Exp.Val(1000)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpIntARShift(as.ExpIntBin("value"), as.ExpIntVal(3)), as.ExpIntVal(1000))// The Node.js client's exp.intArshift builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_lt( as_exp_int_arshift(as_exp_bin_int("value"), as_exp_int(3)), as_exp_int(1000)));Expression exp = Exp.build( Exp.lt( Exp.arshift(Exp.intBin("value"), Exp.val(3)), Exp.val(1000)));from aerospike_helpers.expressions import IntArithmeticRightShift, IntBin, LT
exp = LT(IntArithmeticRightShift(IntBin("value"), 3), 1000).compile()int_count(value)Returns the number of bits set to 1 in value.
| Name | Type | Description |
|---|---|---|
value | integer | Integer whose bits set to 1 are counted. |
integer Find records where the population count of integer bin visits is greater than 15.
String exp = "countOneBits($.visits) > 15";exp = "countOneBits($.visits) > 15"use aerospike::expressions::{gt, int_bin, int_count, int_val};
let exp = gt(int_count(int_bin("visits".into())), int_val(15));Expression exp = Exp.Build( Exp.GT( Exp.Count(Exp.IntBin("visits")), Exp.Val(15)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntCount(as.ExpIntBin("visits")), as.ExpIntVal(15))// The Node.js client's exp.intCount builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_count(as_exp_bin_int("visits")), as_exp_int(15)));Expression exp = Exp.build( Exp.gt( Exp.count(Exp.intBin("visits")), Exp.val(15)));from aerospike_helpers.expressions import GT, IntBin, IntCount
exp = GT(IntCount(IntBin("visits")), 15).compile()int_lscan(value, search)Returns the index of the first bit in value that matches search, scanning from the most significant bit, which is index 0. When search is true the scan looks for a bit set to 1; when false, for a bit set to 0.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to scan. |
search | boolean | Bit value to look for: true finds a bit set to 1, false finds a bit set to 0. |
integer Find records where a left-scan for a 0 bit in integer bin value returns an index greater than 30, so its 31 most significant bits are all 1, as in a small negative number.
String exp = "findBitLeft(x: $.value, value: false) > 30";exp = "findBitLeft(x: $.value, value: false) > 30"use aerospike::expressions::{bool_val, gt, int_bin, int_lscan, int_val};
let exp = gt(int_lscan(int_bin("value".into()), bool_val(false)), int_val(30));Expression exp = Exp.Build( Exp.GT( Exp.Lscan(Exp.IntBin("value"), Exp.Val(false)), Exp.Val(30)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntLScan(as.ExpIntBin("value"), as.ExpBoolVal(false)), as.ExpIntVal(30))// The Node.js client's exp.intLscan builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_lscan( as_exp_bin_int("value"), as_exp_bool(false)), as_exp_int(30)));Expression exp = Exp.build( Exp.gt( Exp.lscan(Exp.intBin("value"), Exp.val(false)), Exp.val(30)));from aerospike_helpers.expressions import GT, IntBin, IntLeftScan
exp = GT(IntLeftScan(IntBin("value"), False), 30).compile()int_lshift(value, by_numbits)Returns value shifted left by by_numbits bits.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to shift. |
by_numbits | integer | Number of bit positions to shift by. |
integer Find records where integer bin visits left-shifted by 1 bit is greater than 100.
String exp = "($.visits << 1) > 100";exp = "($.visits << 1) > 100"use aerospike::expressions::{gt, int_bin, int_lshift, int_val};
let exp = gt(int_lshift(int_bin("visits".into()), int_val(1)), int_val(100));Expression exp = Exp.Build( Exp.GT( Exp.Lshift(Exp.IntBin("visits"), Exp.Val(1)), Exp.Val(100)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntLShift(as.ExpIntBin("visits"), as.ExpIntVal(1)), as.ExpIntVal(100))// The Node.js client's exp.intLshift builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_lshift(as_exp_bin_int("visits"), as_exp_int(1)), as_exp_int(100)));Expression exp = Exp.build( Exp.gt( Exp.lshift(Exp.intBin("visits"), Exp.val(1)), Exp.val(100)));from aerospike_helpers.expressions import GT, IntBin, IntLeftShift
exp = GT(IntLeftShift(IntBin("visits"), 1), 100).compile()int_not(value)Returns the bitwise complement of value, so int_not(0) is -1.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to complement. |
integer Find records where bitwise NOT of integer bin flags is not zero.
String exp = "~$.flags != 0";exp = "~$.flags != 0"use aerospike::expressions::{int_bin, int_not, int_val, ne};
let exp = ne(int_not(int_bin("flags".into())), int_val(0));Expression exp = Exp.Build( Exp.NE( Exp.IntNot(Exp.IntBin("flags")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpNotEq( as.ExpIntNot(as.ExpIntBin("flags")), as.ExpIntVal(0))// The Node.js client's exp.intNot builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_ne( as_exp_int_not(as_exp_bin_int("flags")), as_exp_int(0)));Expression exp = Exp.build( Exp.ne( Exp.intNot(Exp.intBin("flags")), Exp.val(0)));from aerospike_helpers.expressions import IntBin, IntNot, NE
exp = NE(IntNot(IntBin("flags")), 0).compile()int_or(arg0, arg1, ...)Returns the bitwise OR of two or more integers.
| Name | Type | Description |
|---|---|---|
arg0 | integer | First integer. |
arg1 | integer | Second integer. |
... | integer | Any further integers. |
integer Find records where the bitwise OR of integer bins read_mask and write_mask is non-zero.
String exp = "($.read_mask | $.write_mask) > 0";exp = "($.read_mask | $.write_mask) > 0"use aerospike::expressions::{gt, int_bin, int_or, int_val};
let exp = gt( int_or(vec![int_bin("read_mask".into()), int_bin("write_mask".into())]), int_val(0));Expression exp = Exp.Build( Exp.GT( Exp.IntOr(Exp.IntBin("read_mask"), Exp.IntBin("write_mask")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntOr(as.ExpIntBin("read_mask"), as.ExpIntBin("write_mask")), as.ExpIntVal(0))const exp = Aerospike.exp
const filterExp = exp.gt( exp.intOr(exp.binInt('read_mask'), exp.binInt('write_mask')), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_or( as_exp_bin_int("read_mask"), as_exp_bin_int("write_mask")), as_exp_int(0)));Expression exp = Exp.build( Exp.gt( Exp.intOr( Exp.intBin("read_mask"), Exp.intBin("write_mask")), Exp.val(0)));from aerospike_helpers.expressions import GT, IntBin, IntOr
exp = GT(IntOr(IntBin("read_mask"), IntBin("write_mask")), 0).compile()int_rscan(value, search)Returns the index of the last bit in value that matches search, scanning from the least significant bit. Indexes are counted from the most significant bit, which is index 0, so on a 64-bit integer the least significant bit is index 63.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to scan. |
search | boolean | Bit value to look for: true finds a bit set to 1, false finds a bit set to 0. |
integer Find records where a right-scan for a 1 bit in integer bin visits returns an index greater than 56, so at least one of its 7 least significant bits is set.
String exp = "findBitRight(x: $.visits, value: true) > 56";exp = "findBitRight(x: $.visits, value: true) > 56"use aerospike::expressions::{bool_val, gt, int_bin, int_rscan, int_val};
let exp = gt(int_rscan(int_bin("visits".into()), bool_val(true)), int_val(56));Expression exp = Exp.Build( Exp.GT( Exp.Rscan(Exp.IntBin("visits"), Exp.Val(true)), Exp.Val(56)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntRScan(as.ExpIntBin("visits"), as.ExpBoolVal(true)), as.ExpIntVal(56))// The Node.js client's exp.intRscan builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_rscan( as_exp_bin_int("visits"), as_exp_bool(true)), as_exp_int(56)));Expression exp = Exp.build( Exp.gt( Exp.rscan(Exp.intBin("visits"), Exp.val(true)), Exp.val(56)));from aerospike_helpers.expressions import GT, IntBin, IntRightScan
exp = GT(IntRightScan(IntBin("visits"), True), 56).compile()int_rshift(value, by_numbits)Returns value shifted right by by_numbits bits, filling from the left with zeros. The value is treated as unsigned, so int_rshift(-8, 1) is a large positive number rather than -4. Use int_arshift to preserve the sign.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to shift. |
by_numbits | integer | Number of bit positions to shift by. |
integer Determine whether bit 6 of integer bin flags, counting from 0 at the least significant bit (the 64 bit), is set: a logical right shift by 6, then a mask of 1.
String exp = "(($.flags >>> 6) & 1) == 1";exp = "(($.flags >>> 6) & 1) == 1"use aerospike::expressions::{eq, int_and, int_bin, int_rshift, int_val};
let exp = eq( int_and(vec![int_rshift(int_bin("flags".into()), int_val(6)), int_val(1)]), int_val(1));Expression exp = Exp.Build( Exp.EQ( Exp.IntAnd( Exp.Rshift(Exp.IntBin("flags"), Exp.Val(6)), Exp.Val(1)), Exp.Val(1)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpIntAnd( as.ExpIntRShift(as.ExpIntBin("flags"), as.ExpIntVal(6)), as.ExpIntVal(1)), as.ExpIntVal(1))// The Node.js client's exp.intRshift builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_eq( as_exp_int_and( as_exp_int_rshift(as_exp_bin_int("flags"), as_exp_int(6)), as_exp_int(1)), as_exp_int(1)));Expression exp = Exp.build( Exp.eq( Exp.intAnd( Exp.rshift(Exp.intBin("flags"), Exp.val(6)), Exp.val(1)), Exp.val(1)));from aerospike_helpers.expressions import Eq, IntAnd, IntBin, IntRightShift
exp = Eq( IntAnd(IntRightShift(IntBin("flags"), 6), 1), 1,).compile()int_xor(arg0, arg1, ...)Returns the bitwise XOR of two or more integers.
| Name | Type | Description |
|---|---|---|
arg0 | integer | First integer. |
arg1 | integer | Second integer. |
... | integer | Any further integers. |
integer Find records where the bitwise XOR of integer bins a and b is non-zero.
String exp = "($.a ^ $.b) > 0";exp = "($.a ^ $.b) > 0"use aerospike::expressions::{gt, int_bin, int_val, int_xor};
let exp = gt(int_xor(vec![int_bin("a".into()), int_bin("b".into())]), int_val(0));Expression exp = Exp.Build( Exp.GT( Exp.IntXor(Exp.IntBin("a"), Exp.IntBin("b")), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpIntXor(as.ExpIntBin("a"), as.ExpIntBin("b")), as.ExpIntVal(0))const exp = Aerospike.exp
const filterExp = exp.gt(exp.intXor(exp.binInt('a'), exp.binInt('b')), exp.int(0))as_exp_build(predexp, as_exp_cmp_gt( as_exp_int_xor( as_exp_bin_int("a"), as_exp_bin_int("b")), as_exp_int(0)));Expression exp = Exp.build( Exp.gt( Exp.intXor( Exp.intBin("a"), Exp.intBin("b")), Exp.val(0)));from aerospike_helpers.expressions import GT, IntBin, IntXOr
exp = GT(IntXOr(IntBin("a"), IntBin("b")), 0).compile()log(num, base)Returns the logarithm of num in base base. Both operands must be floats; integers are rejected.
| Name | Type | Description |
|---|---|---|
num | float | Number to take the logarithm of. |
base | float | Base of the logarithm. |
float Find records where the base-8 logarithm of float bin branches is greater than 2.
String exp = "log(value: $.branches, base: 8.0) > 2.0";exp = "log(value: $.branches, base: 8.0) > 2.0"use aerospike::expressions::{float_bin, float_val, gt, num_log};
let exp = gt(num_log(float_bin("branches".into()), float_val(8.0)), float_val(2.0));Expression exp = Exp.Build( Exp.GT( Exp.Log(Exp.FloatBin("branches"), Exp.Val(8.0)), Exp.Val(2.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpNumLog(as.ExpFloatBin("branches"), as.ExpFloatVal(8.0)), as.ExpFloatVal(2.0))// The Node.js client's exp.log builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_gt( as_exp_log(as_exp_bin_float("branches"), as_exp_float(8.0)), as_exp_float(2.0)));Expression exp = Exp.build( Exp.gt( Exp.log(Exp.floatBin("branches"), Exp.val(8.0)), Exp.val(2.0)));from aerospike_helpers.expressions import FloatBin, GT, Log
exp = GT(Log(FloatBin("branches"), 8.0), 2.0).compile()max(arg0, arg1, ...)Returns the largest of its arguments. All arguments must be the same numeric type: either all integers or all floats.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | First number to compare. |
arg1 | integer or float | Second number to compare. |
... | integer or float | Any further numbers to compare. |
integer or float Find records where the maximum of integer bins value0–value3 is greater than 100.
String exp = "max($.value0, $.value1, $.value2, $.value3) > 100";exp = "max($.value0, $.value1, $.value2, $.value3) > 100"use aerospike::expressions::{gt, int_bin, int_val, max};
let exp = gt( max(vec![ int_bin("value0".into()), int_bin("value1".into()), int_bin("value2".into()), int_bin("value3".into()), ]), int_val(100));Expression exp = Exp.Build( Exp.GT( Exp.Max( Exp.IntBin("value0"), Exp.IntBin("value1"), Exp.IntBin("value2"), Exp.IntBin("value3")), Exp.Val(100)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreater( as.ExpMax( as.ExpIntBin("value0"), as.ExpIntBin("value1"), as.ExpIntBin("value2"), as.ExpIntBin("value3")), as.ExpIntVal(100))const exp = Aerospike.exp
const filterExp = exp.gt( exp.max( exp.binInt('value0'), exp.binInt('value1'), exp.binInt('value2'), exp.binInt('value3')), exp.int(100))as_exp_build(predexp, as_exp_cmp_gt( as_exp_max( as_exp_bin_int("value0"), as_exp_bin_int("value1"), as_exp_bin_int("value2"), as_exp_bin_int("value3")), as_exp_int(100)));Expression exp = Exp.build( Exp.gt( Exp.max( Exp.intBin("value0"), Exp.intBin("value1"), Exp.intBin("value2"), Exp.intBin("value3")), Exp.val(100)));from aerospike_helpers.expressions import GT, IntBin, Max
exp = GT( Max( IntBin("value0"), IntBin("value1"), IntBin("value2"), IntBin("value3"), ), 100,).compile()min(arg0, arg1, ...)Returns the smallest of its arguments. All arguments must be the same numeric type: either all integers or all floats.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | First number to compare. |
arg1 | integer or float | Second number to compare. |
... | integer or float | Any further numbers to compare. |
integer or float Find records where the minimum of integer bins value0–value3 is less than 10.
String exp = "min($.value0, $.value1, $.value2, $.value3) < 10";exp = "min($.value0, $.value1, $.value2, $.value3) < 10"use aerospike::expressions::{int_bin, int_val, lt, min};
let exp = lt( min(vec![ int_bin("value0".into()), int_bin("value1".into()), int_bin("value2".into()), int_bin("value3".into()), ]), int_val(10));Expression exp = Exp.Build( Exp.LT( Exp.Min( Exp.IntBin("value0"), Exp.IntBin("value1"), Exp.IntBin("value2"), Exp.IntBin("value3")), Exp.Val(10)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpMin( as.ExpIntBin("value0"), as.ExpIntBin("value1"), as.ExpIntBin("value2"), as.ExpIntBin("value3")), as.ExpIntVal(10))const exp = Aerospike.exp
const filterExp = exp.lt( exp.min( exp.binInt('value0'), exp.binInt('value1'), exp.binInt('value2'), exp.binInt('value3')), exp.int(10))as_exp_build(predexp, as_exp_cmp_lt( as_exp_min( as_exp_bin_int("value0"), as_exp_bin_int("value1"), as_exp_bin_int("value2"), as_exp_bin_int("value3")), as_exp_int(10)));Expression exp = Exp.build( Exp.lt( Exp.min( Exp.intBin("value0"), Exp.intBin("value1"), Exp.intBin("value2"), Exp.intBin("value3")), Exp.val(10)));from aerospike_helpers.expressions import IntBin, LT, Min
exp = LT( Min( IntBin("value0"), IntBin("value1"), IntBin("value2"), IntBin("value3"), ), 10,).compile()mod(numerator, denominator)Returns the remainder of numerator divided by denominator. The remainder takes the sign of the numerator, so mod(-7, 3) is -1. A denominator of zero fails the expression.
| Name | Type | Description |
|---|---|---|
numerator | integer | Number to divide. |
denominator | integer | Number to divide by. Zero fails the expression. |
integer Find records where integer bin value modulo 2 equals 0.
String exp = "$.value % 2 == 0";exp = "$.value % 2 == 0"use aerospike::expressions::{eq, int_bin, int_val, num_mod};
let exp = eq(num_mod(int_bin("value".into()), int_val(2)), int_val(0));Expression exp = Exp.Build( Exp.EQ( Exp.Mod(Exp.IntBin("value"), Exp.Val(2)), Exp.Val(0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpNumMod(as.ExpIntBin("value"), as.ExpIntVal(2)), as.ExpIntVal(0))// The Node.js client's exp.mod builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_eq( as_exp_mod(as_exp_bin_int("value"), as_exp_int(2)), as_exp_int(0)));Expression exp = Exp.build( Exp.eq( Exp.mod(Exp.intBin("value"), Exp.val(2)), Exp.val(0)));from aerospike_helpers.expressions import Eq, IntBin, Mod
exp = Eq(Mod(IntBin("value"), 2), 0).compile()mul(arg0, arg1, ...)Returns the product of its arguments, or the argument itself when only one is given. Every argument must be the same numeric type — all integers or all floats. Mixing them is rejected.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | First number to multiply. |
arg1 | integer or float | Second number to multiply. |
... | integer or float | Any further numbers to multiply. |
integer or float Find records where the product of integer bins height and width is less than 100.
String exp = "$.height * $.width < 100";exp = "$.height * $.width < 100"use aerospike::expressions::{int_bin, int_val, lt, num_mul};
let exp = lt(num_mul(vec![int_bin("height".into()), int_bin("width".into())]), int_val(100));Expression exp = Exp.Build( Exp.LT( Exp.Mul(Exp.IntBin("height"), Exp.IntBin("width")), Exp.Val(100)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpNumMul(as.ExpIntBin("height"), as.ExpIntBin("width")), as.ExpIntVal(100))const exp = Aerospike.exp
const filterExp = exp.lt( exp.mul(exp.binInt('height'), exp.binInt('width')), exp.int(100))as_exp_build(predexp, as_exp_cmp_lt( as_exp_mul( as_exp_bin_int("height"), as_exp_bin_int("width")), as_exp_int(100)));Expression exp = Exp.build( Exp.lt( Exp.mul( Exp.intBin("height"), Exp.intBin("width")), Exp.val(100)));from aerospike_helpers.expressions import IntBin, LT, Mul
exp = LT(Mul(IntBin("height"), IntBin("width")), 100).compile()pow(base, exponent)Returns base raised to the power of exponent. Both operands must be floats; integers are rejected.
| Name | Type | Description |
|---|---|---|
base | float | Number to raise. |
exponent | float | Power to raise |
float Find records where float bin p raised to the power of integer bin events (converted to float) is less than 0.5.
String exp = "pow(base: $.p, exponent: $.events:INT.toFloat()) < 0.5";exp = "pow(base: $.p, exponent: $.events:INT.toFloat()) < 0.5"use aerospike::expressions::{float_bin, float_val, int_bin, lt, num_pow, to_float};
let exp = lt( num_pow(float_bin("p".into()), to_float(int_bin("events".into()))), float_val(0.5));Expression exp = Exp.Build( Exp.LT( Exp.Pow(Exp.FloatBin("p"), Exp.ToFloat(Exp.IntBin("events"))), Exp.Val(0.5)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpNumPow(as.ExpFloatBin("p"), as.ExpToFloat(as.ExpIntBin("events"))), as.ExpFloatVal(0.5))// The Node.js client's exp.pow builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_lt( as_exp_pow(as_exp_bin_float("p"), as_exp_to_float(as_exp_bin_int("events"))), as_exp_float(0.5)));Expression exp = Exp.build( Exp.lt( Exp.pow( Exp.floatBin("p"), Exp.toFloat(Exp.intBin("events"))), Exp.val(0.5)));from aerospike_helpers.expressions import FloatBin, IntBin, LT, Pow, ToFloat
exp = LT(Pow(FloatBin("p"), ToFloat(IntBin("events"))), 0.5).compile()sub(arg0, arg1, ...)Returns its arguments subtracted from left to right, so sub(10, 5, 2) is (10 - 5) - 2. Every argument must be the same numeric type — all integers or all floats. Mixing them is rejected.
| Name | Type | Description |
|---|---|---|
arg0 | integer or float | Number to subtract from. |
arg1 | integer or float | Number to subtract. |
... | integer or float | Any further numbers to subtract, applied left to right. |
integer or float Find records where the difference between integer bin assets and debts is less than 1000000.
String exp = "$.assets - $.debts < 1000000";exp = "$.assets - $.debts < 1000000"use aerospike::expressions::{int_bin, int_val, lt, num_sub};
let exp = lt( num_sub(vec![int_bin("assets".into()), int_bin("debts".into())]), int_val(1000000));Expression exp = Exp.Build( Exp.LT( Exp.Sub(Exp.IntBin("assets"), Exp.IntBin("debts")), Exp.Val(1000000)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpLess( as.ExpNumSub(as.ExpIntBin("assets"), as.ExpIntBin("debts")), as.ExpIntVal(1000000))const exp = Aerospike.exp
const filterExp = exp.lt( exp.sub(exp.binInt('assets'), exp.binInt('debts')), exp.int(1000000))as_exp_build(predexp, as_exp_cmp_lt( as_exp_sub( as_exp_bin_int("assets"), as_exp_bin_int("debts")), as_exp_int(1000000)));Expression exp = Exp.build( Exp.lt( Exp.sub( Exp.intBin("assets"), Exp.intBin("debts")), Exp.val(1000000)));from aerospike_helpers.expressions import IntBin, LT, Sub
exp = LT(Sub(IntBin("assets"), IntBin("debts")), 1000000).compile()to_float(value)Returns value, an integer, converted to a float.
| Name | Type | Description |
|---|---|---|
value | integer | Integer to convert. |
float Find records where to_float of integer bin quantity is at least 1.0 (for float comparisons without changing stored bin types).
String exp = "$.quantity:INT.toFloat() >= 1.0";exp = "$.quantity:INT.toFloat() >= 1.0"use aerospike::expressions::{float_val, ge, int_bin, to_float};
let exp = ge(to_float(int_bin("quantity".into())), float_val(1.0));Expression exp = Exp.Build( Exp.GE( Exp.ToFloat(Exp.IntBin("quantity")), Exp.Val(1.0)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpGreaterEq( as.ExpToFloat(as.ExpIntBin("quantity")), as.ExpFloatVal(1.0))// The Node.js client's exp.toFloat builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_ge( as_exp_to_float(as_exp_bin_int("quantity")), as_exp_float(1.0)));Expression exp = Exp.build( Exp.ge( Exp.toFloat(Exp.intBin("quantity")), Exp.val(1.0)));from aerospike_helpers.expressions import GE, IntBin, ToFloat
exp = GE(ToFloat(IntBin("quantity")), 1.0).compile()to_int(value)Returns value, a float, converted to an integer by truncating toward zero, so 2.5 becomes 2.
| Name | Type | Description |
|---|---|---|
value | float | Float to convert. |
integer Find records where to_int of float bin list_price equals 12 (aligned with whole-dollar list prices in path docs).
String exp = "$.list_price:FLOAT.toInt() == 12";exp = "$.list_price:FLOAT.toInt() == 12"use aerospike::expressions::{eq, float_bin, int_val, to_int};
let exp = eq(to_int(float_bin("list_price".into())), int_val(12));Expression exp = Exp.Build( Exp.EQ( Exp.ToInt(Exp.FloatBin("list_price")), Exp.Val(12)));// Requires: import as "github.com/aerospike/aerospike-client-go/v8"exp := as.ExpEq( as.ExpToInt(as.ExpFloatBin("list_price")), as.ExpIntVal(12))// The Node.js client's exp.toInt builds an expression the client cannot send,// so this example has no Node.js form.as_exp_build(predexp, as_exp_cmp_eq( as_exp_to_int(as_exp_bin_float("list_price")), as_exp_int(12)));Expression exp = Exp.build( Exp.eq( Exp.toInt(Exp.floatBin("list_price")), Exp.val(12)));from aerospike_helpers.expressions import Eq, FloatBin, ToInt
exp = Eq(ToInt(FloatBin("list_price")), 12).compile()