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()));
}
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()));
}
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()));
}
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()));
}
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()));
}
Aggregations