Search in sources :

Example 16 with Policy

use of com.aerospike.client.policy.Policy in project aerospike-client-java by aerospike.

the class QueryString 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;
    IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.STRING);
    task.waitTillComplete();
}
Also used : Policy(com.aerospike.client.policy.Policy) IndexTask(com.aerospike.client.task.IndexTask)

Example 17 with Policy

use of com.aerospike.client.policy.Policy in project aerospike-client-java by aerospike.

the class QueryRegion 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;
    IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.GEO2DSPHERE);
    task.waitTillComplete();
}
Also used : Policy(com.aerospike.client.policy.Policy) IndexTask(com.aerospike.client.task.IndexTask)

Example 18 with Policy

use of com.aerospike.client.policy.Policy 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;
    IndexTask task = client.createIndex(policy, params.namespace, params.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS);
    task.waitTillComplete();
}
Also used : Policy(com.aerospike.client.policy.Policy) IndexTask(com.aerospike.client.task.IndexTask)

Example 19 with Policy

use of com.aerospike.client.policy.Policy in project aerospike-client-java by aerospike.

the class TestQueryCollection method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQueryCollection.class.getClassLoader(), "udf/record_example.lua", "record_example.lua", Language.LUA);
    rtask.waitTillComplete();
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    IndexTask task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS);
    task.waitTillComplete();
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(mapKeyPrefix + 1, mapValuePrefix + i);
        if (i % 2 == 0) {
            map.put(mapKeyPrefix + 2, mapValuePrefix + i);
        }
        if (i % 3 == 0) {
            map.put(mapKeyPrefix + 3, mapValuePrefix + i);
        }
        Bin bin = new Bin(binName, map);
        client.put(null, key, bin);
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) HashMap(java.util.HashMap) 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 20 with Policy

use of com.aerospike.client.policy.Policy in project aerospike-client-java by aerospike.

the class TestQueryExecute method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQueryExecute.class.getClassLoader(), "udf/record_example.lua", "record_example.lua", Language.LUA);
    rtask.waitTillComplete();
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    IndexTask itask = client.createIndex(policy, args.namespace, args.set, indexName, binName1, IndexType.NUMERIC);
    itask.waitTillComplete();
    for (int i = 1; i <= size; 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) 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)

Aggregations

Policy (com.aerospike.client.policy.Policy)24 IndexTask (com.aerospike.client.task.IndexTask)23 BeforeClass (org.junit.BeforeClass)10 Bin (com.aerospike.client.Bin)9 Key (com.aerospike.client.Key)9 RegisterTask (com.aerospike.client.task.RegisterTask)5 WritePolicy (com.aerospike.client.policy.WritePolicy)3 AerospikeException (com.aerospike.client.AerospikeException)1 Record (com.aerospike.client.Record)1 ClientPolicy (com.aerospike.client.policy.ClientPolicy)1 GenerationPolicy (com.aerospike.client.policy.GenerationPolicy)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1