Search in sources :

Example 6 with IndexTask

use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.

the class TestQueryAverage method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQueryAverage.class.getClassLoader(), "udf/average_example.lua", "average_example.lua", Language.LUA);
    rtask.waitTillComplete();
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask itask = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
        itask.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        Bin bin = new Bin("l1", i);
        client.put(null, key, bin, new Bin("l2", 1));
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) Bin(com.aerospike.client.Bin) IndexTask(com.aerospike.client.task.IndexTask) RegisterTask(com.aerospike.client.task.RegisterTask) Key(com.aerospike.client.Key) BeforeClass(org.junit.BeforeClass)

Example 7 with IndexTask

use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.

the class QueryAverage method createIndex.

private void createIndex(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
    console.info("Create index: ns=%s set=%s index=%s bin=%s", params.namespace, params.set, indexName, binName);
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 8 with IndexTask

use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.

the class AsyncQuery method createIndex.

private void createIndex(AerospikeClient client, String indexName, String binName) {
    console.info("Create index: ns=%s set=%s index=%s bin=%s", params.namespace, params.set, indexName, binName);
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Example 9 with IndexTask

use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.

the class TestAsyncQuery method initialize.

@BeforeClass
public static void initialize() {
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask) BeforeClass(org.junit.BeforeClass)

Example 10 with IndexTask

use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.

the class QueryInteger method createIndex.

private void createIndex(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
    console.info("Create index: ns=%s set=%s index=%s bin=%s", params.namespace, params.set, indexName, binName);
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    try {
        IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.NUMERIC);
        task.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) AerospikeException(com.aerospike.client.AerospikeException) IndexTask(com.aerospike.client.task.IndexTask)

Aggregations

AerospikeException (com.aerospike.client.AerospikeException)29 IndexTask (com.aerospike.client.task.IndexTask)29 Policy (com.aerospike.client.policy.Policy)28 BeforeClass (org.junit.BeforeClass)13 Bin (com.aerospike.client.Bin)11 Key (com.aerospike.client.Key)11 RegisterTask (com.aerospike.client.task.RegisterTask)6 QueryPolicy (com.aerospike.client.policy.QueryPolicy)3 WritePolicy (com.aerospike.client.policy.WritePolicy)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1