# `Aerospike.Exp`
[🔗](https://github.com/luisgabrielroldan/aerospike_driver/blob/v0.3.1/lib/aerospike/exp.ex#L1)

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.

# `exp_type`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

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

# `t`

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

Opaque server-side expression.

The `wire` field contains encoded Aerospike expression bytes.

# `abs`

```elixir
@spec abs(t()) :: t()
```

Absolute value expression.

# `add`

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

Numeric addition over one or more expressions.

# `and_`

```elixir
@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`

```elixir
@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`

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

True when the named bin exists in the current record.

# `bin_type`

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

Reads the named bin's integer particle type.

# `blob`

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

Blob literal expression encoded as MessagePack binary data.

# `blob_bin`

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

Reads a blob bin from the current record.

# `blob_loop_var`

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

Reads a blob built-in loop variable.

# `bool`

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

Boolean literal expression.

# `bool_bin`

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

Reads a boolean bin from the current record.

# `bool_loop_var`

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

Reads a boolean built-in loop variable.

# `ceil`

```elixir
@spec ceil(t()) :: t()
```

Ceiling expression.

# `cond_`

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

Conditionally selects an action expression.

# `def_`

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

Assigns a variable for use inside `let/1`.

# `digest_modulo`

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

Record digest modulo expression.

# `div_`

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

Numeric division over one or more expressions.

# `eq`

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

Equal comparison.

# `exclusive`

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

Logical exclusive-or over two or more expressions.

# `float`

```elixir
@spec float(float()) :: t()
```

Float literal expression.

# `float_bin`

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

Reads a float bin from the current record.

# `float_loop_var`

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

Reads a float built-in loop variable.

# `floor`

```elixir
@spec floor(t()) :: t()
```

Floor expression.

# `from_wire`

```elixir
@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`

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

GeoJSON literal expression.

# `geo_bin`

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

Reads a geospatial bin from the current record.

# `geo_compare`

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

Geospatial comparison.

# `geo_loop_var`

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

Reads a geospatial built-in loop variable.

# `gt`

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

Greater-than comparison.

# `gte`

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

Greater-than-or-equal comparison.

# `hll_bin`

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

Reads an HLL bin from the current record.

# `hll_loop_var`

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

Reads an HLL built-in loop variable.

# `infinity`

```elixir
@spec infinity() :: t()
```

Infinity value for CDT range expressions.

# `int`

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

Integer literal expression.

# `int_and`

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

Integer bitwise AND over two or more expressions.

# `int_arshift`

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

Integer arithmetic right-shift expression.

# `int_bin`

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

Reads an integer bin from the current record.

# `int_count`

```elixir
@spec int_count(t()) :: t()
```

Count of set bits in an integer expression.

# `int_loop_var`

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

Reads an integer built-in loop variable.

# `int_lscan`

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

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

# `int_lshift`

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

Integer left-shift expression.

# `int_not`

```elixir
@spec int_not(t()) :: t()
```

Integer bitwise NOT expression.

# `int_or`

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

Integer bitwise OR over two or more expressions.

# `int_rscan`

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

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

# `int_rshift`

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

Integer logical right-shift expression.

# `int_xor`

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

Integer bitwise XOR over two or more expressions.

# `key`

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

Record key expression of the specified expression type.

# `key_exists`

```elixir
@spec key_exists() :: t()
```

True when the record has a stored user key.

# `last_update`

```elixir
@spec last_update() :: t()
```

Record last-update timestamp.

# `let`

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

Defines variables and evaluates a scoped expression.

# `list`

```elixir
@spec list(list()) :: t()
```

List literal expression.

# `list_bin`

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

Reads a list bin from the current record.

# `list_loop_var`

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

Reads a list built-in loop variable.

# `log`

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

Numeric logarithm expression.

# `loop_var`

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

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

# `loop_var_part`

```elixir
@spec loop_var_part(loop_var_part()) :: non_neg_integer()
```

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

# `lt`

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

Less-than comparison.

# `lte`

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

Less-than-or-equal comparison.

# `map`

```elixir
@spec map(map()) :: t()
```

Map literal expression.

# `map_bin`

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

Reads a map bin from the current record.

# `map_loop_var`

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

Reads a map built-in loop variable.

# `max`

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

Maximum value over one or more expressions.

# `min`

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

Minimum value over one or more expressions.

# `mod`

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

Integer modulo expression.

# `mul`

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

Numeric multiplication over one or more expressions.

# `ne`

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

Not-equal comparison.

# `nil_`

```elixir
@spec nil_() :: t()
```

Nil literal expression.

# `nil_loop_var`

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

Reads a nil built-in loop variable.

# `not_`

```elixir
@spec not_(t()) :: t()
```

Logical NOT of an expression.

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

# `or_`

```elixir
@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`

```elixir
@spec particle_type(particle_type()) :: non_neg_integer()
```

Integer particle type value returned by `bin_type/1`.

# `pow`

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

Numeric power expression.

# `record_size`

```elixir
@spec record_size() :: t()
```

Record size in bytes on storage device.

# `regex_compare`

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

Regular expression comparison against a string expression.

# `regex_flag`

```elixir
@spec regex_flag(regex_flag()) :: non_neg_integer()
```

Integer regular expression flag value for `regex_compare/3`.

# `regex_flags`

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

Combines regular expression flags for `regex_compare/3`.

# `remove_result`

```elixir
@spec remove_result() :: t()
```

Result-remove expression value.

# `set_name`

```elixir
@spec set_name() :: t()
```

Record set name.

# `since_update`

```elixir
@spec since_update() :: t()
```

Milliseconds since the record was last updated.

# `str`

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

String literal expression encoded as a MessagePack string.

# `str_bin`

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

Reads a string bin from the current record.

# `str_loop_var`

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

Reads a string built-in loop variable.

# `sub`

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

Numeric subtraction over one or more expressions.

# `to_float`

```elixir
@spec to_float(t()) :: t()
```

Converts a numeric expression to a float.

# `to_int`

```elixir
@spec to_int(t()) :: t()
```

Converts a numeric expression to an integer.

# `tombstone?`

```elixir
@spec tombstone?() :: t()
```

True when the record is a tombstone.

# `ttl`

```elixir
@spec ttl() :: t()
```

Record time-to-live in seconds.

# `unknown`

```elixir
@spec unknown() :: t()
```

Unknown expression value.

# `val`

```elixir
@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`

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

Reads a variable defined by `let/1`.

# `void_time`

```elixir
@spec void_time() :: t()
```

Record expiration time as an absolute server timestamp.

# `wildcard`

```elixir
@spec wildcard() :: t()
```

Wildcard value for CDT expressions.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
