use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestListExp method modifyWithContext.
@Test
public void modifyWithContext() {
List<Value> listSubA = new ArrayList<Value>();
listSubA.add(Value.get("e"));
listSubA.add(Value.get("d"));
listSubA.add(Value.get("c"));
listSubA.add(Value.get("b"));
listSubA.add(Value.get("a"));
List<Value> listA = new ArrayList<Value>();
listA.add(Value.get("a"));
listA.add(Value.get("b"));
listA.add(Value.get("c"));
listA.add(Value.get("d"));
listA.add(Value.get(listSubA));
List<Value> listB = new ArrayList<Value>();
listB.add(Value.get("x"));
listB.add(Value.get("y"));
listB.add(Value.get("z"));
client.operate(null, keyA, ListOperation.appendItems(ListPolicy.Default, binA, listA), ListOperation.appendItems(ListPolicy.Default, binB, listB), Operation.put(new Bin(binC, "M")));
CTX ctx = CTX.listIndex(4);
Record record;
List<?> result;
policy.filterExp = Exp.build(Exp.eq(ListExp.size(// Temporarily append binB/binC to binA in expression.
ListExp.appendItems(ListPolicy.Default, Exp.listBin(binB), ListExp.append(ListPolicy.Default, Exp.stringBin(binC), Exp.listBin(binA), ctx), ctx), ctx), Exp.val(9)));
record = client.get(policy, keyA, binA);
assertRecordFound(keyA, record);
result = record.getList(binA);
assertEquals(5, result.size());
policy.filterExp = Exp.build(Exp.eq(ListExp.size(// Temporarily append local listB and local "M" string to binA in expression.
ListExp.appendItems(ListPolicy.Default, Exp.val(listB), ListExp.append(ListPolicy.Default, Exp.val("M"), Exp.listBin(binA), ctx), ctx), ctx), Exp.val(9)));
record = client.get(policy, keyA, binA);
assertRecordFound(keyA, record);
result = record.getList(binA);
assertEquals(5, result.size());
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestOperate method operate.
@Test
public void operate() {
// Write initial record.
Key key = new Key(args.namespace, args.set, "opkey");
Bin bin1 = new Bin("optintbin", 7);
Bin bin2 = new Bin("optstringbin", "string value");
client.put(null, key, bin1, bin2);
// Add integer, write new string and read record.
Bin bin3 = new Bin(bin1.name, 4);
Bin bin4 = new Bin(bin2.name, "new string");
Record record = client.operate(null, key, Operation.add(bin3), Operation.put(bin4), Operation.get());
assertBinEqual(key, record, bin3.name, 11);
assertBinEqual(key, record, bin4);
}
use of com.aerospike.client.Bin 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);
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestExpOperation method setUp.
@Before
public void setUp() throws Exception {
client.delete(null, keyA);
client.delete(null, keyB);
client.put(null, keyA, new Bin(binA, 1), new Bin(binD, 2));
client.put(null, keyB, new Bin(binB, 2), new Bin(binD, 2));
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestFilterExp method operateWrite.
@Test
public void operateWrite() {
WritePolicy policy = new WritePolicy();
policy.filterExp = Exp.build(Exp.eq(Exp.intBin(binA), Exp.val(1)));
Bin bin = new Bin(binA, 3);
Record r = client.operate(policy, keyA, Operation.put(bin), Operation.get(binA));
assertBinEqual(keyA, r, binA, 3);
r = client.operate(policy, keyB, Operation.put(bin), Operation.get(binA));
assertEquals(null, r);
}
Aggregations