use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestOperateHll method assertAddInit.
public void assertAddInit(int nIndexBits, int nMinhashBits) {
client.delete(null, key);
String msg = "Fail - nIdexBits " + nIndexBits + " nMinhashBits " + nMinhashBits;
HLLPolicy p = HLLPolicy.Default;
Operation[] ops = new Operation[] { HLLOperation.add(p, binName, entries, nIndexBits, nMinhashBits), HLLOperation.getCount(binName), HLLOperation.refreshCount(binName), HLLOperation.describe(binName), HLLOperation.add(p, binName, entries) };
if (!checkBits(nIndexBits, nMinhashBits)) {
assertThrows(msg, key, AerospikeException.class, ResultCode.PARAMETER_ERROR, ops);
return;
}
Record record = assertSuccess(msg, key, ops);
List<?> resultList = record.getList(binName);
long count = (Long) resultList.get(1);
long count1 = (Long) resultList.get(2);
List<?> description = (List<?>) resultList.get(3);
long nAdded = (Long) resultList.get(4);
assertDescription(msg, description, nIndexBits, nMinhashBits);
assertHLLCount(msg, nIndexBits, count, entries.size());
assertEquals(count, count1);
assertEquals(nAdded, 0);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestOperateHll method assertInit.
public void assertInit(int nIndexBits, int nMinhashBits, boolean shouldPass) {
String msg = "Fail - nIndexBits " + nIndexBits + " nMinhashBits " + nMinhashBits;
HLLPolicy p = HLLPolicy.Default;
Operation[] ops = new Operation[] { HLLOperation.init(p, binName, nIndexBits, nMinhashBits), HLLOperation.getCount(binName), HLLOperation.refreshCount(binName), HLLOperation.describe(binName) };
if (!shouldPass) {
assertThrows(msg, key, AerospikeException.class, ResultCode.PARAMETER_ERROR, ops);
return;
}
Record record = assertSuccess(msg, key, ops);
List<?> resultList = record.getList(binName);
long count = (Long) resultList.get(1);
long count1 = (Long) resultList.get(2);
List<?> description = (List<?>) resultList.get(3);
assertDescription(msg, description, nIndexBits, nMinhashBits);
assertEquals(0, count);
assertEquals(0, count1);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestOperateHll method operateEmptySimilarity.
@Test
public void operateEmptySimilarity() {
for (ArrayList<Integer> desc : legalDescriptions) {
int nIndexBits = desc.get(0);
int nMinhashBits = desc.get(1);
Record record = assertSuccess("init", key, Operation.delete(), HLLOperation.init(HLLPolicy.Default, binName, nIndexBits, nMinhashBits), Operation.get(binName));
List<?> resultList = record.getList(binName);
List<HLLValue> hlls = new ArrayList<HLLValue>();
hlls.add((HLLValue) resultList.get(1));
record = assertSuccess("test", key, HLLOperation.getSimilarity(binName, hlls), HLLOperation.getIntersectCount(binName, hlls));
resultList = record.getList(binName);
double sim = (Double) resultList.get(0);
long intersectCount = (Long) resultList.get(1);
String msg = "(" + nIndexBits + ", " + nMinhashBits + ")";
assertEquals(msg, 0, intersectCount);
assertEquals(msg, Double.NaN, sim, 0.0);
}
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestExpOperation method expMerge.
@Test
public void expMerge() {
Expression e = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(0)));
Expression eand = Exp.build(Exp.and(Exp.expr(e), Exp.eq(Exp.intBin(binD), Exp.val(2))));
Expression eor = Exp.build(Exp.or(Exp.expr(e), Exp.eq(Exp.intBin(binD), Exp.val(2))));
Record record = client.operate(null, keyA, ExpOperation.read("res1", eand, ExpReadFlags.DEFAULT), ExpOperation.read("res2", eor, ExpReadFlags.DEFAULT));
assertRecordFound(keyA, record);
boolean res1 = record.getBoolean("res1");
assertFalse(res1);
boolean res2 = record.getBoolean("res2");
assertTrue(res2);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestExpOperation method expReturnsBoolean.
@Test
public void expReturnsBoolean() {
Expression exp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
Record record = client.operate(null, keyA, ExpOperation.write(binC, exp, ExpWriteFlags.DEFAULT), Operation.get(binC), ExpOperation.read(expVar, exp, ExpReadFlags.DEFAULT));
assertRecordFound(keyA, record);
// System.out.println(record);
List<?> results = record.getList(binC);
boolean val = (Boolean) results.get(1);
assertTrue(val);
val = record.getBoolean(expVar);
assertTrue(val);
}
Aggregations