Search in sources :

Example 1 with Operation

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

the class MapBase method createRangeOperation.

protected static Operation createRangeOperation(int command, Operation.Type type, String binName, Value begin, Value end, MapReturnType returnType) {
    Packer packer = new Packer();
    packer.packRawShort(command);
    if (begin == null) {
        begin = Value.getAsNull();
    }
    if (end == null) {
        packer.packArrayBegin(2);
        packer.packInt(returnType.type);
        begin.pack(packer);
    } else {
        packer.packArrayBegin(3);
        packer.packInt(returnType.type);
        begin.pack(packer);
        end.pack(packer);
    }
    return new Operation(type, binName, Value.get(packer.toByteArray()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 2 with Operation

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

the class ListOperation method trim.

/**
	 * Create list trim operation.
	 * Server removes "count" 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.
	 */
public static Operation trim(String binName, int index, int count) {
    Packer packer = new Packer();
    packer.packRawShort(TRIM);
    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 3 with Operation

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

the class ListOperation method remove.

/**
	 * Create list remove operation.
	 * Server removes item at specified index from list bin.
	 * Server returns number of items removed.
	 */
public static Operation remove(String binName, int index) {
    Packer packer = new Packer();
    packer.packRawShort(REMOVE);
    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)

Example 4 with Operation

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

the class ListOperation method popRange.

/**
	 * Create list pop range operation.
	 * Server returns "count" items starting at specified index and removes items from list bin.
	 */
public static Operation popRange(String binName, int index, int count) {
    Packer packer = new Packer();
    packer.packRawShort(POP_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 5 with Operation

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

the class MapBase method setMapPolicy.

protected static Operation setMapPolicy(String binName, int attributes) {
    Packer packer = new Packer();
    packer.packRawShort(SET_TYPE);
    packer.packArrayBegin(1);
    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)

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