Search in sources :

Example 36 with Operation

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

the class ListOperation method size.

/**
	 * Create list size operation.
	 * Server returns size of list.
	 */
public static Operation size(String binName) {
    Packer packer = new Packer();
    packer.packRawShort(SIZE);
    //packer.packArrayBegin(0);
    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 37 with Operation

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

the class ListOperation method insert.

/**
	 * Create list insert operation.
	 * Server inserts value to specified index of list bin.
	 * Server returns list size.
	 */
public static Operation insert(String binName, int index, Value value) {
    Packer packer = new Packer();
    packer.packRawShort(INSERT);
    packer.packArrayBegin(2);
    packer.packInt(index);
    value.pack(packer);
    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 38 with Operation

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

the class ListOperation method removeRange.

/**
	 * Create list remove range operation.
	 * Server removes "count" items starting at specified index from list bin.
	 * Server returns number of items removed.
	 */
public static Operation removeRange(String binName, int index, int count) {
    Packer packer = new Packer();
    packer.packRawShort(REMOVE_RANGE);
    packer.packArrayBegin(2);
    packer.packInt(index);
    packer.packInt(count);
    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 39 with Operation

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

the class ListOperation method set.

/**
	 * Create list set operation.
	 * Server sets item value at specified index in list bin.
	 * Server does not return a result by default.
	 */
public static Operation set(String binName, int index, Value value) {
    Packer packer = new Packer();
    packer.packRawShort(SET);
    packer.packArrayBegin(2);
    packer.packInt(index);
    value.pack(packer);
    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 40 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, Operation.Type type, String binName) {
    Packer packer = new Packer();
    packer.packRawShort(command);
    return new Operation(type, 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