Class ListExp

java.lang.Object
com.aerospike.client.exp.ListExp

public final class ListExp extends Object
List expression generator. See Exp.

The bin expression argument in these methods can be a reference to a bin or the result of another expression. Expressions that modify bin values are only used for temporary expression evaluation and are not permanently applied to the bin.

List modify expressions return the bin's value. This value will be a list except when the list is nested within a map. In that case, a map is returned for the list modify expression.

List expressions support negative indexing. If the index is negative, the resolved index starts backwards from end of list. If an index is out of bounds, a parameter error will be returned. If a range is partially out of bounds, the valid part of the range will be returned. Index/Range examples:

  • Index 0: First item in list.
  • Index 4: Fifth item in list.
  • Index -1: Last item in list.
  • Index -3: Third to last item in list.
  • Index 1 Count 2: Second and third items in list.
  • Index -3 Count 3: Last three items in list.
  • Index -5 Count 4: Range between fifth to last item to second to last item inclusive.

Nested expressions are supported by optional CTX context arguments. Example:

  • bin = [[7,9,5],[1,2,3],[6,5,4,1]]
  • Get size of last list.
  • ListExp.size(Exp.listBin("bin"), CTX.listIndex(-1))
  • result = 4
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Exp
    append(ListPolicy policy, Exp value, Exp bin, CTX... ctx)
    Create expression that appends value to end of list.
    static Exp
    appendItems(ListPolicy policy, Exp list, Exp bin, CTX... ctx)
    Create expression that appends list items to end of list.
    static Exp
    clear(Exp bin, CTX... ctx)
    Create expression that removes all items in list.
    static Exp
    getByIndex(int returnType, Exp.Type valueType, Exp index, Exp bin, CTX... ctx)
    Create expression that selects list item identified by index and returns selected data specified by returnType.
    static Exp
    getByIndexRange(int returnType, Exp index, Exp bin, CTX... ctx)
    Create expression that selects list items starting at specified index to the end of list and returns selected data specified by returnType (See ListReturnType).
    static Exp
    getByIndexRange(int returnType, Exp index, Exp count, Exp bin, CTX... ctx)
    Create expression that selects "count" list items starting at specified index and returns selected data specified by returnType (See ListReturnType).
    static Exp
    getByRank(int returnType, Exp.Type valueType, Exp rank, Exp bin, CTX... ctx)
    Create expression that selects list item identified by rank and returns selected data specified by returnType.
    static Exp
    getByRankRange(int returnType, Exp rank, Exp bin, CTX... ctx)
    Create expression that selects list items starting at specified rank to the last ranked item and returns selected data specified by returnType (See ListReturnType).
    static Exp
    getByRankRange(int returnType, Exp rank, Exp count, Exp bin, CTX... ctx)
    Create expression that selects "count" list items starting at specified rank and returns selected data specified by returnType (See ListReturnType).
    static Exp
    getByValue(int returnType, Exp value, Exp bin, CTX... ctx)
    Create expression that selects list items identified by value and returns selected data specified by returnType.
    static Exp
    getByValueList(int returnType, Exp values, Exp bin, CTX... ctx)
    Create expression that selects list items identified by values and returns selected data specified by returnType.
    static Exp
    getByValueRange(int returnType, Exp valueBegin, Exp valueEnd, Exp bin, CTX... ctx)
    Create expression that selects list items identified by value range and returns selected data specified by returnType.
    static Exp
    getByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp bin, CTX... ctx)
    Create expression that selects list items nearest to value and greater by relative rank and returns selected data specified by returnType (See ListReturnType).
    static Exp
    getByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp count, Exp bin, CTX... ctx)
    Create expression that selects list items nearest to value and greater by relative rank with a count limit and returns selected data specified by returnType (See ListReturnType).
    static Exp
    increment(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
    Create expression that increments list[index] by value.
    static Exp
    insert(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
    Create expression that inserts value to specified index of list.
    static Exp
    insertItems(ListPolicy policy, Exp index, Exp list, Exp bin, CTX... ctx)
    Create expression that inserts each input list item starting at specified index of list.
    static Exp
    removeByIndex(Exp index, Exp bin, CTX... ctx)
    Create expression that removes list item identified by index.
    static Exp
    removeByIndexRange(int returnType, Exp index, Exp bin, CTX... ctx)
    Create expression that removes list items starting at specified index to the end of list.
    static Exp
    removeByIndexRange(int returnType, Exp index, Exp count, Exp bin, CTX... ctx)
    Create expression that removes "count" list items starting at specified index.
    static Exp
    removeByRank(Exp rank, Exp bin, CTX... ctx)
    Create expression that removes list item identified by rank.
    static Exp
    removeByRankRange(int returnType, Exp rank, Exp bin, CTX... ctx)
    Create expression that removes list items starting at specified rank to the last ranked item.
    static Exp
    removeByRankRange(int returnType, Exp rank, Exp count, Exp bin, CTX... ctx)
    Create expression that removes "count" list items starting at specified rank.
    static Exp
    removeByValue(int returnType, Exp value, Exp bin, CTX... ctx)
    Create expression that removes list items identified by value.
    static Exp
    removeByValueList(int returnType, Exp values, Exp bin, CTX... ctx)
    Create expression that removes list items identified by values.
    static Exp
    removeByValueRange(int returnType, Exp valueBegin, Exp valueEnd, Exp bin, CTX... ctx)
    Create expression that removes list items identified by value range (valueBegin inclusive, valueEnd exclusive).
    static Exp
    removeByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp bin, CTX... ctx)
    Create expression that removes list items nearest to value and greater by relative rank.
    static Exp
    removeByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp count, Exp bin, CTX... ctx)
    Create expression that removes list items nearest to value and greater by relative rank with a count limit.
    static Exp
    set(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
    Create expression that sets item value at specified index in list.
    static Exp
    size(Exp bin, CTX... ctx)
    Create expression that returns list size.
    static Exp
    sort(int sortFlags, Exp bin, CTX... ctx)
    Create expression that sorts list according to sortFlags.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ListExp

      public ListExp()
  • Method Details

    • append

      public static Exp append(ListPolicy policy, Exp value, Exp bin, CTX... ctx)
      Create expression that appends value to end of list.
    • appendItems

      public static Exp appendItems(ListPolicy policy, Exp list, Exp bin, CTX... ctx)
      Create expression that appends list items to end of list.
    • insert

      public static Exp insert(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
      Create expression that inserts value to specified index of list.
    • insertItems

      public static Exp insertItems(ListPolicy policy, Exp index, Exp list, Exp bin, CTX... ctx)
      Create expression that inserts each input list item starting at specified index of list.
    • increment

      public static Exp increment(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
      Create expression that increments list[index] by value. Value expression should resolve to a number.
    • set

      public static Exp set(ListPolicy policy, Exp index, Exp value, Exp bin, CTX... ctx)
      Create expression that sets item value at specified index in list.
    • clear

      public static Exp clear(Exp bin, CTX... ctx)
      Create expression that removes all items in list.
    • sort

      public static Exp sort(int sortFlags, Exp bin, CTX... ctx)
      Create expression that sorts list according to sortFlags.
      Parameters:
      sortFlags - sort flags. See ListSortFlags.
      bin - bin or list value expression
      ctx - optional context path for nested CDT
    • removeByValue

      public static Exp removeByValue(int returnType, Exp value, Exp bin, CTX... ctx)
      Create expression that removes list items identified by value. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByValueList

      public static Exp removeByValueList(int returnType, Exp values, Exp bin, CTX... ctx)
      Create expression that removes list items identified by values. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByValueRange

      public static Exp removeByValueRange(int returnType, Exp valueBegin, Exp valueEnd, Exp bin, CTX... ctx)
      Create expression that removes list items identified by value range (valueBegin inclusive, valueEnd exclusive). If valueBegin is null, the range is less than valueEnd. If valueEnd is null, the range is greater than equal to valueBegin. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByValueRelativeRankRange

      public static Exp removeByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp bin, CTX... ctx)
      Create expression that removes list items nearest to value and greater by relative rank. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.

      Examples for ordered list [0,4,5,9,11,15]:

      • (value,rank) = [removed items]
      • (5,0) = [5,9,11,15]
      • (5,1) = [9,11,15]
      • (5,-1) = [4,5,9,11,15]
      • (3,0) = [4,5,9,11,15]
      • (3,3) = [11,15]
      • (3,-3) = [0,4,5,9,11,15]
    • removeByValueRelativeRankRange

      public static Exp removeByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp count, Exp bin, CTX... ctx)
      Create expression that removes list items nearest to value and greater by relative rank with a count limit. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.

      Examples for ordered list [0,4,5,9,11,15]:

      • (value,rank,count) = [removed items]
      • (5,0,2) = [5,9]
      • (5,1,1) = [9]
      • (5,-1,2) = [4,5]
      • (3,0,1) = [4]
      • (3,3,7) = [11,15]
      • (3,-3,2) = []
    • removeByIndex

      public static Exp removeByIndex(Exp index, Exp bin, CTX... ctx)
      Create expression that removes list item identified by index.
    • removeByIndexRange

      public static Exp removeByIndexRange(int returnType, Exp index, Exp bin, CTX... ctx)
      Create expression that removes list items starting at specified index to the end of list. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByIndexRange

      public static Exp removeByIndexRange(int returnType, Exp index, Exp count, Exp bin, CTX... ctx)
      Create expression that removes "count" list items starting at specified index. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByRank

      public static Exp removeByRank(Exp rank, Exp bin, CTX... ctx)
      Create expression that removes list item identified by rank.
    • removeByRankRange

      public static Exp removeByRankRange(int returnType, Exp rank, Exp bin, CTX... ctx)
      Create expression that removes list items starting at specified rank to the last ranked item. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • removeByRankRange

      public static Exp removeByRankRange(int returnType, Exp rank, Exp count, Exp bin, CTX... ctx)
      Create expression that removes "count" list items starting at specified rank. Valid returnType values are ListReturnType.NONE or ListReturnType.INVERTED.
    • size

      public static Exp size(Exp bin, CTX... ctx)
      Create expression that returns list size.
      
       // List bin "a" size > 7
       Exp.gt(ListExp.size(Exp.listBin("a")), Exp.val(7))
       
    • getByValue

      public static Exp getByValue(int returnType, Exp value, Exp bin, CTX... ctx)
      Create expression that selects list items identified by value and returns selected data specified by returnType.
      
       // List bin "a" contains at least one item == "abc"
       ListExp.getByValue(ListReturnType.EXISTS, Exp.val("abc"), Exp.listBin("a"))
       
      Parameters:
      returnType - metadata attributes to return. See ListReturnType
      value - search expression
      bin - list bin or list value expression
      ctx - optional context path for nested CDT
    • getByValueRange

      public static Exp getByValueRange(int returnType, Exp valueBegin, Exp valueEnd, Exp bin, CTX... ctx)
      Create expression that selects list items identified by value range and returns selected data specified by returnType.
      
       // List bin "a" items >= 10 && items < 20
       ListExp.getByValueRange(ListReturnType.VALUE, Exp.val(10), Exp.val(20), Exp.listBin("a"))
       
      Parameters:
      returnType - metadata attributes to return. See ListReturnType
      valueBegin - begin expression inclusive. If null, range is less than valueEnd.
      valueEnd - end expression exclusive. If null, range is greater than equal to valueBegin.
      bin - bin or list value expression
      ctx - optional context path for nested CDT
    • getByValueList

      public static Exp getByValueList(int returnType, Exp values, Exp bin, CTX... ctx)
      Create expression that selects list items identified by values and returns selected data specified by returnType.
    • getByValueRelativeRankRange

      public static Exp getByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp bin, CTX... ctx)
      Create expression that selects list items nearest to value and greater by relative rank and returns selected data specified by returnType (See ListReturnType).

      Examples for ordered list [0,4,5,9,11,15]:

      • (value,rank) = [selected items]
      • (5,0) = [5,9,11,15]
      • (5,1) = [9,11,15]
      • (5,-1) = [4,5,9,11,15]
      • (3,0) = [4,5,9,11,15]
      • (3,3) = [11,15]
      • (3,-3) = [0,4,5,9,11,15]
    • getByValueRelativeRankRange

      public static Exp getByValueRelativeRankRange(int returnType, Exp value, Exp rank, Exp count, Exp bin, CTX... ctx)
      Create expression that selects list items nearest to value and greater by relative rank with a count limit and returns selected data specified by returnType (See ListReturnType).

      Examples for ordered list [0,4,5,9,11,15]:

      • (value,rank,count) = [selected items]
      • (5,0,2) = [5,9]
      • (5,1,1) = [9]
      • (5,-1,2) = [4,5]
      • (3,0,1) = [4]
      • (3,3,7) = [11,15]
      • (3,-3,2) = []
    • getByIndex

      public static Exp getByIndex(int returnType, Exp.Type valueType, Exp index, Exp bin, CTX... ctx)
      Create expression that selects list item identified by index and returns selected data specified by returnType.
      
       // a[3] == 5
       Exp.eq(
         ListExp.getByIndex(ListReturnType.VALUE, Exp.Type.INT, Exp.val(3), Exp.listBin("a")),
         Exp.val(5));
       
      Parameters:
      returnType - metadata attributes to return. See ListReturnType
      valueType - expected type of return value
      index - list index expression
      bin - list bin or list value expression
      ctx - optional context path for nested CDT
    • getByIndexRange

      public static Exp getByIndexRange(int returnType, Exp index, Exp bin, CTX... ctx)
      Create expression that selects list items starting at specified index to the end of list and returns selected data specified by returnType (See ListReturnType).
    • getByIndexRange

      public static Exp getByIndexRange(int returnType, Exp index, Exp count, Exp bin, CTX... ctx)
      Create expression that selects "count" list items starting at specified index and returns selected data specified by returnType (See ListReturnType).
    • getByRank

      public static Exp getByRank(int returnType, Exp.Type valueType, Exp rank, Exp bin, CTX... ctx)
      Create expression that selects list item identified by rank and returns selected data specified by returnType.
      
       // Player with lowest score.
       ListExp.getByRank(ListReturnType.VALUE, Type.STRING, Exp.val(0), Exp.listBin("a"))
       
      Parameters:
      returnType - metadata attributes to return. See ListReturnType
      valueType - expected type of return value
      rank - rank expression
      bin - list bin or list value expression
      ctx - optional context path for nested CDT
    • getByRankRange

      public static Exp getByRankRange(int returnType, Exp rank, Exp bin, CTX... ctx)
      Create expression that selects list items starting at specified rank to the last ranked item and returns selected data specified by returnType (See ListReturnType).
    • getByRankRange

      public static Exp getByRankRange(int returnType, Exp rank, Exp count, Exp bin, CTX... ctx)
      Create expression that selects "count" list items starting at specified rank and returns selected data specified by returnType (See ListReturnType).