Search in sources :

Example 6 with Operation

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

the class MapBase method createPut.

protected static Operation createPut(int command, int attributes, String binName, Value value1, Value value2) {
    Packer packer = new Packer();
    packer.packRawShort(command);
    if (command == MapBase.REPLACE) {
        // Replace doesn't allow map attributes because it does not create on non-existing key.
        packer.packArrayBegin(2);
        value1.pack(packer);
        value2.pack(packer);
    } else {
        packer.packArrayBegin(3);
        value1.pack(packer);
        value2.pack(packer);
        packer.packInt(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)

Example 7 with Operation

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

the class MapBase method createOperation.

protected static Operation createOperation(int command, int attributes, String binName, Value value1, Value value2) {
    Packer packer = new Packer();
    packer.packRawShort(command);
    packer.packArrayBegin(3);
    value1.pack(packer);
    value2.pack(packer);
    packer.packInt(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)

Example 8 with Operation

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

the class ListOperation method getRange.

/**
	 * Create list get range operation.
	 * Server returns "count" items starting at specified index in list bin.
	 */
public static Operation getRange(String binName, int index, int count) {
    Packer packer = new Packer();
    packer.packRawShort(GET_RANGE);
    packer.packArrayBegin(2);
    packer.packInt(index);
    packer.packInt(count);
    byte[] bytes = packer.toByteArray();
    return new Operation(Operation.Type.CDT_READ, binName, Value.get(bytes));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 9 with Operation

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

the class ListOperation method clear.

/**
	 * Create list clear operation.
	 * Server removes all items in list bin.
	 * Server does not return a result by default.
	 */
public static Operation clear(String binName) {
    Packer packer = new Packer();
    packer.packRawShort(CLEAR);
    //packer.packArrayBegin(0);
    byte[] bytes = packer.toByteArray();
    return new Operation(Operation.Type.CDT_MODIFY, binName, Value.get(bytes));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 10 with Operation

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

the class ListOperation method pop.

/**
	 * Create list pop operation.
	 * Server returns item at specified index and removes item from list bin.
	 */
public static Operation pop(String binName, int index) {
    Packer packer = new Packer();
    packer.packRawShort(POP);
    packer.packArrayBegin(1);
    packer.packInt(index);
    byte[] bytes = packer.toByteArray();
    return new Operation(Operation.Type.CDT_MODIFY, binName, Value.get(bytes));
}
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