Class ListOperation

java.lang.Object
com.aerospike.client.cdt.ListOperation

public class ListOperation
extends Object
List bin operations. Create list operations used by client operate command.

List operations 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 CDT operations are supported by optional CTX context arguments. Examples:

  • bin = [[7,9,5],[1,2,3],[6,5,4,1]]
  • Append 11 to last list.
  • ListOperation.append("bin", Value.get(11), CTX.listIndex(-1))
  • bin result = [[7,9,5],[1,2,3],[6,5,4,1,11]]
  • bin = {key1=[[7,9,5],[13]], key2=[[9],[2,4],[6,1,9]], key3=[[6,5]]}
  • Append 11 to lowest ranked list in map identified by "key2".
  • ListOperation.append("bin", Value.get(11), CTX.mapKey(Value.get("key2")), CTX.listRank(0))
  • bin result = {key1=[[7,9,5],[13]], key2=[[9],[2,4,11],[6,1,9]], key3=[[6,5]]}
  • Constructor Details

  • Method Details

    • create

      public static Operation create​(String binName, ListOrder order, boolean pad, CTX... ctx)
      Create list create operation. Server creates list at given context level. The context is allowed to be beyond list boundaries only if pad is set to true. In that case, nil list entries will be inserted to satisfy the context position.
    • setOrder

      public static Operation setOrder​(String binName, ListOrder order, CTX... ctx)
      Create set list order operation. Server sets list order. Server returns null.
    • append

      public static Operation append​(String binName, Value value, CTX... ctx)
      Create default list append operation. Server appends value to end of list bin. Server returns list size.
    • append

      public static Operation append​(ListPolicy policy, String binName, Value value, CTX... ctx)
      Create list append operation with policy. Server appends value to list bin. Server returns list size.
    • appendItems

      public static Operation appendItems​(String binName, List<Value> list, CTX... ctx)
      Create default list append items operation. Server appends each input list item to end of list bin. Server returns list size.
    • appendItems

      public static Operation appendItems​(ListPolicy policy, String binName, List<Value> list, CTX... ctx)
      Create list append items operation with policy. Server appends each input list item to list bin. Server returns list size.
    • insert

      public static Operation insert​(String binName, int index, Value value, CTX... ctx)
      Create default list insert operation. Server inserts value to specified index of list bin. Server returns list size.
    • insert

      public static Operation insert​(ListPolicy policy, String binName, int index, Value value, CTX... ctx)
      Create list insert operation with policy. Server inserts value to specified index of list bin. Server returns list size.
    • insertItems

      public static Operation insertItems​(String binName, int index, List<Value> list, CTX... ctx)
      Create default list insert items operation. Server inserts each input list item starting at specified index of list bin. Server returns list size.
    • insertItems

      public static Operation insertItems​(ListPolicy policy, String binName, int index, List<Value> list, CTX... ctx)
      Create list insert items operation with policy. Server inserts each input list item starting at specified index of list bin. Server returns list size.
    • increment

      public static Operation increment​(String binName, int index, CTX... ctx)
      Create default list increment operation. Server increments list[index] by 1. Server returns list[index] after incrementing.
    • increment

      public static Operation increment​(ListPolicy policy, String binName, int index, CTX... ctx)
      Create list increment operation with policy. Server increments list[index] by 1. Server returns list[index] after incrementing.
    • increment

      public static Operation increment​(String binName, int index, Value value, CTX... ctx)
      Create default list increment operation. Server increments list[index] by value. Value should be integer(IntegerValue, LongValue) or double(DoubleValue, FloatValue). Server returns list[index] after incrementing.
    • increment

      public static Operation increment​(ListPolicy policy, String binName, int index, Value value, CTX... ctx)
      Create list increment operation. Server increments list[index] by value. Value should be integer(IntegerValue, LongValue) or double(DoubleValue, FloatValue). Server returns list[index] after incrementing.
    • pop

      public static Operation pop​(String binName, int index, CTX... ctx)
      Create list pop operation. Server returns item at specified index and removes item from list bin.
    • popRange

      public static Operation popRange​(String binName, int index, int count, CTX... ctx)
      Create list pop range operation. Server returns "count" items starting at specified index and removes items from list bin.
    • popRange

      public static Operation popRange​(String binName, int index, CTX... ctx)
      Create list pop range operation. Server returns items starting at specified index to the end of list and removes those items from list bin.
    • remove

      public static Operation remove​(String binName, int index, CTX... ctx)
      Create list remove operation. Server removes item at specified index from list bin. Server returns number of items removed.
    • removeRange

      public static Operation removeRange​(String binName, int index, int count, CTX... ctx)
      Create list remove range operation. Server removes "count" items starting at specified index from list bin. Server returns number of items removed.
    • removeRange

      public static Operation removeRange​(String binName, int index, CTX... ctx)
      Create list remove range operation. Server removes items starting at specified index to the end of list. Server returns number of items removed.
    • set

      public static Operation set​(String binName, int index, Value value, CTX... ctx)
      Create list set operation. Server sets item value at specified index in list bin. Server does not return a result by default.
    • set

      public static Operation set​(ListPolicy policy, String binName, int index, Value value, CTX... ctx)
      Create list set operation with policy. Server sets item value at specified index in list bin. Server does not return a result by default.
    • trim

      public static Operation trim​(String binName, int index, int count, CTX... ctx)
      Create list trim operation. Server removes items in list bin that do not fall into range specified by index and count range. If the range is out of bounds, then all items will be removed. Server returns list size after trim.
    • clear

      public static Operation clear​(String binName, CTX... ctx)
      Create list clear operation. Server removes all items in list bin. Server does not return a result by default.
    • sort

      public static Operation sort​(String binName, int sortFlags, CTX... ctx)
      Create list sort operation. Server sorts list according to sortFlags. Server does not return a result by default.
      Parameters:
      binName - server bin name
      sortFlags - sort flags. See ListSortFlags.
    • removeByValue

      public static Operation removeByValue​(String binName, Value value, int returnType, CTX... ctx)
      Create list remove operation. Server removes list items identified by value and returns removed data specified by returnType (See ListReturnType).
    • removeByValueList

      public static Operation removeByValueList​(String binName, List<Value> values, int returnType, CTX... ctx)
      Create list remove operation. Server removes list items identified by values and returns removed data specified by returnType (See ListReturnType).
    • removeByValueRange

      public static Operation removeByValueRange​(String binName, Value valueBegin, Value valueEnd, int returnType, CTX... ctx)
      Create list remove operation. Server 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.

      Server returns removed data specified by returnType (See ListReturnType).

    • removeByValueRelativeRankRange

      public static Operation removeByValueRelativeRankRange​(String binName, Value value, int rank, int returnType, CTX... ctx)
      Create list remove by value relative to rank range operation. Server removes list items nearest to value and greater by relative rank. Server returns removed data specified by returnType (See ListReturnType).

      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 Operation removeByValueRelativeRankRange​(String binName, Value value, int rank, int count, int returnType, CTX... ctx)
      Create list remove by value relative to rank range operation. Server removes list items nearest to value and greater by relative rank with a count limit. Server returns removed data specified by returnType (See ListReturnType).

      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 Operation removeByIndex​(String binName, int index, int returnType, CTX... ctx)
      Create list remove operation. Server removes list item identified by index and returns removed data specified by returnType (See ListReturnType).
    • removeByIndexRange

      public static Operation removeByIndexRange​(String binName, int index, int returnType, CTX... ctx)
      Create list remove operation. Server removes list items starting at specified index to the end of list and returns removed data specified by returnType (See ListReturnType).
    • removeByIndexRange

      public static Operation removeByIndexRange​(String binName, int index, int count, int returnType, CTX... ctx)
      Create list remove operation. Server removes "count" list items starting at specified index and returns removed data specified by returnType (See ListReturnType).
    • removeByRank

      public static Operation removeByRank​(String binName, int rank, int returnType, CTX... ctx)
      Create list remove operation. Server removes list item identified by rank and returns removed data specified by returnType (See ListReturnType).
    • removeByRankRange

      public static Operation removeByRankRange​(String binName, int rank, int returnType, CTX... ctx)
      Create list remove operation. Server removes list items starting at specified rank to the last ranked item and returns removed data specified by returnType (See ListReturnType).
    • removeByRankRange

      public static Operation removeByRankRange​(String binName, int rank, int count, int returnType, CTX... ctx)
      Create list remove operation. Server removes "count" list items starting at specified rank and returns removed data specified by returnType (See ListReturnType).
    • size

      public static Operation size​(String binName, CTX... ctx)
      Create list size operation. Server returns size of list.
    • get

      public static Operation get​(String binName, int index, CTX... ctx)
      Create list get operation. Server returns item at specified index in list bin.
    • getRange

      public static Operation getRange​(String binName, int index, int count, CTX... ctx)
      Create list get range operation. Server returns "count" items starting at specified index in list bin.
    • getRange

      public static Operation getRange​(String binName, int index, CTX... ctx)
      Create list get range operation. Server returns items starting at index to the end of list.
    • getByValue

      public static Operation getByValue​(String binName, Value value, int returnType, CTX... ctx)
      Create list get by value operation. Server selects list items identified by value and returns selected data specified by returnType (See ListReturnType).
    • getByValueRange

      public static Operation getByValueRange​(String binName, Value valueBegin, Value valueEnd, int returnType, CTX... ctx)
      Create list get by value range operation. Server selects 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.

      Server returns selected data specified by returnType (See ListReturnType).

    • getByValueList

      public static Operation getByValueList​(String binName, List<Value> values, int returnType, CTX... ctx)
      Create list get by value list operation. Server selects list items identified by values and returns selected data specified by returnType (See ListReturnType).
    • getByValueRelativeRankRange

      public static Operation getByValueRelativeRankRange​(String binName, Value value, int rank, int returnType, CTX... ctx)
      Create list get by value relative to rank range operation. Server selects list items nearest to value and greater by relative rank. Server 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 Operation getByValueRelativeRankRange​(String binName, Value value, int rank, int count, int returnType, CTX... ctx)
      Create list get by value relative to rank range operation. Server selects list items nearest to value and greater by relative rank with a count limit. Server 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 Operation getByIndex​(String binName, int index, int returnType, CTX... ctx)
      Create list get by index operation. Server selects list item identified by index and returns selected data specified by returnType (See ListReturnType).
    • getByIndexRange

      public static Operation getByIndexRange​(String binName, int index, int returnType, CTX... ctx)
      Create list get by index range operation. Server selects list items starting at specified index to the end of list and returns selected data specified by returnType (See ListReturnType).
    • getByIndexRange

      public static Operation getByIndexRange​(String binName, int index, int count, int returnType, CTX... ctx)
      Create list get by index range operation. Server selects "count" list items starting at specified index and returns selected data specified by returnType (See ListReturnType).
    • getByRank

      public static Operation getByRank​(String binName, int rank, int returnType, CTX... ctx)
      Create list get by rank operation. Server selects list item identified by rank and returns selected data specified by returnType (See ListReturnType).
    • getByRankRange

      public static Operation getByRankRange​(String binName, int rank, int returnType, CTX... ctx)
      Create list get by rank range operation. Server selects list items starting at specified rank to the last ranked item and returns selected data specified by returnType (See ListReturnType).
    • getByRankRange

      public static Operation getByRankRange​(String binName, int rank, int count, int returnType, CTX... ctx)
      Create list get by rank range operation. Server selects "count" list items starting at specified rank and returns selected data specified by returnType (See ListReturnType).