use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestAppend method prepend.
@Test
public void prepend() {
Key key = new Key(args.namespace, args.set, "prependkey");
String binName = args.getBinName("prependbin");
// Delete record if it already exists.
client.delete(null, key);
Bin bin = new Bin(binName, "World");
client.prepend(null, key, bin);
bin = new Bin(binName, "Hello ");
client.prepend(null, key, bin);
Record record = client.get(null, key, bin.name);
assertBinEqual(key, record, bin.name, "Hello World");
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestDeleteBin method deleteBin.
@Test
public void deleteBin() {
Key key = new Key(args.namespace, args.set, "delbinkey");
String binName1 = args.getBinName("bin1");
String binName2 = args.getBinName("bin2");
Bin bin1 = new Bin(binName1, "value1");
Bin bin2 = new Bin(binName2, "value2");
client.put(null, key, bin1, bin2);
// Set bin value to null to drop bin.
bin1 = Bin.asNull(binName1);
client.put(null, key, bin1);
Record record = client.get(null, key, bin1.name, bin2.name, "bin3");
assertRecordFound(key, record);
if (record.getValue("bin1") != null) {
fail("bin1 still exists.");
}
Object v2 = record.getValue("bin2");
assertNotNull(v2);
assertEquals("value2", v2);
}
use of com.aerospike.client.Record in project aerospike-client-java by aerospike.
the class TestBitExp method and.
private void and(Key key) {
byte[] bytes = new byte[] { (byte) 0x01 };
policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(8), BitExp.and(BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(0), 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.and(BitPolicy.Default, Exp.val(16), Exp.val(8), Exp.val(bytes), Exp.blobBin(binA))), BitExp.get(Exp.val(0), 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 insert.
private void insert(Key key) {
byte[] bytes = new byte[] { (byte) 0xff };
int expected = 0xff;
policy.filterExp = Exp.build(Exp.ne(BitExp.getInt(Exp.val(8), Exp.val(8), false, BitExp.insert(BitPolicy.Default, Exp.val(1), Exp.val(bytes), 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(8), Exp.val(8), false, BitExp.insert(BitPolicy.Default, Exp.val(1), Exp.val(bytes), 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 lshift.
private void lshift(Key key) {
policy.filterExp = Exp.build(Exp.ne(BitExp.get(Exp.val(0), Exp.val(6), BitExp.lshift(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(2), Exp.blobBin(binA))), BitExp.get(Exp.val(2), Exp.val(6), 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(6), BitExp.lshift(BitPolicy.Default, Exp.val(0), Exp.val(8), Exp.val(2), Exp.blobBin(binA))), BitExp.get(Exp.val(2), Exp.val(6), Exp.blobBin(binA))));
r = client.get(policy, key);
assertRecordFound(key, r);
}
Aggregations