aerospike_helpers.expressions package

Classes for the creation and use of aerospike expressions. See:: Aerospike Expressions.

Aerospike Expressions are a small domain specific language that allow for filtering records in transactions by manipulating and comparing bins and record metadata. Expressions can be used everywhere that predicate expressions have been used and allow for expanded functionality and customizability.

In the Python client, Aerospike expressions are built using a series of classes that represent comparrison and logical operators, bins, metadata operations, and bin operations. Expressions are constructed using a Lisp like syntax by instantiating an expression that yields a boolean, such as Eq() or And(), while passing them other expressions and constants as arguments, and finally calling the compile() method. See the example below.

Example:

# See if integer bin "bin_name" contains a value equal to 10.
from aerospike_helpers import expressions as exp
expr = exp.Eq(exp.IntBin("bin_name"), 10).compile()

By passing these compiled expressions to transactions via the “expressions” policy field, the expressions will filter the results. See the example below.

Example:

from __future__ import print_function
import aerospike
from aerospike_helpers import expressions as exp
from aerospike import exception as ex
import sys

TEST_NS = "test"
TEST_SET = "demo"
FIRST_RECORD_INDEX = 0
SECOND_RECORD_INDEX = 1
BIN_INDEX = 2

# Configure the client.
config = {"hosts": [("127.0.0.1", 3000)]}

# Create a client and connect it to the cluster.
try:
    client = aerospike.client(config).connect()
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

# Write records
keys = [(TEST_NS, TEST_SET, i) for i in range(1, 5)]
records = [
            {'user': "Chief"     , 'team': "blue", 'scores': [6, 12, 4, 21], 'kd': 1.0,  'status': "MasterPlatinum" },
            {'user': "Arbiter"   , 'team': "blue", 'scores': [5, 10, 5, 8] , 'kd': 1.0,  'status': "MasterGold"     },
            {'user': "Johnson"   , 'team': "blue", 'scores': [8, 17, 20, 5], 'kd': 0.99, 'status': "SergeantGold"   },
            {'user': "Regret"    , 'team': "red" , 'scores': [4, 2, 3, 5]  , 'kd': 0.33, 'status': "ProphetSilver"  }
        ]

try:
    for key, record in zip(keys, records):
        client.put(key, record)
except ex.RecordError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))


# EXAMPLE 1: Get records for users who's top scores are above 20 using a scan.
try:
    expr = exp.GT(exp.ListGetByRank(None, aerospike.LIST_RETURN_VALUE, exp.ResultType.INTEGER, -1, exp.ListBin("scores")), # rank -1 == largest value
                    20).compile()

    scan = client.scan(TEST_NS, TEST_SET)
    policy = {
        'expressions': expr
    }

    records = scan.results(policy)
    # This scan will only return the record for "Chief" since it is the only account with a score over 20 using batch get.
    print(records[FIRST_RECORD_INDEX][BIN_INDEX])
except ex.AerospikeError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

# EXPECTED OUTPUT:
# {'user': 'Chief', 'team': 'blue', 'scores': [6, 12, 4, 21], 'kd': 1.0, 'status': 'MasterPlatinum'}


# EXAMPLE 2: Get player's records with a kd >= 1.0 with a status including "Gold".
try:
    expr = exp.And(
        exp.CmpRegex(aerospike.REGEX_ICASE, '.*Gold', exp.StrBin('status')),
        exp.GE(exp.FloatBin("kd"), 1.0)).compile()

    policy = {
        'expressions': expr
    }

    records = client.get_many(keys, policy)
    # This get_many will only return the record for "Arbiter" since it is the only account with a kd >= 1.0 and Gold status.
    print(records[SECOND_RECORD_INDEX][BIN_INDEX])
except ex.AerospikeError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)
finally:
    client.close()

# EXPECTED OUTPUT:
# {'user': 'Arbiter', 'team': 'blue', 'scores': [5, 10, 5, 8], 'kd': 1.0, 'status': 'MasterGold'}

By nesting expressions, complicated filters can be created. See the example below.

Example:

from aerospike_helpers import expressions as exp
expr = Eq(
    exp.ListGetByIndexRangeToEnd(ctx, aerospike.LIST_RETURN_VALUE, 0,
        exp.ListSort(ctx, aerospike.LIST_SORT_DEFAULT,
            exp.ListAppend(ctx, policy, value_x,
                exp.ListAppendItems(ctx, policy, value_y,
                    exp.ListInsert(ctx, policy, 1, value_z, bin_name))))),
    expected_answer
),

Note:

Aerospike expressions are evaluated server side, and do not return any values to the client themselves.
When the following documentation says an expression returns a "list expression", it means that the expression returns a
list during evalution on the server side. When these docs say that a parameter requires an "integer or integer expression"
It means it will accept a literal integer, or an expression that will return an integer during evaluation. When the docs say
an expression returns a "expression" this means that the data type returned may vary, usually depending on the `return_type` parameter.

Current Limitations:

Currently, Aerospike expressions for the python client do not support comparing as_python_bytes blobs.
Comparrisions between constant map values and map expressions are  also unsupported.

The expressions module uses typehints, here are a table of custom typehints mapped to standard types.

Title
Type Name Type Description
TypeResultType Optional[int]
TypeFixedEle Union[int, float, str, bytes, dict]
TypeFixed Optional[Dict[str, TypeFixedEle]]
TypeCompiledOp Tuple[int, TypeResultType, TypeFixed, int]
TypeExpression List[TypeCompiledOp]
TypeChild Union[int, float, str, bytes, _AtomExpr]
TypeChildren Tuple[TypeChild, …]
TypeBinName Union[_BaseExpr, str]
TypeListValue Union[_BaseExpr, List[Any]]
TypeIndex Union[_BaseExpr, int, aerospike.CDTInfinite]
TypeCDT Union[None, List[cdt_ctx._cdt_ctx]]
TypeRank Union[_BaseExpr, int, aerospike.CDTInfinite]
TypeCount Union[_BaseExpr, int, aerospike.CDTInfinite]
TypeValue Union[_BaseExpr, Any]
TypePolicy Union[Dict[str, Any], None]
TypeComparisonArg Union[_BaseExpr, int, str, list, dict, aerospike.CDTInfinite]
TypeGeo Union[_BaseExpr, aerospike.GeoJSON]
TypeKey Union[_BaseExpr, Any]
TypeKeyList Union[_BaseExpr, List[Any]]
TypeBitValue Union[bytes, bytearray]

Note

Requires server version >= 5.2.0

aerospike_helpers.expressions.basemodule

Base expressions include operators, bin, and meta data related expressions.

Example:

import aerospike_helpers.expressions.base as exp
# See if integer bin "bin_name" contains a value equal to 10.
expr = exp.Eq(exp.IntBin("bin_name"), 10).compile()
class aerospike_helpers.expressions.base.And(*exprs)

Create an “and” operator that applies to a variable amount of expressions.

__init__(*exprs)

Create an “and” operator that applies to a variable amount of expressions.

Parameters:*exprs (_BaseExpr) – Variable amount of expressions to be ANDed together.
Returns:(boolean value)

Example:

# (a > 5 || a == 0) && b < 3
expr = And(
    Or(
        GT(IntBin("a"), 5),
        Eq(IntBin("a"), 0)),
    LT(IntBin("b"), 3)).compile()
class aerospike_helpers.expressions.base.BinExists(bin: str)

Create an expression that returns True if bin exists.

__init__(bin: str)

Create an expression that returns True if bin exists.

Parameters:bin (str) – bin name.
Return (boolean value):
 True if bin exists, False otherwise.

Example:

#Bin "a" exists in record.
expr = BinExists("a").compile()
class aerospike_helpers.expressions.base.BinType(bin: str)

Create an expression that returns the type of a bin as one of the aerospike bin types

__init__(bin: str)

Create an expression that returns the type of a bin as one of the aerospike bin types.

Parameters:bin (str) – bin name.
Return (integer value):
 returns the bin type.

Example:

# bin "a" == type string.
expr = Eq(BinType("a"), aerospike.AS_BYTES_STRING).compile()
class aerospike_helpers.expressions.base.BlobBin(bin: str)

Create an expression that returns a bin as a blob. Returns ‘unknown’ if the bin is not a blob.

__init__(bin: str)

Create an expression that returns a bin as a blob. Returns ‘unknown’ if the bin is not a blob.

Parameters:bin (str) – Bin name.

:return (blob bin)

Example:

#. Blob bin "a" == bytearray([0x65, 0x65])
expr = Eq(BlobBin("a"), bytearray([0x65, 0x65])).compile()
class aerospike_helpers.expressions.base.CmpGeo(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, <MagicMock id='140171716724048'>], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, <MagicMock id='140171716724048'>])

Create a point within region or region contains point expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, <MagicMock id='140171716724048'>], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, <MagicMock id='140171716724048'>])

Create a point within region or region contains point expression.

Parameters:
  • expr0 (TypeGeo) – Left expression in comparrison.
  • expr1 (TypeGeo) – Right expression in comparrison.
Returns:

(boolean value)

Example:

# Geo bin "point" is within geo bin "region".
expr = CmpGeo(GeoBin("point"), GeoBin("region")).compile()
class aerospike_helpers.expressions.base.CmpRegex(options: int, regex_str: str, cmp_str: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a regex match on a string bin or value expression.

__init__(options: int, regex_str: str, cmp_str: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a regex match on a string bin or value expression.

Parameters:
  • options (int) – One of the aerospike regex constants, Regex Flag Values.
  • regex_str (str) – POSIX regex string.
  • cmp_str (Union[_BaseExpr, str]) – String expression to compare against.
Returns:

(boolean value)

Example:

# Select string bin "a" that starts with "prefix" and ends with "suffix".
# Ignore case and do not match newline.
expr = CmpRegex(aerospike.REGEX_ICASE | aerospike.REGEX_NEWLINE, "prefix.*suffix", BinStr("a")).compile()
class aerospike_helpers.expressions.base.DeviceSize

Create an expression that returns record size on disk. If server storage-engine is memory, then zero is returned. This expression usually evaluates quickly because record meta data is cached in memory.

__init__()

Create an expression that returns record size on disk. If server storage-engine is memory, then zero is returned. This expression usually evaluates quickly because record meta data is cached in memory.

Return (integer value):
 Uncompressed storage size of the record.

Example:

# Record device size >= 100 KB.
expr = GE(DeviceSize(), 100 * 1024).compile()
class aerospike_helpers.expressions.base.DigestMod(mod: int)

Create an expression that returns record digest modulo as integer.

__init__(mod: int)

Create an expression that returns record digest modulo as integer.

Parameters:mod (int) – Divisor used to divide the digest to get a remainder.
Return (integer value):
 Value in range 0 and mod (exclusive).

Example:

# Records that have digest(key) % 3 == 1.
expr = Eq(DigestMod(3), 1).compile()
class aerospike_helpers.expressions.base.Eq(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create an equals, (==) expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create an equals, (==) expression.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to ==.
  • expr1 (TypeComparisonArg) – Right argument to ==.
Returns:

(boolean value)

Example:

# Integer bin "a" == 11
expr = Eq(IntBin("a"), 11).compile()
class aerospike_helpers.expressions.base.FloatBin(bin: str)

Create an expression that returns a bin as a float. Returns ‘unknown’ if the bin is not a float.

__init__(bin: str)

Create an expression that returns a bin as a float. Returns ‘unknown’ if the bin is not a float.

Parameters:bin (str) – Bin name.
Returns:(float bin)

Example:

# Float bin "a" > 2.71.
expr = GT(FloatBin("a"), 2.71).compile()
class aerospike_helpers.expressions.base.GE(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a greater than or equal to (>=) expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a greater than or equal to (>=) expression.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to >=.
  • expr1 (TypeComparisonArg) – Right argument to >=.
Returns:

(boolean value)

Example:

# Integer bin "a" >= 88.
expr = GE(IntBin("a"), 88).compile()
class aerospike_helpers.expressions.base.GT(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a greater than (>) expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a greater than (>) expression.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to >.
  • expr1 (TypeComparisonArg) – Right argument to >.
Returns:

(boolean value)

Example:

# Integer bin "a" > 8.
expr = GT(IntBin("a"), 8).compile()
class aerospike_helpers.expressions.base.GeoBin(bin: str)

Create an expression that returns a bin as a geojson. Returns ‘unknown’ if the bin is not a geojson.

__init__(bin: str)

Create an expression that returns a bin as a geojson. Returns ‘unknown’ if the bin is not a geojson.

Parameters:bin (str) – Bin name.

:return (geojson bin)

Example:

#GeoJSON bin "a" contained by GeoJSON bin "b".
expr = CmpGeo(GeoBin("a"), GeoBin("b")).compile()
class aerospike_helpers.expressions.base.HLLBin(bin: str)

Create an expression that returns a bin as a HyperLogLog. Returns ‘unknown’ if the bin is not a HyperLogLog.

__init__(bin: str)

Create an expression that returns a bin as a HyperLogLog. Returns ‘unknown’ if the bin is not a HyperLogLog.

Parameters:bin (str) – Bin name.

:return (HyperLogLog bin)

Example:

# Does HLL bin "a" have a hll_count > 1000000.
expr = GT(HllGetCount(HllBin("a"), 1000000)).compile()
class aerospike_helpers.expressions.base.IntBin(bin: str)

Create an expression that returns a bin as an integer. Returns ‘unknown’ if the bin is not an integer.

__init__(bin: str)

Create an expression that returns a bin as an integer. Returns ‘unknown’ if the bin is not an integer.

Parameters:bin (str) – Bin name.
Returns:(integer bin)

Example:

# Integer bin "a" == 200.
expr = Eq(IntBin("a"), 200).compile()
class aerospike_helpers.expressions.base.IsTombstone

Create an expression that returns if record has been deleted and is still in tombstone state. This expression usually evaluates quickly because record meta data is cached in memory. NOTE: this is only applicable for XDR filter expressions.

__init__()

Create an expression that returns if record has been deleted and is still in tombstone state. This expression usually evaluates quickly because record meta data is cached in memory. NOTE: this is only applicable for XDR filter expressions.

Return (boolean value):
 True if the record is a tombstone, false otherwise.

Example:

# Detect deleted records that are in tombstone state.
expr = IsTombstone().compile()
class aerospike_helpers.expressions.base.KeyBlob

Create an expression that returns the key as a blob. Returns ‘unknown’ if the key is not a blob.

__init__()

Create an expression that returns the key as a blob. Returns ‘unknown’ if the key is not a blob.

Return (blob value):
 Blob value of the key if the key is a blob.

Example:

# blob record key <= bytearray([0x65, 0x65]).
expr = GE(KeyBlob(), bytearray([0x65, 0x65])).compile()
class aerospike_helpers.expressions.base.KeyExists

Create an expression that returns if the primary key is stored in the record storage data as a boolean expression. This would occur on record write, when write policies set the key field to aerospike.POLICY_KEY_SEND.

__init__()

Create an expression that returns if the primary key is stored in the record storage data as a boolean expression. This would occur on record write, when write policies set the key field to aerospike.POLICY_KEY_SEND.

Return (boolean value):
 True if the record has a stored key, false otherwise.

Example:

# Key exists in record meta data.
expr = KeyExists().compile()
class aerospike_helpers.expressions.base.KeyInt

Create an expression that returns the key as an integer. Returns ‘unknown’ if the key is not an integer.

__init__()

Create an expression that returns the key as an integer. Returns ‘unknown’ if the key is not an integer.

Return (integer value):
 Integer value of the key if the key is an integer.

Example:

# Integer record key >= 10000.
expr = GE(KeyInt(), 10000).compile()
class aerospike_helpers.expressions.base.KeyStr

Create an expression that returns the key as a string. Returns ‘unknown’ if the key is not a string.

__init__()

Create an expression that returns the key as a string. Returns ‘unknown’ if the key is not a string.

Return (string value):
 string value of the key if the key is an string.

Example:

# string record key == "aaa".
expr = Eq(KeyStr(), "aaa").compile()
class aerospike_helpers.expressions.base.LE(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a less than or equal to (<=) expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a less than or equal to (<=) expression.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to <=.
  • expr1 (TypeComparisonArg) – Right argument to <=.
Returns:

(boolean value)

Example:

# Integer bin "a" <= 1.
expr = LE(IntBin("a"), 1).compile()
class aerospike_helpers.expressions.base.LT(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a less than (<) expression.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a less than (<) expression.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to <.
  • expr1 (TypeComparisonArg) – Right argument to <.
Returns:

(boolean value)

Example:

# Integer bin "a" < 1000.
expr = LT(IntBin("a"), 1000).compile()
class aerospike_helpers.expressions.base.LastUpdateTime

Create an expression that the returns record last update time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.

__init__()

Create an expression that the returns record last update time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.

Return (integer value):
 When the record was last updated.

Example:

# Record last update time >= 2020-01-15.
expr = GE(LastUpdateTime(), 1577836800).compile()
class aerospike_helpers.expressions.base.ListBin(bin: str)

Create an expression that returns a bin as a list. Returns ‘unknown’ if the bin is not a list.

__init__(bin: str)

Create an expression that returns a bin as a list. Returns ‘unknown’ if the bin is not a list.

Parameters:bin (str) – Bin name.

:return (list bin)

Example:

# List bin "a" contains at least one item with value "abc".
expr = GT(ListGetByValue(None, aerospike.LIST_RETURN_COUNT,
            ResultType.INTEGER, "abc", ListBin("a")),
        0).compile()
class aerospike_helpers.expressions.base.MapBin(bin: str)

Create an expression that returns a bin as a map. Returns ‘unknown’ if the bin is not a map.

__init__(bin: str)

Create an expression that returns a bin as a map. Returns ‘unknown’ if the bin is not a map.

Parameters:bin (str) – Bin name.

:return (map bin)

Example:

# Map bin "a" size > 7.
expr = GT(MapSize(None, MapBin("a")), 7).compile()
class aerospike_helpers.expressions.base.NE(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a not equals (not ==) expressions.

__init__(expr0: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], expr1: Union[aerospike_helpers.expressions.resources._BaseExpr, Any])

Create a not equals (not ==) expressions.

Parameters:
  • expr0 (TypeComparisonArg) – Left argument to not ==.
  • expr1 (TypeComparisonArg) – Right argument to not ==.
Returns:

(boolean value)

Example:

# Integer bin "a" not == 13.
expr = NE(IntBin("a"), 13).compile()
class aerospike_helpers.expressions.base.Not(*exprs)

Create a “not” (not) operator expression.

__init__(*exprs)

Create a “not” (not) operator expression.

Parameters:*exprs (_BaseExpr) – Variable amount of expressions to be negated.
Returns:(boolean value)

Example:

# not (a == 0 or a == 10)
expr = Not(Or(
            Eq(IntBin("a"), 0),
            Eq(IntBin("a"), 10))).compile()
class aerospike_helpers.expressions.base.Or(*exprs)

Create an “or” operator that applies to a variable amount of expressions.

__init__(*exprs)

Create an “or” operator that applies to a variable amount of expressions.

Parameters:*exprs (_BaseExpr) – Variable amount of expressions to be ORed together.
Returns:(boolean value)

Example:

# (a == 0 || b == 0)
expr = Or(
        Eq(IntBin("a"), 0),
        Eq(IntBin("b"), 0)).compile()
class aerospike_helpers.expressions.base.SetName

Create an expression that returns record set name string. This expression usually evaluates quickly because record meta data is cached in memory.

__init__()

Create an expression that returns record set name string. This expression usually evaluates quickly because record meta data is cached in memory.

Return (string value):
 Name of the set this record belongs to.

Example:

# Record set name == "myset".
expr = Eq(SetName(), "myset").compile()
class aerospike_helpers.expressions.base.SinceUpdateTime

Create an expression that returns milliseconds since the record was last updated. This expression usually evaluates quickly because record meta data is cached in memory.

__init__()

Create an expression that returns milliseconds since the record was last updated. This expression usually evaluates quickly because record meta data is cached in memory.

Return (integer value):
 Number of milliseconds since last updated.

Example:

# Record last updated more than 2 hours ago.
expr = GT(SinceUpdateTime(), 2 * 60 * 1000).compile()
class aerospike_helpers.expressions.base.StrBin(bin: str)

Create an expression that returns a bin as a string. Returns ‘unknown’ if the bin is not a string.

__init__(bin: str)

Create an expression that returns a bin as a string. Returns ‘unknown’ if the bin is not a string.

Parameters:bin (str) – Bin name.
Returns:(string bin)

Example:

# String bin "a" == "xyz".
expr = Eq(StrBin("a"), "xyz").compile()
class aerospike_helpers.expressions.base.TTL

Create an expression that returns record expiration time (time to live) in integer seconds.

__init__()

Create an expression that returns record expiration time (time to live) in integer seconds.

Return (integer value):
 Number of seconds till the record will expire, returns -1 if the record never expires.

Example:

# Record expires in less than 1 hour.
expr = LT(TTL(), 60 * 60).compile()
class aerospike_helpers.expressions.base.VoidTime

Create an expression that returns record expiration time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.

__init__()

Create an expression that returns record expiration time expressed as 64 bit integer nanoseconds since 1970-01-01 epoch.

Return (integer value):
 Expiration time in nanoseconds since 1970-01-01.

Example:

# Record expires on 2021-01-01.
expr = And(
        GE(VoidTime(), 1609459200),
        LT(VoidTime(), 1609545600)).compile()

aerospike_helpers.expressions.list module

List expressions contain list read and modify expressions.

Example:

import aerospike_helpers.expressions as exp
#Take the size of list bin "a".
expr = exp.ListSize(None, exp.ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListAppend(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that appends value to end of list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that appends value to end of list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.
  • value (TypeValue) – Value or value expression to append to list.
  • bin (TypeBinName) – List bin or list expression.
Returns:

List expression.

Example:

# Check if length of list bin "a" is > 5 after appending 1 item.
expr = GT(
        ListSize(None, ListAppend(None, None, 3, ListBin("a"))),
        5).compile()
class aerospike_helpers.expressions.list.ListAppendItems(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that appends a list of items to the end of a list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that appends a list of items to the end of a list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.
  • value (TypeValue) – List or list expression of items to be appended.
  • bin (TypeBinName) – Bin name or list expression.
Returns:

List expression.

Example:

# Check if length of list bin "a" is > 5 after appending multiple items.
expr = GT(
        ListSize(None, ListAppendItems(None, None, [3, 2], ListBin("a"))),
        5).compile()
class aerospike_helpers.expressions.list.ListClear(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes all items in a list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes all items in a list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • bin (TypeBinName) – List bin or list expression to clear.
Returns:

List expression.

Example:

# Clear list value of list nested in list bin "a" index 1.
from aerospike_helpers import cdt_ctx
expr = ListClear([cdt_ctx.cdt_ctx_list_index(1)], "a").compile()
class aerospike_helpers.expressions.list.ListGetByIndex(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list item identified by index and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list item identified by index and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • value_type (int) – The value type that will be returned by this expression (ResultType).
  • index (TypeIndex) – Integer or integer expression of index to get element at.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the value at index 0 in list bin "a". (assume this value is an integer)
expr = ListGetByIndex(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 0, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” list items starting at specified index and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” list items starting at specified index and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • index (TypeIndex) – Integer or integer expression of index to start getting elements at.
  • count (TypeCount) – Integer or integer expression for count of elements to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get elements at indexes 3, 4, 5, 6 in list bin "a".
expr = ListGetByIndexRange(None, aerospike.LIST_RETURN_VALUE, 3, 4, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items starting at specified index to the end of list and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items starting at specified index to the end of list and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • index (TypeIndex) – Integer or integer expression of index to start getting elements at.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get element 5 to end from list bin "a".
expr = ListGetByIndexRangeToEnd(None, aerospike.LIST_RETURN_VALUE, 5, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByRank(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list item identified by rank and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list item identified by rank and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value_type (int) – The value type that will be returned by this expression (ResultType).
  • rank (TypeRank) – Rank integer or integer expression of element to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the smallest element in list bin "a".
expr = ListGetByRank(None, aerospike.LIST_RETURN_VALUE, aerospike.ResultType.INTEGER, 0, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” list items starting at specified rank and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” list items starting at specified rank and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • rank (TypeRank) – Rank integer or integer expression of first element to get.
  • count (TypeCount) – Count integer or integer expression for how many elements to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the 3 smallest elements in list bin "a".
expr = ListGetByRankRange(None, aerospike.LIST_RETURN_VALUE, 0, 3, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items starting at specified rank to the last ranked item and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items starting at specified rank to the last ranked item and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • rank (TypeRank) – Rank integer or integer expression of first element to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the three largest elements in list bin "a".
expr = ListGetByRankRangeToEnd(None, aerospike.LIST_RETURN_VALUE, -3, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByValue(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by value and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by value and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value (TypeValue) – Value or value expression of element to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the index of the element with value, 3, in list bin "a".
expr = ListGetByValue(None, aerospike.LIST_RETURN_INDEX, 3, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByValueList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by values and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by values and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value (TypeListValue) – List or list expression of values of elements to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

#Get the indexes of the the elements in list bin "a" with values [3, 6, 12].
expr = ListGetByValueList(None, aerospike.LIST_RETURN_INDEX, [3, 6, 12], ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByValueRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value_end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by value range and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value_end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items identified by value range and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value_begin (TypeValue) – Value or value expression of first element to get.
  • value_end (TypeValue) – Value or value expression of ending element.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get rank of values between 3 (inclusive) and 7 (exclusive) in list bin "a".
expr = ListGetByValueRange(None, aerospike.LIST_RETURN_RANK, 3, 7, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByValueRelRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items nearest to value and greater by relative rank with a count limit and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items nearest to value and greater by relative rank with a count limit and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value (TypeValue) – Value or vaule expression to get items relative to.
  • rank (TypeRank) – Rank intger expression. rank relative to “value” to start getting elements.
  • count (TypeCount) – Integer value or integer value expression, how many elements to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the next 2 values in list bin "a" larger than 3.
expr = ListGetByValueRelRankRange(None, aerospike.LIST_RETURN_VALUE, 3, 1, 2, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListGetByValueRelRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items nearest to value and greater by relative rank

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects list items nearest to value and greater by relative rank and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values One of the aerospike list return types.
  • value (TypeValue) – Value or vaule expression to get items relative to.
  • rank (TypeRank) – Rank intger expression. rank relative to “value” to start getting elements.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the values of all elements in list bin "a" larger than 3.
expr = ListGetByValueRelRankRangeToEnd(None, aerospike.LIST_RETURN_VALUE, 3, 1, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListIncrement(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that increments list[index] by value.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that increments list[index] by value.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.Optional list write policy.
  • index (TypeIndex) – Index of value to increment.
  • value (TypeValue) – Value or value expression.
  • bin (TypeBinName) – Bin name or list expression.
Returns:

List expression.

Example:

# Check if incremented value in list bin "a" is the largest in the list.
expr = Eq(
        ListGetByRank(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, -1, #rank of -1 == largest element.
            ListIncrement(None, None, 1, 5, ListBin("a"))),
        ListGetByIndex(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 1,
            ListIncrement(None, None, 1, 5, ListBin("a")))
).compile()
class aerospike_helpers.expressions.list.ListInsert(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that inserts value to specified index of list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that inserts value to specified index of list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.
  • index (TypeIndex) – Target index for insertion, integer or integer expression.
  • value (TypeValue) – Value or value expression to be inserted.
  • bin (TypeBinName) – Bin name or list expression.
Returns:

List expression.

Example:

# Check if list bin "a" has length > 5 after insert.
expr = GT(
        ListSize(None, ListInsert(None, None, 0, 3, ListBin("a"))),
        5).compile()
class aerospike_helpers.expressions.list.ListInsertItems(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that inserts each input list item starting at specified index of list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that inserts each input list item starting at specified index of list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.Optional list write policy.
  • index (TypeIndex) – Target index where item insertion will begin, integer or integer expression.
  • values (TypeListValue) – List or list expression of items to be inserted.
  • bin (TypeBinName) – Bin name or list expression.
Returns:

List expression.

Example:

# Check if list bin "a" has length > 5 after inserting items.
expr = GT(
        ListSize(None, ListInsertItems(None, None, 0, [4, 7], ListBin("a"))),
        5).compile()
class aerospike_helpers.expressions.list.ListRemoveByIndex(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified index.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Index integer or integer expression of element to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Get size of list bin "a" after index 3 has been removed.
expr = ListSize(None, ListRemoveByIndex(None, 3, ListBin("a"))).compile()
class aerospike_helpers.expressions.list.ListRemoveByIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified index.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Starting index integer or integer expression of elements to remove.
  • count (TypeCount) – Integer or integer expression, how many elements to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Get size of list bin "a" after index 3, 4, and 5 have been removed.
expr = ListSize(None, ListRemoveByIndexRange(None, 3, 3, ListBin("a"))).compile()
class aerospike_helpers.expressions.list.ListRemoveByIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items starting at specified index to the end of list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items starting at specified index to the end of list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Starting index integer or integer expression of elements to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove all elements starting from index 3 in list bin "a".
expr = ListRemoveByIndexRangeToEnd(None, 3, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByRank(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list item identified by rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list item identified by rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove smallest value in list bin "a".
expr = ListRemoveByRank(None, 0, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” list items starting at specified rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to start removing at.
  • count (TypeCount) – Count integer or integer expression of elements to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove the 3 smallest items from list bin "a".
expr = ListRemoveByRankRange(None, 0, 3, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items starting at specified rank to the last ranked item.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items starting at specified rank to the last ranked item.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to start removing at.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove the 2 largest elements from List bin "a".
expr = ListRemoveByRankRangeToEnd(None, -2, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByValue(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by value.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by value.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Value or value expression to remove.
  • bin (TypeBinName) – bin name or bin expression.
Returns:

list expression.

Example:

# See if list bin "a", with `3` removed, is equal to list bin "b".
expr = Eq(ListRemoveByValue(None, 3, ListBin("a")), ListBin("b")).compile()
class aerospike_helpers.expressions.list.ListRemoveByValueList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by values.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by values.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • values (TypeListValue) – List of values or list expression.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove elements with values [1, 2, 3] from list bin "a".
expr = ListRemoveByValueList(None, [1, 2, 3], ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByValueRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by value range (begin inclusive, end exclusive). If begin is None, the range is less than end. If end is None, the range is greater than or equal to begin.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items identified by value range (begin inclusive, end exclusive). If begin is None, the range is less than end. If end is None, the range is greater than or equal to begin.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • begin (TypeValue) – Begin value or value expression for range.
  • end (TypeValue) – End value or value expression for range.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove list of items with values >= 3 and < 7 from list bin "a".
expr = ListRemoveByValueRange(None, 3, 7, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListRemoveByValueRelRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items nearest to value and greater by relative rank with a count limit.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717171792'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items nearest to value and greater by relative rank with a count limit.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Start value or value expression.
  • rank (TypeRank) – Rank integer or integer expression.
  • count (TypeCount) – How many elements to remove.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# After removing the 3 elements larger than 4 by relative rank, does list bin "a" include 9?.
expr = GT(
        ListGetByValue(None, aerospike.LIST_RETURN_COUNT, 9,
            ListRemoveByValueRelRankRange(None, 4, 1, 0, ListBin("a"))),
        0).compile()
class aerospike_helpers.expressions.list.ListRemoveByValueRelRankToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items nearest to value and greater by relative rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717161232'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes list items nearest to value and greater by relative rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Start value or value expression.
  • rank (TypeRank) – Rank integer or integer expression.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Remove elements larger than 4 by relative rank in list bin "a".
expr = ListRemoveByValueRelRankToEnd(None, 4, 1, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListSet(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that sets item value at specified index in list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171717163152'>], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that sets item value at specified index in list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional dictionary of list write options list write options.Optional list write policy.
  • index (TypeIndex) – index of value to set.
  • value (TypeValue) – value or value expression to set index in list to.
  • bin (TypeBinName) – bin name or list expression.
Returns:

List expression.

Example:

# Get smallest element in list bin "a" after setting index 1 to 10.
expr = ListGetByRank(None, aerospike.LIST_RETURN_VALUE, ResultType.INTEGER, 0,
                ListSet(None, None, 1, 10, ListBin("a"))).compile()
class aerospike_helpers.expressions.list.ListSize(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that returns list size.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that returns list size.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Integer expression.

Example:

#Take the size of list bin "a".
expr = ListSize(None, ListBin("a")).compile()
class aerospike_helpers.expressions.list.ListSort(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], order: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that sorts a list.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], order: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that sorts a list.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • order (int) – Optional flags modifiying the behavior of list_sort. This should be constructed by bitwise or’ing together values from List Sort Flags.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

list expression.

Example:

# Get value of sorted list bin "a".
expr = ListSort(None, aerospike.LIST_SORT_DEFAULT, "a").compile()

aerospike_helpers.expressions.map module

Map expressions contain map read and modify expressions.

Example:

import aerospike_helpers.expressions as exp
#Take the size of map bin "b".
expr = exp.MapSize(None, exp.MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapClear(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes all items in map.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes all items in map.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Clear map bin "b".
expr = MapClear(None, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByIndex(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map item identified by index and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map item identified by index and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value_type (int) – The value type that will be returned by this expression (ResultType).
  • index (TypeIndex) – Integer or integer expression of index to get element at.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the value at index 0 in map bin "b". (assume this value is an integer)
expr = MapGetByIndex(None, aerospike.MAP_RETURN_VALUE, ResultType.INTEGER, 0, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” map items starting at specified index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” map items starting at specified index and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • index (TypeIndex) – Integer or integer expression of index to start getting elements at.
  • count (TypeCount) – Integer or integer expression for count of elements to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get elements at indexes 3, 4, 5, 6 in map bin "b".
expr = MapGetByIndexRange(None, aerospike.MAP_RETURN_VALUE, 3, 4, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items starting at specified index to the end of map.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items starting at specified index to the end of map and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • index (TypeIndex) – Integer or integer expression of index to start getting elements at.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get element at index 5 to end from map bin "b".
expr = MapGetByIndexRangeToEnd(None, aerospike.MAP_RETURN_VALUE, 5, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByKey(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map item identified by key and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map item identified by key and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value_type (int) – The value type that will be returned by this expression (ResultType).
  • key (TypeKey) – Key value or value expression of element to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the value at key "key0" in map bin "b". (assume the value at key0 is an integer)
expr = MapGetByKey(None, aerospike.MAP_RETURN_VALUE, ResultType.INTEGER, "key0", MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByKeyList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, keys: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by keys and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, keys: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by keys and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • keys (TypeKeyList) – List of key values or list expression.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get elements at keys "key3", "key4", "key5" in map bin "b".
expr = MapGetByKeyList(None, aerospike.MAP_RETURN_VALUE, ["key3", "key4", "key5"], MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByKeyRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by key range.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by key range (begin inclusive, end exclusive). If begin is nil, the range is less than end. If end is aerospike.CDTInfinite(), the range is greater than equal to begin. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • begin (TypeKey) – Key value or expression.
  • end (TypeKey) – Key value or expression.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get elements at keys "key3", "key4", "key5", "key6" in map bin "b".
expr = MapGetByKeyRange(None, aerospike.MAP_RETURN_VALUE, "key3", "key7", MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByKeyRelIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to key and greater by index with a count limit.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to key and greater by index with a count limit. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • key (TypeKey) – Key value or value expression.
  • index (TypeIndex) – Index integer or integer value expression.
  • count (TypeCount) – Integer count or integer value expression.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the next 2 elements with keys larger than "key3" from map bin "b".
expr = MapGetByKeyRelIndexRange(None, aerospike.MAP_RETURN_VALUE, "key3", 1, 2, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByKeyRelIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to key and greater by index with a count limit.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to key and greater by index with a count limit. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • key (TypeKey) – Key value or value expression.
  • index (TypeIndex) – Index integer or integer value expression.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get elements with keys larger than "key2" from map bin "b".
expr = MapGetByKeyRelIndexRangeToEnd(None, aerospike.MAP_RETURN_VALUE, "key2", 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByRank(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by rank and returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by rank and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value_type (int) – The value type that will be returned by this expression (ResultType).
  • rank (TypeRank) – Rank integer or integer expression of element to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the smallest element in map bin "b".
expr = MapGetByRank(None, aerospike.MAP_RETURN_VALUE, aerospike.ResultType.INTEGER, 0, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” map items starting at specified rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects “count” map items starting at specified rank and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • rank (TypeRank) – Rank integer or integer expression of first element to get.
  • count (TypeCount) – Count integer or integer expression for how many elements to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the 3 smallest elements in map bin "b".
expr = MapGetByRankRange(None, aerospike.MAP_RETURN_VALUE, 0, 3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items starting at specified rank to the last ranked item.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items starting at specified rank to the last ranked item and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • rank (TypeRank) – Rank integer or integer expression of first element to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the three largest elements in map bin "b".
expr = MapGetByRankRangeToEnd(None, aerospike.MAP_RETURN_VALUE, -3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByValue(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by value.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by value and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value (TypeValue) – Value or value expression of element to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the rank of the element with value, 3, in map bin "b".
expr = MapGetByValue(None, aerospike.MAP_RETURN_RANK, 3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByValueList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by values.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by values and returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value (TypeListValue) – List or list expression of values of elements to get.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the indexes of the the elements in map bin "b" with values [3, 6, 12].
expr = MapGetByValueList(None, aerospike.MAP_RETURN_INDEX, [3, 6, 12], MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByValueRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value_end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by value range.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value_begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value_end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items identified by value range (begin inclusive, end exclusive). If begin is None, the range is less than end. If end is None, the range is greater than equal to begin. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value_begin (TypeValue) – Value or value expression of first element to get.
  • value_end (TypeValue) – Value or value expression of ending element.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get elements with values between 3 and 7 from map bin "b".
expr = MapGetByValueRange(None, aerospike.MAP_RETURN_VALUE, 3, 7, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByValueRelRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to value and greater by relative rank with a count limit. Expression returns selected data specified by return_type.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to value and greater by relative rank with a count limit. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike list return types.
  • value (TypeValue) – Value or vaule expression to get items relative to.
  • rank (TypeRank) – Rank intger expression. rank relative to “value” to start getting elements.
  • count (TypeCount) – Integer value or integer value expression, how many elements to get.
  • bin (TypeBinName) – List bin name or list expression.
Returns:

Expression.

Example:

# Get the next 2 values in map bin "b" larger than 3.
expr = MapGetByValueRelRankRange(None, aerospike.MAP_RETURN_VALUE, 3, 1, 2, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapGetByValueRelRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to value and greater by relative rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], return_type: int, value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that selects map items nearest to value and greater by relative rank. Expression returns selected data specified by return_type.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values One of the aerospike map return types.
  • value (TypeValue) – Value or vaule expression to get items relative to.
  • rank (TypeRank) – Rank intger expression. rank relative to “value” to start getting elements.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Expression.

Example:

# Get the values of all elements in map bin "b" larger than 3.
expr = MapGetByValueRelRankRangeToEnd(None, aerospike.MAP_RETURN_VALUE, 3, 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapIncrement(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that increments a map value, by value, for all items identified by key. Valid only for numbers.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that increments a map value, by value, for all items identified by key. Valid only for numbers.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional map write policy.
  • key (TypeKey) – Key value or value expression element to increment.
  • value (TypeValue) – Increment element by value expression.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Increment element at 'vageta' in map bin "b" by 9000.
expr = MapIncrement(None, None, 'vageta', 9000, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapPut(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that writes key/val to map bin.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that writes key/val to map bin.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional map write policy.
  • key (TypeKey) – Key value or value expression to put into map.
  • value (TypeValue) – Value or value expression to put into map.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Put {27: 'key27'} into map bin "b".
expr = MapPut(None, None, 27, 'key27', MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapPutItems(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], map: map, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that writes each map item to map bin.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], policy: Optional[Dict[str, Any]], map: map, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that writes each map item to map bin.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • policy (TypePolicy) – Optional map write policy.
  • map (map) – Map or map expression of items to put into target map.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Put {27: 'key27', 28: 'key28'} into map bin "b".
expr = MapPut(None, None, {27: 'key27', 28: 'key28'}, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByIndex(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map item identified by index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map item identified by index.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Index integer or integer expression of element to remove.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove element with smallest key from map bin "b".
expr = MapRemoveByIndex(None, 0, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes count map items starting at specified index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes count map items starting at specified index.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Starting index integer or integer expression of elements to remove.
  • count (TypeCount) – Integer or integer expression, how many elements to remove.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Map expression.

Example:

# Get size of map bin "b" after index 3, 4, and 5 have been removed.
expr = MapSize(None, MapRemoveByIndexRange(None, 3, 3, MapBin("b"))).compile()
class aerospike_helpers.expressions.map.MapRemoveByIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items starting at specified index to the end of map.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items starting at specified index to the end of map.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • index (TypeIndex) – Starting index integer or integer expression of elements to remove.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Map expression.

Example:

# Remove all elements starting from index 3 in map bin "b".
expr = MapRemoveByIndexRangeToEnd(None, 3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByKey(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes a map item identified by key.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes a map item identified by key.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • key (TypeKey) – Key value or value expression of key to element to remove.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Remove element at key 1 in map bin "b".
expr = MapRemoveByKey(None, 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByKeyList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], keys: List[Union[aerospike_helpers.expressions.resources._BaseExpr, Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by keys.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], keys: List[Union[aerospike_helpers.expressions.resources._BaseExpr, Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by keys.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • key (List[TypeKey]) – List of key values or a list expression of keys to elements to remove.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Remove elements at keys [1, 2] in map bin "b".
expr = MapRemoveByKeyList(None, [1, 2], MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByKeyRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by key range (begin inclusive, end exclusive). If begin is None, the range is less than end. If end is None, the range is greater than equal to begin.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by key range (begin inclusive, end exclusive). If begin is None, the range is less than end. If end is None, the range is greater than equal to begin.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • begin (TypeValue) – Begin value expression.
  • end (TypeValue) – End value expression.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Remove elements at keys between 1 and 10 in map bin "b".
expr = MapRemoveByKeyRange(None, 1, 10 MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByKeyRelIndexRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to key and greater by index with a count limit.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to key and greater by index with a count limit.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • key (TypeKey) – Key value or expression for key to start removing from.
  • index (TypeIndex) – Index integer or integer expression.
  • count (TypeCount) – Integer expression for how many elements to remove.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

[Map expression.

Example:

# Remove 3 elements with keys greater than "key1" from map bin "b".
expr = MapRemoveByKeyRelIndexRange(None, "key1", 1, 3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByKeyRelIndexRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to key and greater by index.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], key: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], index: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716602192'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to key and greater by index.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • key (TypeKey) – Key value or expression for key to start removing from.
  • index (TypeIndex) – Index integer or integer expression.
  • bin (TypeBinName) – Map bin or map expression.
Returns:

Map expression.

Example:

# Map bin "b" has {"key1": 1, "key2": 2, "key3": 3, "key4": 4}.
# Remove each element where the key has greater index than "key1".
expr = MapRemoveByKeyRelIndexRangeToEnd(None, "key1", 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByRank(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map item identified by rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map item identified by rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to remove.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Map expression.

Example:

# Remove smallest value in map bin "b".
expr = MapRemoveByRank(None, 0, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” map items starting at specified rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes “count” map items starting at specified rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to start removing at.
  • count (TypeCount) – Count integer or integer expression of elements to remove.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Map expression.

Example:

# Remove the 3 smallest items from map bin "b".
expr = MapRemoveByRankRange(None, 0, 3, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items starting at specified rank to the last ranked item.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items starting at specified rank to the last ranked item.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • rank (TypeRank) – Rank integer or integer expression of element to start removing at.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Map expression.

Example:

# Remove the 2 largest elements from map bin "b".
expr = MapRemoveByRankRangeToEnd(None, -2, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByValue(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by value.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by value.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Value or value expression to remove.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove {"key1": 1} from map bin "b".
expr = MapRemoveByValue(None, 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByValueList(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by values.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], values: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by values.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • values (TypeListValue) – List of values or list expression.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove elements with values 1, 2, 3 from map bin "b".
expr = MapRemoveByValueList(None, [1, 2, 3], MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByValueRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by value range (begin inclusive, end exclusive). If begin is nil, the range is less than end. If end is aerospike.CDTInfinite(), the range is greater than equal to begin.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], begin: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], end: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items identified by value range (begin inclusive, end exclusive). If begin is nil, the range is less than end. If end is aerospike.CDTInfinite(), the range is greater than equal to begin.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • begin (TypeValue) – Begin value or value expression for range.
  • end (TypeValue) – End value or value expression for range.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove list of items with values >= 3 and < 7 from map bin "b".
expr = MapRemoveByValueRange(None, 3, 7, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByValueRelRankRange(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to value and greater by relative rank with a count limit.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], count: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716969616'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to value and greater by relative rank with a count limit.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Value or value expression to start removing from.
  • rank (TypeRank) – Integer or integer expression of rank.
  • count (TypeCount) – Integer count or integer expression for how many elements to remove.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove the next 4 elements larger than 3 from map bin "b".
expr = MapRemoveByValueRelRankRangeToEnd(None, 3, 1, 4, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapRemoveByValueRelRankRangeToEnd(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to value and greater by relative rank.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], value: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], rank: Union[aerospike_helpers.expressions.resources._BaseExpr, int, <MagicMock id='140171716589904'>], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that removes map items nearest to value and greater by relative rank.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • value (TypeValue) – Value or value expression to start removing from.
  • rank (TypeRank) – Integer or integer expression of rank.
  • bin (TypeBinName) – Bin name or map expression.
Returns:

Map expression.

Example:

# Remove all elements with values larger than 3 from map bin "b".
expr = MapRemoveByValueRelRankRangeToEnd(None, 3, 1, MapBin("b")).compile()
class aerospike_helpers.expressions.map.MapSize(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that returns map size.

__init__(ctx: Union[None, List[aerospike_helpers.cdt_ctx._cdt_ctx]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that returns map size.

Parameters:
  • ctx (TypeCDT) – Optional context path for nested CDT.
  • bin (TypeBinName) – Map bin name or map expression.
Returns:

Integer expression.

Example:

#Take the size of map bin "b".
expr = MapSize(None, MapBin("b")).compile()

aerospike_helpers.expressions.bit module

Bitwise expressions contain bit read and modify expressions.

Example:

import aerospike_helpers.expressions as exp
# Let blob bin "c" == bytearray([3] * 5).
# Count set bits starting at 3rd byte in bin "c" to get count of 6.
expr = exp.BitCount(16, 8 * 3, exp.BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitAdd(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, action: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_add operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, action: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_add operation. Note: integers are stored big-endian.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • value (int) – Integer value or expression for value to add.
  • action (int) – An aerospike bit overflow action.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# Bit add the second byte of bin "c" to get bytearray([1, 2, 1, 1, 1])
expr = BitAdd(None, 8, 8, 1, aerospike.BIT_OVERFLOW_FAIL).compile()
class aerospike_helpers.expressions.bitwise.BitAnd(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_and operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_and operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • value (TypeBitValue) – Bytes value or blob expression containing bytes to use in operation.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# bitwise and `0` with the first byte of blob bin c so that the returned value is bytearray([0, 5, 5, 5, 5]).
expr = BitAnd(None, 0, 8, bytearray([0]), BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitCount(bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_count operation.

__init__(bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_count operation.

Parameters:
  • bit_offset (int) – Bit index of where to start reading.
  • bit_size (int) – Number of bits to count.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Blob, bit_size bits rounded up to the nearest byte size.

Example:

# Let blob bin "c" == bytearray([3] * 5).
# Count set bits starting at 3rd byte in bin "c" to get count of 6.
expr = BitCount(16, 8 * 3, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitGet(bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_get operation.

__init__(bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_get operation.

Parameters:
  • bit_offset (int) – Bit index of where to start reading.
  • bit_size (int) – Number of bits to get.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Blob, bit_size bits rounded up to the nearest byte size.

Example:

# Let blob bin "c" == bytearray([1, 2, 3, 4, 5).
# Get 2 from bin "c".
expr = BitGet(8, 8, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitGetInt(bit_offset: int, bit_size: int, sign: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_get_int operation.

__init__(bit_offset: int, bit_size: int, sign: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_get_int operation.

Parameters:
  • bit_offset (int) – Bit index of where to start reading.
  • bit_size (int) – Number of bits to get.
  • bool (sign) – True for signed, False for unsigned.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Integer expression.

Example:

# Let blob bin "c" == bytearray([1, 2, 3, 4, 5).
# Get 2 as an integer from bin "c".
expr = BitGetInt(8, 8, True, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitInsert(policy: Optional[Dict[str, Any]], byte_offset: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_insert operation.

__init__(policy: Optional[Dict[str, Any]], byte_offset: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_insert operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • byte_offset (int) – Integer byte index of where to insert the value.
  • value (TypeBitValue) – A bytes value or blob value expression to insert.
  • bin (TypeBinName) – Blob bin name or blob value expression.
Returns:

Resulting blob containing the inserted bytes.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# Insert 3 so that returned value is bytearray([1, 3, 1, 1, 1, 1]).
expr = BitInsert(None, 1, bytearray([3]), BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitLeftScan(bit_offset: int, bit_size: int, value: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_lscan operation.

__init__(bit_offset: int, bit_size: int, value: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_lscan operation.

Parameters:
  • bit_offset (int) – Bit index of where to start reading.
  • bit_size (int) – Number of bits to read.
  • bool (value) – Bit value to check for.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Index of the left most bit starting from bit_offset set to value. Returns -1 if not found.

Example:

# Let blob bin "c" == bytearray([3] * 5).
# Scan the first byte of bin "c" for the first bit set to 1. (should get 6)
expr = BitLeftScan(0, 8, True, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitLeftShift(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, shift: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_lshift operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, shift: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_lshift operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • shift (int) – Number of bits to shift by.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# Bit left shift the first byte of bin "c" to get bytearray([8, 1, 1, 1, 1]).
expr = BitLeftShift(None, 0, 8, 3, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitNot(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_not operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_not operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([255] * 5).
# bitwise, not, all of "c" to get bytearray([254] * 5).
expr = BitNot(None, 0, 40, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitOr(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_or operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_or operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • value (TypeBitValue) – Bytes value or blob expression containing bytes to use in operation.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# bitwise Or `8` with the first byte of blob bin c so that the returned value is bytearray([9, 1, 1, 1, 1]).
expr = BitOr(None, 0, 8, bytearray([8]), BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitRemove(policy: Optional[Dict[str, Any]], byte_offset: int, byte_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_remove operation.

__init__(policy: Optional[Dict[str, Any]], byte_offset: int, byte_size: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_remove operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • byte_offset (int) – Byte index of where to start removing from.
  • byte_size (int) – Number of bytes to remove.
  • bin (TypeBinName) – Blob bin name or blob value expression.
Returns:

Resulting blob containing the remaining bytes.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# Remove 1 element so that the returned value is bytearray([1] * 4).
expr = BitRemove(None, 1, 1, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitResize(policy: Optional[Dict[str, Any]], byte_size: int, flags: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_resize operation.

__init__(policy: Optional[Dict[str, Any]], byte_size: int, flags: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_resize operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • byte_size (int) – Number of bytes the resulting blob should occupy.
  • flags (int) – One or a combination of bit resize flags.
  • bin (TypeBinName) – Blob bin name or blob value expression.
Returns:

Blob value expression of resized blob bin.

Example:

# Blob bin "c" == bytearray([1] * 5).
# Resize blob bin "c" from the front so that the returned value is bytearray([0] * 5 + [1] * 5).
expr = BitResize(None, 10, aerospike.BIT_RESIZE_FROM_FRONT, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitRightScan(bit_offset: int, bit_size: int, value: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_rscan operation.

__init__(bit_offset: int, bit_size: int, value: bool, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_rscan operation.

Parameters:
  • bit_offset (int) – Bit index of where to start reading.
  • bit_size (int) – Number of bits to read.
  • bool (value) – Bit value to check for.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Index of the right most bit starting from bit_offset set to value. Returns -1 if not found.

Example:

# Let blob bin "c" == bytearray([3] * 5).
# Scan the first byte of bin "c" for the right most bit set to 1. (should get 7)
expr = BitRightScan(0, 8, True, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitRightShift(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, shift: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_rshift operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, shift: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_rshift operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • shift (int) – Number of bits to shift by.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([8] * 5).
# Bit left shift the first byte of bin "c" to get bytearray([4, 8, 8, 8, 8]).
expr = BitRightShift(None, 0, 8, 1, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitSet(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_set operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_set operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start overwriting.
  • bit_size (int) – Number of bits to overwrite.
  • value (TypeBitValue) – Bytes value or blob expression containing bytes to write.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob expression with the bits overwritten.

Example:

# Let blob bin "c" == bytearray([0] * 5).
# Set bit at offset 7 with size 1 bits to 1 to make the returned value bytearray([1, 0, 0, 0, 0]).
expr = BitSet(None, 7, 1, bytearray([255]), BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitSetInt(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_set_int operation. Note: integers are stored big-endian.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_set_int operation. Note: integers are stored big-endian.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start writing.
  • bit_size (int) – Number of bits to overwrite.
  • value (int) – Integer value or integer expression containing value to write.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob expression with the bits overwritten.

Example:

# Let blob bin "c" == bytearray([0] * 5).
# Set bit at offset 7 with size 1 bytes to 1 to make the returned value bytearray([1, 0, 0, 0, 0]).
expr = BitSetInt(None, 7, 1, 1, BlobBin("c")).compile()
class aerospike_helpers.expressions.bitwise.BitSubtract(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, action: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_subtract operation. Note: integers are stored big-endian.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: int, action: int, bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_subtract operation. Note: integers are stored big-endian.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • value (int) – Integer value or expression for value to add.
  • action (int) – An aerospike bit overflow action.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# Bit subtract the second byte of bin "c" to get bytearray([1, 0, 1, 1, 1])
expr = BitSubtract(None, 8, 8, 1, aerospike.BIT_OVERFLOW_FAIL).compile()
class aerospike_helpers.expressions.bitwise.BitXor(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_xor operation.

__init__(policy: Optional[Dict[str, Any]], bit_offset: int, bit_size: int, value: Union[bytes, bytearray], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs a bit_xor operation.

Parameters:
  • policy (TypePolicy) – An optional aerospike bit policy.
  • bit_offset (int) – Bit index of where to start operation.
  • bit_size (int) – Number of bits to be operated on.
  • value (TypeBitValue) – Bytes value or blob expression containing bytes to use in operation.
  • bin (TypeBinName) – Blob bin name or blob expression.
Returns:

Resulting blob with the bits operated on.

Example:

# Let blob bin "c" == bytearray([1] * 5).
# bitwise Xor `1` with the first byte of blob bin c so that the returned value is bytearray([0, 1, 1, 1, 1]).
expr = BitXor(None, 0, 8, bytearray([1]), BlobBin("c")).compile()

aerospike_helpers.expressions.hllmodule

Hyper Log Log expressions contain hll read and modify expressions.

Example:

import aerospike_helpers.expressions as exp
# Get count from HLL bin "d".
expr = exp.HLLGetCount(exp.HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLAdd(policy: Optional[Dict[str, Any]], list: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], index_bit_count: Optional[int], mh_bit_count: Optional[int], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an hll_add.

__init__(policy: Optional[Dict[str, Any]], list: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], index_bit_count: Optional[int], mh_bit_count: Optional[int], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an hll_add.

Parameters:
  • policy (TypePolicy) – An optional aerospike HLL policy.
  • list (TypeListValue) – A list or list expression of elements to add to the HLL.
  • index_bit_count (int) – Number of index bits. Must be between 4 and 16 inclusive.
  • mh_bit_count (int) – Number of min hash bits. Must be between 4 and 51 inclusive.
  • bin (TypeBinName) – A hll bin name or bin expression to apply this function to.
Returns:

Returns the resulting hll bin after adding elements from list.

Example:

# Let HLL bin "d" have the following elements, ['key1', 'key2', 'key3'], index_bits 8, mh_bits 8.
# Add ['key4', 'key5', 'key6'] so that the returned value is ['key1', 'key2', 'key3', 'key4', 'key5', 'key6']
expr = HLLAdd(None, ['key4', 'key5', 'key6'], 8, 8, HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLDescribe(bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_describe.

__init__(bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_describe.

Parameters:bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:List bin, a list containing the index_bit_count and minhash_bit_count.

Example:

# Get description of HLL bin "d".
expr = HLLDescribe(HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLGetCount(bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_count.

__init__(bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_count.

Parameters:bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:Integer bin, the estimated number of unique elements in an HLL.

Example:

# Get count from HLL bin "d".
expr = HLLGetCount(HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLGetIntersectCount(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_inersect_count.

__init__(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_inersect_count.

Parameters:
  • values (TypeValue) – A single HLL or list of HLLs, values or expressions, to intersect with bin.
  • bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:

Integer bin, estimated number of elements in the set intersection.

Example:

# Let HLLBin "d" contain keys ['key%s' % str(i) for i in range(10000)].
# Let values be a list containing one HLL object with keys ['key%s' % str(i) for i in range(5000, 15000)].
# Find the count of keys in the intersection of HLL bin "d" and all HLLs in values. (Should be around 5000)
expr = HLLGetIntersectCount(values, HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLGetSimilarity(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_similarity.

__init__(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_similarity.

Parameters:
  • values (TypeValue) – A single HLL or list of HLLs, values or expressions, to calculate similarity with.
  • bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:

Float bin, stimated similarity between 0.0 and 1.0.

Example:

# Let HLLBin "d" contain keys ['key%s' % str(i) for i in range(10000)].
# Let values be a list containing one HLL object with keys ['key%s' % str(i) for i in range(5000, 15000)].
# Find the similarity the HLL in values to HLL bin "d". (Should be around 0.33)
# Note that similarity is defined as intersect(A, B, ...) / union(A, B, ...).
expr = HLLGetSimilarity(values, HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLGetUnion(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an hll_get_union.

__init__(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an hll_get_union.

Parameters:
  • values (TypeValue) – A single HLL or list of HLLs, values or expressions, to union with bin.
  • bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:

HLL bin representing the set union.

Example:

# Let HLLBin "d" contain keys ['key%s' % str(i) for i in range(10000)].
# Let values be a list containing HLL objects retrieved from the aerospike database.
# Find the union of HLL bin "d" and all HLLs in values.
expr = HLLGetUnion(values, HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLGetUnionCount(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_union_count.

__init__(values: Union[aerospike_helpers.expressions.resources._BaseExpr, Any], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that performs an as_operations_hll_get_union_count.

Parameters:
  • values (TypeValue) – A single HLL or list of HLLs, values or expressions, to union with bin.
  • bin (TypeBinName) – A hll bin name or bin expression to read from.
Returns:

Integer bin, estimated number of elements in the set union.

Example:

# Let HLLBin "d" contain keys ['key%s' % str(i) for i in range(10000)].
# Let values be a list containing one HLL object with keys ['key%s' % str(i) for i in range(5000, 15000)].
# Find the count of keys in the union of HLL bin "d" and all HLLs in values. (Should be around 15000)
expr = HLLGetUnionCount(values, HLLBin("d")).compile()
class aerospike_helpers.expressions.hll.HLLMayContain(list: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that checks if the HLL bin contains any keys in list.

__init__(list: Union[aerospike_helpers.expressions.resources._BaseExpr, List[Any]], bin: Union[aerospike_helpers.expressions.resources._BaseExpr, str])

Create an expression that checks if the HLL bin contains any keys in list.

Parameters:
  • list (TypeListValue) – A list expression of keys to check if the HLL may contain them.
  • bin (TypeBinName) – Integer bin, a hll bin name or bin expression to read from.
Returns:

1 if bin contains any key in list, 0 otherwise.

Example:

# Check if HLL bin "d" contains any of the keys in `list`.
expr = HLLMayContain(["key1", "key2", "key3"], HLLBin("d")).compile()

aerospike_helpers.expressions.resourcesmodule

Resources used by all expressions.

class aerospike_helpers.expressions.resources.ResultType

Flags used to indicate expression value_type.

BOOLEAN = 1
INTEGER = 2
STRING = 3
LIST = 4
MAP = 5
BLOB = 6
FLOAT = 7
GEOJSON = 8
HLL = 9