Search in sources :

Example 21 with IndexTask

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

the class TestQueryRPS method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask0 = client.register(null, TestQuerySum.class.getClassLoader(), "udf/sum_example.lua", "sum_example.lua", Language.LUA);
    RegisterTask rtask1 = client.register(null, TestQueryExecute.class.getClassLoader(), "udf/record_example.lua", "record_example.lua", Language.LUA);
    rtask0.waitTillComplete();
    rtask1.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, binName1, IndexType.NUMERIC);
        itask.waitTillComplete();
    } catch (AerospikeException ae) {
        if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
            throw ae;
        }
    }
    n_records = records_per_node * client.getNodes().length;
    client.truncate(null, args.namespace, args.set, null);
    for (int i = 1; i <= n_records; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        client.put(null, key, new Bin(binName1, i), new Bin(binName2, i));
    }
}
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 22 with IndexTask

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

the class QueryExecute 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 23 with IndexTask

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

the class QueryFilter 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.STRING);
        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 24 with IndexTask

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

the class QueryRegionFilter 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.GEO2DSPHERE);
        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 25 with IndexTask

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

the class QueryCollection method createIndex.

private void createIndex(AerospikeClient client, Parameters params, String indexName, String binName) throws Exception {
    console.info("Create mapkeys 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.STRING, IndexCollectionType.MAPKEYS);
        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