Search in sources :

Example 11 with Operation

use of com.aerospike.client.Operation in project aerospike-client-java by aerospike.

the class CDT method createOperation.

protected static Operation createOperation(int command, Operation.Type type, String binName, int v1, Value v2, int v3) {
    Packer packer = new Packer();
    packer.packRawShort(command);
    packer.packArrayBegin(3);
    packer.packInt(v1);
    v2.pack(packer);
    packer.packInt(v3);
    return new Operation(type, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 12 with Operation

use of com.aerospike.client.Operation in project aerospike-client-java by aerospike.

the class ListOperation method appendItems.

/**
 * Create default list append items operation.
 * Server appends each input list item to end of list bin.
 * Server returns list size.
 */
public static Operation appendItems(String binName, List<Value> list) {
    Packer packer = new Packer();
    packer.packRawShort(APPEND_ITEMS);
    packer.packArrayBegin(1);
    packer.packValueList(list);
    return new Operation(Operation.Type.CDT_MODIFY, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 13 with Operation

use of com.aerospike.client.Operation in project aerospike-client-java by aerospike.

the class ListOperation method appendItems.

/**
 * Create list append items operation with policy.
 * Server appends each input list item to list bin.
 * Server returns list size.
 */
public static Operation appendItems(ListPolicy policy, String binName, List<Value> list) {
    Packer packer = new Packer();
    packer.packRawShort(APPEND_ITEMS);
    packer.packArrayBegin(3);
    packer.packValueList(list);
    packer.packInt(policy.attributes);
    packer.packInt(policy.flags);
    return new Operation(Operation.Type.CDT_MODIFY, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 14 with Operation

use of com.aerospike.client.Operation in project aerospike-client-java by aerospike.

the class ListOperation method insertItems.

/**
 * Create default list insert items operation.
 * Server inserts each input list item starting at specified index of list bin.
 * Server returns list size.
 */
public static Operation insertItems(String binName, int index, List<Value> list) {
    Packer packer = new Packer();
    packer.packRawShort(INSERT_ITEMS);
    packer.packArrayBegin(2);
    packer.packInt(index);
    packer.packValueList(list);
    return new Operation(Operation.Type.CDT_MODIFY, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 15 with Operation

use of com.aerospike.client.Operation in project aerospike-client-java by aerospike.

the class MapOperation method putItems.

/**
 * Create map put items operation
 * Server writes each map item to map bin and returns map size.
 * <p>
 * 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 {@link com.aerospike.client.cdt.MapPolicy} and write mode
 * {@link com.aerospike.client.cdt.MapWriteMode}.
 */
public static Operation putItems(MapPolicy policy, String binName, Map<Value, Value> map) {
    Packer packer = new Packer();
    packer.packRawShort(policy.itemsCommand);
    if (policy.itemsCommand == REPLACE_ITEMS) {
        // Replace doesn't allow map attributes because it does not create on non-existing key.
        packer.packArrayBegin(1);
        packer.packValueMap(map);
    } else {
        packer.packArrayBegin(2);
        packer.packValueMap(map);
        packer.packInt(policy.attributes);
    }
    return new Operation(Operation.Type.MAP_MODIFY, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Aggregations

Operation (com.aerospike.client.Operation)51 Packer (com.aerospike.client.util.Packer)36 Record (com.aerospike.client.Record)6 ArrayList (java.util.ArrayList)6 Key (com.aerospike.client.Key)5 BatchRead (com.aerospike.client.BatchRead)4 CommandExp (com.aerospike.client.exp.CommandExp)4 ListOperation (com.aerospike.client.cdt.ListOperation)3 ExpOperation (com.aerospike.client.exp.ExpOperation)3 Expression (com.aerospike.client.exp.Expression)3 HLLOperation (com.aerospike.client.operation.HLLOperation)3 HLLPolicy (com.aerospike.client.operation.HLLPolicy)3 List (java.util.List)2 Test (org.junit.Test)2 AerospikeException (com.aerospike.client.AerospikeException)1 Bin (com.aerospike.client.Bin)1 Value (com.aerospike.client.Value)1 HLLValue (com.aerospike.client.Value.HLLValue)1 StringValue (com.aerospike.client.Value.StringValue)1 BatchListListener (com.aerospike.client.listener.BatchListListener)1