Search in sources :

Example 21 with Policy

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

the class TestQueryFilter method prepare.

@BeforeClass
public static void prepare() {
    RegisterTask rtask = client.register(null, TestQueryFilter.class.getClassLoader(), "udf/filter_example.lua", "filter_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, binName, IndexType.STRING);
    itask.waitTillComplete();
    writeRecord(keyPrefix + 1, "Charlie", "cpass");
    writeRecord(keyPrefix + 2, "Bill", "hknfpkj");
    writeRecord(keyPrefix + 3, "Doug", "dj6554");
}
Also used : Policy(com.aerospike.client.policy.Policy) IndexTask(com.aerospike.client.task.IndexTask) RegisterTask(com.aerospike.client.task.RegisterTask) BeforeClass(org.junit.BeforeClass)

Example 22 with Policy

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

the class TestQueryKey method prepare.

@BeforeClass
public static void prepare() {
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    IndexTask itask = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
    itask.waitTillComplete();
    WritePolicy writePolicy = new WritePolicy();
    writePolicy.sendKey = true;
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        Bin bin = new Bin(binName, i);
        client.put(writePolicy, key, bin);
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) WritePolicy(com.aerospike.client.policy.WritePolicy) Bin(com.aerospike.client.Bin) IndexTask(com.aerospike.client.task.IndexTask) Key(com.aerospike.client.Key) WritePolicy(com.aerospike.client.policy.WritePolicy) BeforeClass(org.junit.BeforeClass)

Example 23 with Policy

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

the class TestQueryPredExp method prepare.

@BeforeClass
public static void prepare() {
    Policy policy = new Policy();
    // Do not timeout on index create.
    policy.socketTimeout = 0;
    IndexTask task = client.createIndex(policy, args.namespace, setName, indexName, binName, IndexType.NUMERIC);
    task.waitTillComplete();
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, setName, keyPrefix + i);
        List<Integer> list = null;
        Map<String, String> map = null;
        if (i == 1) {
            list = new ArrayList<Integer>(5);
            list.add(1);
            list.add(2);
            list.add(4);
            list.add(9);
            list.add(20);
        // map will be null, which means mapbin will not exist in this record.
        } else if (i == 2) {
            list = new ArrayList<Integer>(3);
            list.add(5);
            list.add(9);
            list.add(100);
        // map will be null, which means mapbin will not exist in this record.
        } else if (i == 3) {
            map = new HashMap<String, String>();
            map.put("A", "AAA");
            map.put("B", "BBB");
            map.put("C", "BBB");
        // list will be null, which means listbin will not exist in this record.
        } else {
            list = new ArrayList<Integer>(0);
            map = new HashMap<String, String>(0);
        }
        client.put(null, key, new Bin(binName, i), new Bin("bin2", i), new Bin("listbin", list), new Bin("mapbin", map));
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) Bin(com.aerospike.client.Bin) IndexTask(com.aerospike.client.task.IndexTask) ArrayList(java.util.ArrayList) Key(com.aerospike.client.Key) BeforeClass(org.junit.BeforeClass)

Example 24 with Policy

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

the class TestQueryString method prepare.

@BeforeClass
public static void prepare() {
    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);
    task.waitTillComplete();
    for (int i = 1; i <= size; i++) {
        Key key = new Key(args.namespace, args.set, keyPrefix + i);
        Bin bin = new Bin(binName, valuePrefix + i);
        client.put(null, key, bin);
    }
}
Also used : Policy(com.aerospike.client.policy.Policy) Bin(com.aerospike.client.Bin) IndexTask(com.aerospike.client.task.IndexTask) 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