Search in sources :

Example 16 with Operation

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()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 17 with Operation

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();
}
Also used : Operation(com.aerospike.client.Operation)

Example 18 with Operation

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()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 19 with Operation

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()));
}
Also used : Operation(com.aerospike.client.Operation) Packer(com.aerospike.client.util.Packer)

Example 20 with Operation

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