use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.
the class MapOperation method put.
/**
* Create map put operation.
* Server writes key/value 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 put(MapPolicy policy, String binName, Value key, Value value) {
Packer packer = new Packer();
packer.packRawShort(policy.itemCommand);
if (policy.itemCommand == REPLACE) {
// Replace doesn't allow map attributes because it does not create on non-existing key.
packer.packArrayBegin(2);
key.pack(packer);
value.pack(packer);
} else {
packer.packArrayBegin(3);
key.pack(packer);
value.pack(packer);
packer.packInt(policy.attributes);
}
return new Operation(Operation.Type.MAP_MODIFY, binName, Value.get(packer.toByteArray()));
}
use of com.aerospike.client.util.Packer 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, int v2, int v3) {
Packer packer = new Packer();
packer.packRawShort(command);
packer.packArrayBegin(3);
packer.packInt(v1);
packer.packInt(v2);
packer.packInt(v3);
return new Operation(type, binName, Value.get(packer.toByteArray()));
}
use of com.aerospike.client.util.Packer 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, List<Value> v2) {
Packer packer = new Packer();
packer.packRawShort(command);
packer.packArrayBegin(2);
packer.packInt(v1);
packer.packValueList(v2);
return new Operation(type, binName, Value.get(packer.toByteArray()));
}
use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.
the class CDT method createRangeOperation.
protected static Operation createRangeOperation(int command, Operation.Type type, String binName, Value begin, Value end, int returnType) {
Packer packer = new Packer();
packer.packRawShort(command);
if (begin == null) {
begin = Value.getAsNull();
}
if (end == null) {
packer.packArrayBegin(2);
packer.packInt(returnType);
begin.pack(packer);
} else {
packer.packArrayBegin(3);
packer.packInt(returnType);
begin.pack(packer);
end.pack(packer);
}
return new Operation(type, binName, Value.get(packer.toByteArray()));
}
use of com.aerospike.client.util.Packer in project aerospike-client-java by aerospike.
the class ExpOperation method createOperation.
private static Operation createOperation(Operation.Type type, String name, Expression exp, int flags) {
Packer packer = new Packer();
packer.packArrayBegin(2);
byte[] b = exp.getBytes();
packer.packByteArray(b, 0, b.length);
packer.packInt(flags);
return new Operation(type, name, Value.get(packer.toByteArray()));
}