use of com.aerospike.client.Operation 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.Operation in project aerospike-client-java by aerospike.
the class Command method setOperate.
public final void setOperate(WritePolicy policy, Key key, Operation[] operations, OperateArgs args) {
begin();
int fieldCount = estimateKeySize(policy, key);
dataOffset += args.size;
sizeBuffer();
writeHeader(policy, args.readAttr, args.writeAttr, fieldCount, operations.length);
writeKey(policy, key);
for (Operation operation : operations) {
writeOperation(operation);
}
end();
}
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, 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.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, 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.Operation 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()));
}
Aggregations