Esempio n. 1
0
    def __init__(self, ctx: TypeCDT, policy: TypePolicy, index: TypeIndex,
                 value: TypeValue, bin: TypeBinName):
        """ Create an expression that sets item value at specified index in list.

            Args:
                ctx (TypeCDT): Optional context path for nested CDT.
                policy (TypePolicy): Optional dictionary of list write options :ref:`list write options <aerospike_list_policies>`.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.

            :return: 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()
        """
        self._children = (index, value,
                          _GenericExpr(_ExprOp._AS_EXP_CODE_CDT_LIST_MOD, 0,
                                       {_Keys.LIST_POLICY_KEY: policy}
                                       if policy is not None else {}),
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx

        if policy is not None:
            self._fixed[_Keys.LIST_POLICY_KEY] = policy
Esempio n. 2
0
    def __init__(self, ctx: TypeCDT, policy: TypePolicy, index: TypeIndex,
                 value: TypeValue, bin: TypeBinName):
        """ Create an expression that increments list[index] by value.

            Args:
                ctx (TypeCDT): Optional context path for nested CDT.
                policy (TypePolicy): Optional dictionary of list write options :ref:`list write options <aerospike_list_policies>`.Optional list write policy.
                index (TypeIndex): Index of value to increment.
                value (TypeValue): Value or value expression.
                bin (TypeBinName): Bin name or list expression.

            :return: 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()
        """
        self._children = (index, value,
                          _GenericExpr(_ExprOp._AS_EXP_CODE_CDT_LIST_CRMOD, 0,
                                       {_Keys.LIST_POLICY_KEY: policy}
                                       if policy is not None else {}),
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx

        if policy is not None:
            self._fixed[_Keys.LIST_POLICY_KEY] = policy
Esempio n. 3
0
    def __init__(
        self,
        ctx: TypeCDT,
        return_type: int,
        value_type: int,
        rank: TypeRank,
        bin: TypeBinName,
    ):
        """ Create an expression that selects list item identified by rank
            and returns selected data specified by return_type.

            Args:
                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 :ref:`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.

            :return: Expression.
        
            Example::

                # Get the smallest element in list bin "a".
                expr = ListGetByRank(None, aerospike.LIST_RETURN_VALUE, aerospike.ResultType.INTEGER, 0, ListBin("a")).compile()
        """
        self._children = (rank,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {
            _Keys.VALUE_TYPE_KEY: value_type,
            _Keys.RETURN_TYPE_KEY: return_type
        }

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 4
0
    def __init__(self, ctx: TypeCDT, return_type: int, rank: TypeRank,
                 bin: TypeBinName):
        """ Create an expression that selects list items starting at specified rank to the last ranked item
            and returns selected data specified by return_type.

            Args:
                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 :ref:`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.

            :return: Expression.
        
            Example::

                # Get the three largest elements in list bin "a".
                expr = ListGetByRankRangeToEnd(None, aerospike.LIST_RETURN_VALUE, -3, ListBin("a")).compile()
        """
        self._children = (rank,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {_Keys.RETURN_TYPE_KEY: return_type}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 5
0
    def __init__(self, ctx: TypeCDT, return_type: int, value_begin: TypeValue,
                 value_end: TypeValue, bin: TypeBinName):
        """ Create an expression that selects list items identified by value range and returns selected
            data specified by return_type.

            Args:
                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 :ref:`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.

            :return: 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()
        """
        self._children = (value_begin, value_end,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {_Keys.RETURN_TYPE_KEY: return_type}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 6
0
    def __init__(self, ctx: TypeCDT, return_type: int, value: TypeListValue,
                 bin: TypeBinName):
        """ Create an expression that selects list items identified by values and returns selected
            data specified by return_type.

            Args:
                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 :ref:`list_return_types` values  Value specifying what should be returned from the operation.
                    This should be one of the :ref:`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.

            :return: 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()
        """
        self._children = (value,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {_Keys.RETURN_TYPE_KEY: return_type}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 7
0
    def __init__(self, ctx: TypeCDT, policy: TypePolicy, value: TypeValue,
                 bin: TypeBinName):
        """ Create an expression that appends a list of items to the end of a list.

            Args:
                ctx (TypeCDT): Optional context path for nested CDT.
                policy (TypePolicy): Optional dictionary of list write options :ref:`list write options <aerospike_list_policies>`.
                value (TypeValue): List or list expression of items to be appended.
                bin (TypeBinName): Bin name or list expression.

            :return: 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()
        """
        self._children = (value,
                          _GenericExpr(_ExprOp._AS_EXP_CODE_CDT_LIST_CRMOD, 0,
                                       {_Keys.LIST_POLICY_KEY: policy}
                                       if policy is not None else {}),
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx

        if policy is not None:
            self._fixed[_Keys.LIST_POLICY_KEY] = policy
Esempio n. 8
0
    def __init__(self, ctx: TypeCDT, policy: TypePolicy, index: TypeIndex,
                 values: TypeListValue, bin: TypeBinName):
        """ Create an expression that inserts each input list item starting at specified index of list.

            Args:
                ctx (TypeCDT): Optional context path for nested CDT.
                policy (TypePolicy): Optional dictionary of list write options :ref:`list write options <aerospike_list_policies>`.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.

            :return: 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()
        """
        self._children = (index, values,
                          _GenericExpr(_ExprOp._AS_EXP_CODE_CDT_LIST_MOD, 0,
                                       {_Keys.LIST_POLICY_KEY: policy}
                                       if policy is not None else {}),
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx

        if policy is not None:
            self._fixed[_Keys.LIST_POLICY_KEY] = policy
Esempio n. 9
0
    def __init__(self, ctx: TypeCDT, return_type: int, index: TypeIndex,
                 count: TypeCount, bin: TypeBinName):
        """ Create an expression that selects "count" list items starting at specified index
            and returns selected data specified by return_type.

            Args:
                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 :ref:`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.

            :return: 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()
        """
        self._children = (index, count,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {_Keys.RETURN_TYPE_KEY: return_type}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 10
0
    def __init__(self, ctx: TypeCDT, value: TypeValue, rank: TypeRank,
                 count: TypeCount, bin: TypeBinName):
        """ Create an expression that removes list items nearest to value and greater by relative rank with a
            count limit.

            Args:
                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.

            :return: 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()
        """
        self._children = (value, rank, count,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 11
0
    def __init__(self, ctx: TypeCDT, begin: TypeValue, end: TypeValue,
                 bin: TypeBinName):
        """ 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.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove list of items with values >= 3 and < 7 from list bin "a".
                expr = ListRemoveByValueRange(None, 3, 7, ListBin("a")).compile()
        """
        self._children = (begin, end,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 12
0
    def __init__(self, ctx: TypeCDT, return_type: int, value: TypeValue,
                 rank: TypeRank, count: TypeCount, bin: TypeBinName):
        """ 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.

            Args:
                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 :ref:`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.

            :return: 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()
        """
        self._children = (value, rank, count,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {_Keys.RETURN_TYPE_KEY: return_type}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 13
0
    def __init__(self, ctx: TypeCDT, bin: TypeBinName):
        """ Create an expression that returns list size.

            Args:
                ctx (TypeCDT): Optional context path for nested CDT.
                bin (TypeBinName): List bin name or list expression.

            :return: Integer expression.
        
            Example::

                #Take the size of list bin "a".
                expr = ListSize(None, ListBin("a")).compile()
        """
        self._children = (bin
                          if isinstance(bin, _BaseExpr) else ListBin(bin), )
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 14
0
    def __init__(self, ctx: TypeCDT, rank: TypeRank, bin: TypeBinName):
        """ Create an expression that removes list items starting at specified rank to the last ranked item.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove the 2 largest elements from List bin "a".
                expr = ListRemoveByRankRangeToEnd(None, -2, ListBin("a")).compile()
        """
        self._children = (rank,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 15
0
    def __init__(self, ctx: TypeCDT, order: int, bin: TypeBinName):
        """ Create an expression that sorts a list.

            Args:
                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 :ref:`aerospike_list_sort_flag`.
                bin (TypeBinName): List bin name or list expression.

            :return: list expression.
        
            Example::

                # Get value of sorted list bin "a".
                expr = ListSort(None, aerospike.LIST_SORT_DEFAULT, "a").compile()
        """
        self._children = (bin
                          if isinstance(bin, _BaseExpr) else ListBin(bin), )
        self._fixed = {_Keys.LIST_ORDER_KEY: order}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 16
0
    def __init__(self, ctx: TypeCDT, index: TypeIndex, bin: TypeBinName):
        """ Create an expression that removes list items starting at specified index to the end of list.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove all elements starting from index 3 in list bin "a".
                expr = ListRemoveByIndexRangeToEnd(None, 3, ListBin("a")).compile()
        """
        self._children = (index,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 17
0
    def __init__(self, ctx: TypeCDT, values: TypeListValue, bin: TypeBinName):
        """ Create an expression that removes list items identified by values.

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

            :return: list expression.
        
            Example::

                # Remove elements with values [1, 2, 3] from list bin "a".
                expr = ListRemoveByValueList(None, [1, 2, 3], ListBin("a")).compile()
        """
        self._children = (values,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 18
0
    def __init__(self, ctx: TypeCDT, value: TypeValue, bin: TypeBinName):
        """ Create an expression that removes list items identified by value.

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

            :return: 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()
        """
        self._children = (value,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 19
0
    def __init__(self, ctx: TypeCDT, rank: TypeRank, bin: TypeBinName):
        """ Create an expression that removes list item identified by rank.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove smallest value in list bin "a".
                expr = ListRemoveByRank(None, 0, ListBin("a")).compile()
        """
        self._children = (rank,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 20
0
    def __init__(self, ctx: TypeCDT, index: TypeIndex, bin: TypeBinName):
        """ Create an expression that removes "count" list items starting at specified index.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Get size of list bin "a" after index 3 has been removed.
                expr = ListSize(None, ListRemoveByIndex(None, 3, ListBin("a"))).compile()
        """
        self._children = (index,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 21
0
    def __init__(self, ctx: TypeCDT, bin: TypeBinName):
        """ Create an expression that removes all items in a list.

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

            :return: 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()
        """
        self._children = (bin
                          if isinstance(bin, _BaseExpr) else ListBin(bin), )
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 22
0
    def __init__(self, ctx: TypeCDT, value: TypeValue, rank: TypeRank,
                 bin: TypeBinName):
        """ Create an expression that removes list items nearest to value and greater by relative rank.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove elements larger than 4 by relative rank in list bin "a".
                expr = ListRemoveByValueRelRankToEnd(None, 4, 1, ListBin("a")).compile()
        """
        self._children = (value, rank,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx
Esempio n. 23
0
    def __init__(self, ctx: TypeCDT, rank: TypeRank, count: TypeCount,
                 bin: TypeBinName):
        """ Create an expression that removes "count" list items starting at specified rank.

            Args:
                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.

            :return: list expression.
        
            Example::

                # Remove the 3 smallest items from list bin "a".
                expr = ListRemoveByRankRange(None, 0, 3, ListBin("a")).compile()
        """
        self._children = (rank, count,
                          bin if isinstance(bin, _BaseExpr) else ListBin(bin))
        self._fixed = {}

        if ctx is not None:
            self._fixed[_Keys.CTX_KEY] = ctx