Class MapOperation

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

public class MapOperation extends Object
Map bin operations. Create map operations used by the client operate command. The default unique key map is unordered. Valid map key types are:
  • String
  • Integer
  • byte[]

The server will validate map key types in an upcoming release.

All maps maintain an index and a rank. The index is the item offset from the start of the map, for both unordered and ordered maps. The rank is the sorted index of the value component. Map supports negative indexing for index and rank.

Index examples:

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

Rank examples:

  • Rank 0: Item with lowest value rank in map.
  • Rank 4: Fifth lowest ranked item in map.
  • Rank -1: Item with highest ranked value in map.
  • Rank -3: Item with third highest ranked value in map.
  • Rank 1 Count 2: Second and third lowest ranked items in map.
  • Rank -3 Count 3: Top three ranked items in map.

Nested CDT operations are supported by optional CTX context arguments. Examples:

  • bin = {key1={key11=9,key12=4}, key2={key21=3,key22=5}}
  • Set map value to 11 for map key "key21" inside of map key "key2".
  • MapOperation.put(MapPolicy.Default, "bin", Value.get("key21"), Value.get(11), CTX.mapKey(Value.get("key2")))
  • bin result = {key1={key11=9,key12=4},key2={key21=11,key22=5}}
  • bin = {key1={key11={key111=1},key12={key121=5}}, key2={key21={"key211",7}}}
  • Set map value to 11 in map key "key121" for highest ranked map ("key12") inside of map key "key1".
  • MapOperation.put(MapPolicy.Default, "bin", Value.get("key121"), Value.get(11), CTX.mapKey(Value.get("key1")), CTX.mapRank(-1))
  • bin result = {key1={key11={key111=1},key12={key121=11}}, key2={key21={"key211",7}}}
  • Constructor Details

    • MapOperation

      public MapOperation()
  • Method Details

    • create

      public static Operation create(String binName, MapOrder order, CTX... ctx)
      Create map create operation. Server creates map at given context level.
    • create

      public static Operation create(String binName, MapOrder order, boolean persistIndex, CTX... ctx)
      Create map create operation. Server creates map at given context level.
      Parameters:
      binName - bin name
      order - map order
      persistIndex - if true, persist map index. A map index improves lookup performance, but requires more storage. A map index can be created for a top-level ordered map only. Nested and unordered map indexes are not supported.
      ctx - optional path to nested map. If not defined, the top-level map is used.
    • setMapPolicy

      public static Operation setMapPolicy(MapPolicy policy, String binName, CTX... ctx)
      Create set map policy operation. Server sets map policy attributes. Server returns null.

      The required map policy attributes can be changed after the map is created.

    • put

      public static Operation put(MapPolicy policy, String binName, Value key, Value value, CTX... ctx)
      Create map put operation. Server writes key/value item to map bin and returns map size.

      The required map policy dictates the type of map to create when it does not exist. The map policy also specifies the flags used when writing items to the map. See policy MapPolicy.

    • putItems

      public static Operation putItems(MapPolicy policy, String binName, Map<Value,Value> map, CTX... ctx)
      Create map put items operation Server writes each map item to map bin and returns map size.

      The required map policy dictates the type of map to create when it does not exist. The map policy also specifies the flags used when writing items to the map. See policy MapPolicy.

    • increment

      public static Operation increment(MapPolicy policy, String binName, Value key, Value incr, CTX... ctx)
      Create map increment operation. Server increments values by incr for all items identified by key and returns final result. Valid only for numbers.

      The required map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. See policy MapPolicy and write flags MapWriteFlags.

    • decrement

      @Deprecated public static Operation decrement(MapPolicy policy, String binName, Value key, Value decr, CTX... ctx)
      Deprecated.
      This method is deprecated. Use increment(MapPolicy, String, Value, Value, CTX...) with a negative value instead.

      Create map decrement operation. Server decrements values by decr for all items identified by key and returns final result. Valid only for numbers.

      The required map policy dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. See policy MapPolicy and write flags MapWriteFlags.

    • clear

      public static Operation clear(String binName, CTX... ctx)
      Create map clear operation. Server removes all items in map. Server returns null.
    • removeByKey

      public static Operation removeByKey(String binName, Value key, int returnType, CTX... ctx)
      Create map remove operation. Server removes map item identified by key and returns removed data specified by returnType (See MapReturnType).
    • removeByKeyList

      public static Operation removeByKeyList(String binName, List<Value> keys, int returnType, CTX... ctx)
      Create map remove operation. Server removes map items identified by keys and returns removed data specified by returnType (See MapReturnType).
    • removeByKeyRange

      public static Operation removeByKeyRange(String binName, Value keyBegin, Value keyEnd, int returnType, CTX... ctx)
      Create map remove operation. Server removes map items identified by key range (keyBegin inclusive, keyEnd exclusive). If keyBegin is null, the range is less than keyEnd. If keyEnd is null, the range is greater than equal to keyBegin.

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

    • removeByKeyRelativeIndexRange

      public static Operation removeByKeyRelativeIndexRange(String binName, Value key, int index, int returnType, CTX... ctx)
      Create map remove by key relative to index range operation. Server removes map items nearest to key and greater by index. Server returns removed data specified by returnType (See MapReturnType).

      Examples for map [{0=17},{4=2},{5=15},{9=10}]:

      • (value,index) = [removed items]
      • (5,0) = [{5=15},{9=10}]
      • (5,1) = [{9=10}]
      • (5,-1) = [{4=2},{5=15},{9=10}]
      • (3,2) = [{9=10}]
      • (3,-2) = [{0=17},{4=2},{5=15},{9=10}]
    • removeByKeyRelativeIndexRange

      public static Operation removeByKeyRelativeIndexRange(String binName, Value key, int index, int count, int returnType, CTX... ctx)
      Create map remove by key relative to index range operation. Server removes map items nearest to key and greater by index with a count limit. Server returns removed data specified by returnType (See MapReturnType).

      Examples for map [{0=17},{4=2},{5=15},{9=10}]:

      • (value,index,count) = [removed items]
      • (5,0,1) = [{5=15}]
      • (5,1,2) = [{9=10}]
      • (5,-1,1) = [{4=2}]
      • (3,2,1) = [{9=10}]
      • (3,-2,2) = [{0=17}]
    • removeByValue

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

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

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

    • removeByValueRelativeRankRange

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

      Examples for map [{4=2},{9=10},{5=15},{0=17}]:

      • (value,rank) = [removed items]
      • (11,1) = [{0=17}]
      • (11,-1) = [{9=10},{5=15},{0=17}]
    • removeByValueRelativeRankRange

      public static Operation removeByValueRelativeRankRange(String binName, Value value, int rank, int count, int returnType, CTX... ctx)
      Create map remove by value relative to rank range operation. Server removes map items nearest to value and greater by relative rank with a count limit. Server returns removed data specified by returnType (See MapReturnType).

      Examples for map [{4=2},{9=10},{5=15},{0=17}]:

      • (value,rank,count) = [removed items]
      • (11,1,1) = [{0=17}]
      • (11,-1,1) = [{9=10}]
    • removeByIndex

      public static Operation removeByIndex(String binName, int index, int returnType, CTX... ctx)
      Create map remove operation. Server removes map item identified by index and returns removed data specified by returnType (See MapReturnType).
    • removeByIndexRange

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

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

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

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

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

      public static Operation size(String binName, CTX... ctx)
      Create map size operation. Server returns size of map.
    • getByKey

      public static Operation getByKey(String binName, Value key, int returnType, CTX... ctx)
      Create map get by key operation. Server selects map item identified by key and returns selected data specified by returnType (See MapReturnType).
    • getByKeyRange

      public static Operation getByKeyRange(String binName, Value keyBegin, Value keyEnd, int returnType, CTX... ctx)
      Create map get by key range operation. Server selects map items identified by key range (keyBegin inclusive, keyEnd exclusive). If keyBegin is null, the range is less than keyEnd. If keyEnd is null, the range is greater than equal to keyBegin.

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

    • getByKeyList

      public static Operation getByKeyList(String binName, List<Value> keys, int returnType, CTX... ctx)
      Create map get by key list operation. Server selects map items identified by keys and returns selected data specified by returnType (See MapReturnType).
    • getByKeyRelativeIndexRange

      public static Operation getByKeyRelativeIndexRange(String binName, Value key, int index, int returnType, CTX... ctx)
      Create map get by key relative to index range operation. Server selects map items nearest to key and greater by index. Server returns selected data specified by returnType (See MapReturnType).

      Examples for ordered map [{0=17},{4=2},{5=15},{9=10}]:

      • (value,index) = [selected items]
      • (5,0) = [{5=15},{9=10}]
      • (5,1) = [{9=10}]
      • (5,-1) = [{4=2},{5=15},{9=10}]
      • (3,2) = [{9=10}]
      • (3,-2) = [{0=17},{4=2},{5=15},{9=10}]
    • getByKeyRelativeIndexRange

      public static Operation getByKeyRelativeIndexRange(String binName, Value key, int index, int count, int returnType, CTX... ctx)
      Create map get by key relative to index range operation. Server selects map items nearest to key and greater by index with a count limit. Server returns selected data specified by returnType (See MapReturnType).

      Examples for ordered map [{0=17},{4=2},{5=15},{9=10}]:

      • (value,index,count) = [selected items]
      • (5,0,1) = [{5=15}]
      • (5,1,2) = [{9=10}]
      • (5,-1,1) = [{4=2}]
      • (3,2,1) = [{9=10}]
      • (3,-2,2) = [{0=17}]
    • getByValue

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

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

    • getByValueList

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

      public static Operation getByValueRelativeRankRange(String binName, Value value, int rank, int returnType, CTX... ctx)
      Create map get by value relative to rank range operation. Server selects map items nearest to value and greater by relative rank. Server returns selected data specified by returnType (See MapReturnType).

      Examples for map [{4=2},{9=10},{5=15},{0=17}]:

      • (value,rank) = [selected items]
      • (11,1) = [{0=17}]
      • (11,-1) = [{9=10},{5=15},{0=17}]
    • getByValueRelativeRankRange

      public static Operation getByValueRelativeRankRange(String binName, Value value, int rank, int count, int returnType, CTX... ctx)
      Create map get by value relative to rank range operation. Server selects map items nearest to value and greater by relative rank with a count limit. Server returns selected data specified by returnType (See MapReturnType).

      Examples for map [{4=2},{9=10},{5=15},{0=17}]:

      • (value,rank,count) = [selected items]
      • (11,1,1) = [{0=17}]
      • (11,-1,1) = [{9=10}]
    • getByIndex

      public static Operation getByIndex(String binName, int index, int returnType, CTX... ctx)
      Create map get by index operation. Server selects map item identified by index and returns selected data specified by returnType (See MapReturnType).
    • getByIndexRange

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

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

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

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

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