Aerospike.Exp (Aerospike Driver v0.3.1)

Copy Markdown View Source

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 termExpression builder
integer()int/1
float()float/1
binary()str/1
boolean()bool/1
nilnil_/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.

t()

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.

Reads a variable defined by let/1.

Record expiration time as an absolute server timestamp.

Wildcard value for CDT expressions.

Types

exp_type()

@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.

loop_var_part()

@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.

particle_type()

@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.

regex_flag()

@type regex_flag() :: :none | :extended | :icase | :nosub | :newline

Regular expression flag name accepted by regex_flag/1 and regex_flags/1.

t()

@type t() :: %Aerospike.Exp{wire: binary()}

Opaque server-side expression.

The wire field contains encoded Aerospike expression bytes.

Functions

abs(expression)

@spec abs(t()) :: t()

Absolute value expression.

add(expressions)

@spec add([t(), ...]) :: t()

Numeric addition over one or more expressions.

and_(expressions)

@spec and_([t(), ...]) :: t()

Logical AND over two or more expressions.

The function name has a trailing underscore because and is an Elixir reserved word.

base64(exp)

@spec base64(t()) :: {:ok, String.t()} | {:error, :empty}

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.

bin_exists(name)

@spec bin_exists(String.t()) :: t()

True when the named bin exists in the current record.

bin_type(name)

@spec bin_type(String.t()) :: t()

Reads the named bin's integer particle type.

blob(value)

@spec blob(binary()) :: t()

Blob literal expression encoded as MessagePack binary data.

blob_bin(name)

@spec blob_bin(String.t()) :: t()

Reads a blob bin from the current record.

blob_loop_var(part)

@spec blob_loop_var(loop_var_part()) :: t()

Reads a blob built-in loop variable.

bool(value)

@spec bool(boolean()) :: t()

Boolean literal expression.

bool_bin(name)

@spec bool_bin(String.t()) :: t()

Reads a boolean bin from the current record.

bool_loop_var(part)

@spec bool_loop_var(loop_var_part()) :: t()

Reads a boolean built-in loop variable.

ceil(expression)

@spec ceil(t()) :: t()

Ceiling expression.

cond_(expressions)

@spec cond_([t(), ...]) :: t()

Conditionally selects an action expression.

def_(name, expression)

@spec def_(String.t(), t()) :: t()

Assigns a variable for use inside let/1.

digest_modulo(value)

@spec digest_modulo(integer()) :: t()

Record digest modulo expression.

div_(expressions)

@spec div_([t(), ...]) :: t()

Numeric division over one or more expressions.

eq(left, right)

@spec eq(t(), t()) :: t()

Equal comparison.

exclusive(expressions)

@spec exclusive([t(), ...]) :: t()

Logical exclusive-or over two or more expressions.

float(value)

@spec float(float()) :: t()

Float literal expression.

float_bin(name)

@spec float_bin(String.t()) :: t()

Reads a float bin from the current record.

float_loop_var(part)

@spec float_loop_var(loop_var_part()) :: t()

Reads a float built-in loop variable.

floor(expression)

@spec floor(t()) :: t()

Floor expression.

from_wire(wire)

@spec from_wire(binary()) :: t()

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.

geo(value)

@spec geo(binary()) :: t()

GeoJSON literal expression.

geo_bin(name)

@spec geo_bin(String.t()) :: t()

Reads a geospatial bin from the current record.

geo_compare(left, right)

@spec geo_compare(t(), t()) :: t()

Geospatial comparison.

geo_loop_var(part)

@spec geo_loop_var(loop_var_part()) :: t()

Reads a geospatial built-in loop variable.

gt(left, right)

@spec gt(t(), t()) :: t()

Greater-than comparison.

gte(left, right)

@spec gte(t(), t()) :: t()

Greater-than-or-equal comparison.

hll_bin(name)

@spec hll_bin(String.t()) :: t()

Reads an HLL bin from the current record.

hll_loop_var(part)

@spec hll_loop_var(loop_var_part()) :: t()

Reads an HLL built-in loop variable.

infinity()

@spec infinity() :: t()

Infinity value for CDT range expressions.

int(value)

@spec int(integer()) :: t()

Integer literal expression.

int_and(expressions)

@spec int_and([t(), ...]) :: t()

Integer bitwise AND over two or more expressions.

int_arshift(value, shift)

@spec int_arshift(t(), t()) :: t()

Integer arithmetic right-shift expression.

int_bin(name)

@spec int_bin(String.t()) :: t()

Reads an integer bin from the current record.

int_count(expression)

@spec int_count(t()) :: t()

Count of set bits in an integer expression.

int_loop_var(part)

@spec int_loop_var(loop_var_part()) :: t()

Reads an integer built-in loop variable.

int_lscan(value, search)

@spec int_lscan(t(), t()) :: t()

Scan integer bits from left to right for a search bit.

int_lshift(value, shift)

@spec int_lshift(t(), t()) :: t()

Integer left-shift expression.

int_not(expression)

@spec int_not(t()) :: t()

Integer bitwise NOT expression.

int_or(expressions)

@spec int_or([t(), ...]) :: t()

Integer bitwise OR over two or more expressions.

int_rscan(value, search)

@spec int_rscan(t(), t()) :: t()

Scan integer bits from right to left for a search bit.

int_rshift(value, shift)

@spec int_rshift(t(), t()) :: t()

Integer logical right-shift expression.

int_xor(expressions)

@spec int_xor([t(), ...]) :: t()

Integer bitwise XOR over two or more expressions.

key(type)

@spec key(exp_type()) :: t()

Record key expression of the specified expression type.

key_exists()

@spec key_exists() :: t()

True when the record has a stored user key.

last_update()

@spec last_update() :: t()

Record last-update timestamp.

let(expressions)

@spec let([t(), ...]) :: t()

Defines variables and evaluates a scoped expression.

list(values)

@spec list(list()) :: t()

List literal expression.

list_bin(name)

@spec list_bin(String.t()) :: t()

Reads a list bin from the current record.

list_loop_var(part)

@spec list_loop_var(loop_var_part()) :: t()

Reads a list built-in loop variable.

log(number, base)

@spec log(t(), t()) :: t()

Numeric logarithm expression.

loop_var(type, part)

@spec loop_var(exp_type(), loop_var_part()) :: t()

Reads a built-in loop variable with the specified expression type.

loop_var_part(name)

@spec loop_var_part(loop_var_part()) :: non_neg_integer()

Integer loop-variable part value for typed loop-variable builders.

lt(left, right)

@spec lt(t(), t()) :: t()

Less-than comparison.

lte(left, right)

@spec lte(t(), t()) :: t()

Less-than-or-equal comparison.

map(values)

@spec map(map()) :: t()

Map literal expression.

map_bin(name)

@spec map_bin(String.t()) :: t()

Reads a map bin from the current record.

map_loop_var(part)

@spec map_loop_var(loop_var_part()) :: t()

Reads a map built-in loop variable.

max(expressions)

@spec max([t(), ...]) :: t()

Maximum value over one or more expressions.

min(expressions)

@spec min([t(), ...]) :: t()

Minimum value over one or more expressions.

mod(numerator, denominator)

@spec mod(t(), t()) :: t()

Integer modulo expression.

mul(expressions)

@spec mul([t(), ...]) :: t()

Numeric multiplication over one or more expressions.

ne(left, right)

@spec ne(t(), t()) :: t()

Not-equal comparison.

nil_()

@spec nil_() :: t()

Nil literal expression.

nil_loop_var(part)

@spec nil_loop_var(loop_var_part()) :: t()

Reads a nil built-in loop variable.

not_(expression)

@spec not_(t()) :: t()

Logical NOT of an expression.

The function name has a trailing underscore because not is an Elixir reserved word.

or_(expressions)

@spec or_([t(), ...]) :: t()

Logical OR over two or more expressions.

The function name has a trailing underscore because or is an Elixir reserved word.

particle_type(name)

@spec particle_type(particle_type()) :: non_neg_integer()

Integer particle type value returned by bin_type/1.

pow(base, exponent)

@spec pow(t(), t()) :: t()

Numeric power expression.

record_size()

@spec record_size() :: t()

Record size in bytes on storage device.

regex_compare(regex, flags, expression)

@spec regex_compare(String.t(), non_neg_integer(), t()) :: t()

Regular expression comparison against a string expression.

regex_flag(name)

@spec regex_flag(regex_flag()) :: non_neg_integer()

Integer regular expression flag value for regex_compare/3.

regex_flags(flags)

@spec regex_flags([regex_flag()]) :: non_neg_integer()

Combines regular expression flags for regex_compare/3.

remove_result()

@spec remove_result() :: t()

Result-remove expression value.

set_name()

@spec set_name() :: t()

Record set name.

since_update()

@spec since_update() :: t()

Milliseconds since the record was last updated.

str(value)

@spec str(binary()) :: t()

String literal expression encoded as a MessagePack string.

str_bin(name)

@spec str_bin(String.t()) :: t()

Reads a string bin from the current record.

str_loop_var(part)

@spec str_loop_var(loop_var_part()) :: t()

Reads a string built-in loop variable.

sub(expressions)

@spec sub([t(), ...]) :: t()

Numeric subtraction over one or more expressions.

to_float(expression)

@spec to_float(t()) :: t()

Converts a numeric expression to a float.

to_int(expression)

@spec to_int(t()) :: t()

Converts a numeric expression to an integer.

tombstone?()

@spec tombstone?() :: t()

True when the record is a tombstone.

ttl()

@spec ttl() :: t()

Record time-to-live in seconds.

unknown()

@spec unknown() :: t()

Unknown expression value.

val(value)

@spec val(integer() | float() | binary() | boolean() | nil | list() | map()) :: t()

Builds a literal expression from an Elixir value.

Binaries are treated as strings. Use blob/1 explicitly for raw binary semantics.

var(name)

@spec var(String.t()) :: t()

Reads a variable defined by let/1.

void_time()

@spec void_time() :: t()

Record expiration time as an absolute server timestamp.

wildcard()

@spec wildcard() :: t()

Wildcard value for CDT expressions.