Server-side expression builder.
Expressions are composable values used by Aerospike server features such as
filter expressions. Each builder returns an %Aerospike.Exp{} struct
containing pre-encoded expression wire bytes.
alias Aerospike.Exp
adult =
Exp.and_([
Exp.gte(Exp.int_bin("age"), Exp.val(18)),
Exp.lt(Exp.int_bin("age"), Exp.val(65))
])
active = Exp.eq(Exp.str_bin("status"), Exp.val("active"))
expression = Exp.and_([adult, active])val/1 maps Elixir values to literal expressions:
| Elixir term | Expression builder |
|---|---|
integer() | int/1 |
float() | float/1 |
binary() | str/1 |
boolean() | bool/1 |
nil | nil_/0 |
Binaries passed to val/1 or str/1 are encoded as MessagePack strings.
Use blob/1 when the expression value must use MessagePack binary format.
Summary
Types
Aerospike expression result type tag.
Built-in loop-variable part used inside CDT filter expressions.
Aerospike particle type name accepted by particle_type/1.
Regular expression flag name accepted by regex_flag/1 and regex_flags/1.
Opaque server-side expression.
Functions
Absolute value expression.
Numeric addition over one or more expressions.
Logical AND over two or more expressions.
Encodes an expression's wire bytes as Base64.
True when the named bin exists in the current record.
Reads the named bin's integer particle type.
Blob literal expression encoded as MessagePack binary data.
Reads a blob bin from the current record.
Reads a blob built-in loop variable.
Boolean literal expression.
Reads a boolean bin from the current record.
Reads a boolean built-in loop variable.
Ceiling expression.
Conditionally selects an action expression.
Assigns a variable for use inside let/1.
Record digest modulo expression.
Numeric division over one or more expressions.
Equal comparison.
Logical exclusive-or over two or more expressions.
Float literal expression.
Reads a float bin from the current record.
Reads a float built-in loop variable.
Floor expression.
Wraps pre-encoded expression bytes.
GeoJSON literal expression.
Reads a geospatial bin from the current record.
Geospatial comparison.
Reads a geospatial built-in loop variable.
Greater-than comparison.
Greater-than-or-equal comparison.
Reads an HLL bin from the current record.
Reads an HLL built-in loop variable.
Infinity value for CDT range expressions.
Integer literal expression.
Integer bitwise AND over two or more expressions.
Integer arithmetic right-shift expression.
Reads an integer bin from the current record.
Count of set bits in an integer expression.
Reads an integer built-in loop variable.
Scan integer bits from left to right for a search bit.
Integer left-shift expression.
Integer bitwise NOT expression.
Integer bitwise OR over two or more expressions.
Scan integer bits from right to left for a search bit.
Integer logical right-shift expression.
Integer bitwise XOR over two or more expressions.
Record key expression of the specified expression type.
True when the record has a stored user key.
Record last-update timestamp.
Defines variables and evaluates a scoped expression.
List literal expression.
Reads a list bin from the current record.
Reads a list built-in loop variable.
Numeric logarithm expression.
Reads a built-in loop variable with the specified expression type.
Integer loop-variable part value for typed loop-variable builders.
Less-than comparison.
Less-than-or-equal comparison.
Map literal expression.
Reads a map bin from the current record.
Reads a map built-in loop variable.
Maximum value over one or more expressions.
Minimum value over one or more expressions.
Integer modulo expression.
Numeric multiplication over one or more expressions.
Not-equal comparison.
Nil literal expression.
Reads a nil built-in loop variable.
Logical NOT of an expression.
Logical OR over two or more expressions.
Integer particle type value returned by bin_type/1.
Numeric power expression.
Record size in bytes on storage device.
Regular expression comparison against a string expression.
Integer regular expression flag value for regex_compare/3.
Combines regular expression flags for regex_compare/3.
Result-remove expression value.
Record set name.
Milliseconds since the record was last updated.
String literal expression encoded as a MessagePack string.
Reads a string bin from the current record.
Reads a string built-in loop variable.
Numeric subtraction over one or more expressions.
Converts a numeric expression to a float.
Converts a numeric expression to an integer.
True when the record is a tombstone.
Record time-to-live in seconds.
Unknown expression value.
Builds a literal expression from an Elixir value.
Record expiration time as an absolute server timestamp.
Wildcard value for CDT expressions.
Types
@type exp_type() ::
nil | :bool | :int | :string | :list | :map | :blob | :float | :geo | :hll
Aerospike expression result type tag.
Use this with typed bin, key, and loop-variable builders when the server must know the expected expression value type.
@type loop_var_part() :: :map_key | :value | :index
Built-in loop-variable part used inside CDT filter expressions.
:map_key reads the current map key, :value reads the current list item or
map value, and :index reads the current collection index.
@type particle_type() ::
:null
| :integer
| :float
| :string
| :blob
| :digest
| :bool
| :hll
| :map
| :list
| :ldt
| :geojson
Aerospike particle type name accepted by particle_type/1.
The returned integer can be compared with bin_type/1.
@type regex_flag() :: :none | :extended | :icase | :nosub | :newline
Regular expression flag name accepted by regex_flag/1 and regex_flags/1.
@type t() :: %Aerospike.Exp{wire: binary()}
Opaque server-side expression.
The wire field contains encoded Aerospike expression bytes.
Functions
Absolute value expression.
Numeric addition over one or more expressions.
Logical AND over two or more expressions.
The function name has a trailing underscore because and is an Elixir
reserved word.
Encodes an expression's wire bytes as Base64.
Empty expressions return {:error, :empty} because Aerospike server APIs that
accept expressions require a non-empty expression payload.
True when the named bin exists in the current record.
Reads the named bin's integer particle type.
Blob literal expression encoded as MessagePack binary data.
Reads a blob bin from the current record.
@spec blob_loop_var(loop_var_part()) :: t()
Reads a blob built-in loop variable.
Boolean literal expression.
Reads a boolean bin from the current record.
@spec bool_loop_var(loop_var_part()) :: t()
Reads a boolean built-in loop variable.
Ceiling expression.
Conditionally selects an action expression.
Assigns a variable for use inside let/1.
Record digest modulo expression.
Numeric division over one or more expressions.
Equal comparison.
Logical exclusive-or over two or more expressions.
Float literal expression.
Reads a float bin from the current record.
@spec float_loop_var(loop_var_part()) :: t()
Reads a float built-in loop variable.
Floor expression.
Wraps pre-encoded expression bytes.
This is a low-level escape hatch for expressions built outside this module. The binary is not validated as a complete Aerospike expression.
GeoJSON literal expression.
Reads a geospatial bin from the current record.
Geospatial comparison.
@spec geo_loop_var(loop_var_part()) :: t()
Reads a geospatial built-in loop variable.
Greater-than comparison.
Greater-than-or-equal comparison.
Reads an HLL bin from the current record.
@spec hll_loop_var(loop_var_part()) :: t()
Reads an HLL built-in loop variable.
@spec infinity() :: t()
Infinity value for CDT range expressions.
Integer literal expression.
Integer bitwise AND over two or more expressions.
Integer arithmetic right-shift expression.
Reads an integer bin from the current record.
Count of set bits in an integer expression.
@spec int_loop_var(loop_var_part()) :: t()
Reads an integer built-in loop variable.
Scan integer bits from left to right for a search bit.
Integer left-shift expression.
Integer bitwise NOT expression.
Integer bitwise OR over two or more expressions.
Scan integer bits from right to left for a search bit.
Integer logical right-shift expression.
Integer bitwise XOR over two or more expressions.
Record key expression of the specified expression type.
@spec key_exists() :: t()
True when the record has a stored user key.
@spec last_update() :: t()
Record last-update timestamp.
Defines variables and evaluates a scoped expression.
List literal expression.
Reads a list bin from the current record.
@spec list_loop_var(loop_var_part()) :: t()
Reads a list built-in loop variable.
Numeric logarithm expression.
@spec loop_var(exp_type(), loop_var_part()) :: t()
Reads a built-in loop variable with the specified expression type.
@spec loop_var_part(loop_var_part()) :: non_neg_integer()
Integer loop-variable part value for typed loop-variable builders.
Less-than comparison.
Less-than-or-equal comparison.
Map literal expression.
Reads a map bin from the current record.
@spec map_loop_var(loop_var_part()) :: t()
Reads a map built-in loop variable.
Maximum value over one or more expressions.
Minimum value over one or more expressions.
Integer modulo expression.
Numeric multiplication over one or more expressions.
Not-equal comparison.
@spec nil_() :: t()
Nil literal expression.
@spec nil_loop_var(loop_var_part()) :: t()
Reads a nil built-in loop variable.
Logical NOT of an expression.
The function name has a trailing underscore because not is an Elixir
reserved word.
Logical OR over two or more expressions.
The function name has a trailing underscore because or is an Elixir
reserved word.
@spec particle_type(particle_type()) :: non_neg_integer()
Integer particle type value returned by bin_type/1.
Numeric power expression.
@spec record_size() :: t()
Record size in bytes on storage device.
@spec regex_compare(String.t(), non_neg_integer(), t()) :: t()
Regular expression comparison against a string expression.
@spec regex_flag(regex_flag()) :: non_neg_integer()
Integer regular expression flag value for regex_compare/3.
@spec regex_flags([regex_flag()]) :: non_neg_integer()
Combines regular expression flags for regex_compare/3.
@spec remove_result() :: t()
Result-remove expression value.
@spec set_name() :: t()
Record set name.
@spec since_update() :: t()
Milliseconds since the record was last updated.
String literal expression encoded as a MessagePack string.
Reads a string bin from the current record.
@spec str_loop_var(loop_var_part()) :: t()
Reads a string built-in loop variable.
Numeric subtraction over one or more expressions.
Converts a numeric expression to a float.
Converts a numeric expression to an integer.
@spec tombstone?() :: t()
True when the record is a tombstone.
@spec ttl() :: t()
Record time-to-live in seconds.
@spec unknown() :: t()
Unknown expression value.
Builds a literal expression from an Elixir value.
Binaries are treated as strings. Use blob/1 explicitly for raw binary
semantics.
Reads a variable defined by let/1.
@spec void_time() :: t()
Record expiration time as an absolute server timestamp.
@spec wildcard() :: t()
Wildcard value for CDT expressions.