use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestBitExp method set.
private void set(Key key) {
byte[] bytes = new byte[] { (byte) 0x80 };
policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(24), Exp.val(8), BitExp.set(BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin(binA))));
Record r = client.get(policy, key);
assertEquals(null, r);
policy.filterExp = Exp.build(Exp.eq(BitExp.get(Exp.val(24), Exp.val(8), BitExp.set(BitPolicy.Default, Exp.val(31), Exp.val(1), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(32), Exp.val(8), Exp.blobBin(binA))));
r = client.get(policy, key);
assertRecordFound(key, r);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestBitExp method xor.
private void xor(Key key) {
byte[] bytes = new byte[] { (byte) 0x02 };
policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(8), BitExp.xor(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin(binA))));
Record r = client.get(policy, key);
assertEquals(null, r);
policy.filterExp = Exp.build(Exp.eq(BitExp.get(Exp.val(0), Exp.val(8), BitExp.xor(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(16), Exp.val(8), Exp.blobBin(binA))));
r = client.get(policy, key);
assertRecordFound(key, r);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestBitExp method remove.
private void remove(Key key) {
int expected = 0x42;
policy.filterExp = Exp.build(Exp.ne(BitExp.getInt(Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin(binA))), Exp.val(expected)));
Record r = client.get(policy, key);
assertEquals(null, r);
policy.filterExp = Exp.build(Exp.eq(BitExp.getInt(Exp.val(0), Exp.val(8), false, BitExp.remove(BitPolicy.Default, Exp.val(0), Exp.val(1), Exp.blobBin(binA))), Exp.val(expected)));
r = client.get(policy, key);
assertRecordFound(key, r);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestBitExp method resize.
private void resize(Key key) {
Exp size = Exp.val(6);
policy.filterExp = Exp.build(Exp.ne(BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA)), BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA))));
Record r = client.get(policy, key);
assertEquals(null, r);
policy.filterExp = Exp.build(Exp.eq(BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA)), BitExp.resize(BitPolicy.Default, size, 0, Exp.blobBin(binA))));
r = client.get(policy, key);
assertRecordFound(key, r);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestOperateHll method operateGetUnion.
@Test
public void operateGetUnion() {
int nIndexBits = 14;
long expectedUnionCount = 0;
ArrayList<List<Value>> vals = new ArrayList<List<Value>>();
List<HLLValue> hlls = new ArrayList<HLLValue>();
for (int i = 0; i < keys.length; i++) {
ArrayList<Value> subVals = new ArrayList<Value>();
for (int j = 0; j < nEntries / 3; j++) {
subVals.add(new StringValue("key" + i + " " + j));
}
Record record = assertSuccess("init other keys", keys[i], Operation.delete(), HLLOperation.add(HLLPolicy.Default, binName, subVals, nIndexBits), Operation.get(binName));
List<?> resultList = record.getList(binName);
hlls.add((HLLValue) resultList.get(1));
expectedUnionCount += subVals.size();
vals.add(subVals);
}
// Keep record around win binName is removed.
assertSuccess("other bin", key, Operation.delete(), HLLOperation.init(HLLPolicy.Default, binName + "other", nIndexBits), HLLOperation.add(HLLPolicy.Default, binName, vals.get(0), nIndexBits));
Record record = assertSuccess("union and unionCount", key, HLLOperation.getUnion(binName, hlls), HLLOperation.getUnionCount(binName, hlls));
List<?> resultList = record.getList(binName);
long unionCount = (Long) resultList.get(1);
assertHLLCount("verify union count", nIndexBits, unionCount, expectedUnionCount);
HLLValue unionHll = (HLLValue) resultList.get(0);
record = assertSuccess("", key, Operation.put(new Bin(binName, unionHll)), HLLOperation.getCount(binName));
resultList = record.getList(binName);
long unionCount2 = (Long) resultList.get(1);
assertEquals("unions equal", unionCount, unionCount2);
}
Aggregations