Search in sources :

Example 36 with Packer

use of com.aerospike.client.util.Packer 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 37 with Packer

use of com.aerospike.client.util.Packer 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)

Example 38 with Packer

use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.

the class ListOperation method append.

/**
 * Create default list append operation.
 * Server appends value to end of list bin.
 * Server returns list size.
 */
public static Operation append(String binName, Value value) {
    Packer packer = new Packer();
    packer.packRawShort(APPEND);
    packer.packArrayBegin(1);
    value.pack(packer);
    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 39 with Packer

use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.

the class ListOperation method insertItems.

/**
 * Create list insert items operation with policy.
 * Server inserts each input list item starting at specified index of list bin.
 * Server returns list size.
 */
public static Operation insertItems(ListPolicy policy, String binName, int index, List<Value> list) {
    Packer packer = new Packer();
    packer.packRawShort(INSERT_ITEMS);
    packer.packArrayBegin(3);
    packer.packInt(index);
    packer.packValueList(list);
    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 40 with Packer

use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.

the class ListOperation method append.

/**
 * Create list append operation with policy.
 * Server appends value to list bin.
 * Server returns list size.
 */
public static Operation append(ListPolicy policy, String binName, Value value) {
    Packer packer = new Packer();
    packer.packRawShort(APPEND);
    packer.packArrayBegin(3);
    value.pack(packer);
    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)

Aggregations

Packer (com.aerospike.client.util.Packer)44 Operation (com.aerospike.client.Operation)36