use of com.aerospike.client.task.IndexTask 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;
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;
}
}
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);
}
}
use of com.aerospike.client.task.IndexTask 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;
try {
IndexTask task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.STRING);
task.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(binName, valuePrefix + i);
client.put(null, key, bin);
}
}
use of com.aerospike.client.task.IndexTask in project aerospike-client-java by aerospike.
the class TestIndex method createDrop.
@Test
public void createDrop() {
Policy policy = new Policy();
policy.setTimeout(0);
IndexTask task;
// Drop index if it already exists.
try {
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.INDEX_NOTFOUND) {
throw ae;
}
}
task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
task.waitTillComplete();
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.NUMERIC);
task.waitTillComplete();
task = client.dropIndex(policy, args.namespace, args.set, indexName);
task.waitTillComplete();
}
use of com.aerospike.client.task.IndexTask 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;
try {
IndexTask task = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS);
task.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);
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);
}
}
use of com.aerospike.client.task.IndexTask 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;
try {
IndexTask itask = client.createIndex(policy, args.namespace, args.set, indexName, binName, IndexType.STRING);
itask.waitTillComplete();
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
throw ae;
}
}
writeRecord(keyPrefix + 1, "Charlie", "cpass");
writeRecord(keyPrefix + 2, "Bill", "hknfpkj");
writeRecord(keyPrefix + 3, "Doug", "dj6554");
}
Aggregations