use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class UserDefinedFunction method writeUsingUdf.
private void writeUsingUdf(AerospikeClient client, Parameters params) throws Exception {
Key key = new Key(params.namespace, params.set, "udfkey1");
Bin bin = new Bin(params.getBinName("udfbin1"), "string value");
client.execute(params.writePolicy, key, "record_example", "writeBin", Value.get(bin.name), bin.value);
Record record = client.get(params.policy, key, bin.name);
String expected = bin.value.toString();
String received = record.getString(bin.name);
if (received != null && received.equals(expected)) {
console.info("Data matched: namespace=%s set=%s key=%s bin=%s value=%s", key.namespace, key.setName, key.userKey, bin.name, received);
} else {
console.error("Data mismatch: Expected %s. Received %s.", expected, received);
}
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestAsyncPutGet method asyncPutGetWithRetry.
@Test
public void asyncPutGetWithRetry() {
final Key key = new Key(args.namespace, args.set, "putgetkey2");
final Bin bin = new Bin(binName, "value");
client.put(eventLoop, new WriteHandler(client, null, key, bin), null, key, bin);
waitTillComplete();
}
use of com.aerospike.client.Bin 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.Bin 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.Bin in project aerospike-client-java by aerospike.
the class TestBitExp method callRead.
@Test
public void callRead() {
Key key = new Key(args.namespace, args.set, 5000);
client.delete(null, key);
Bin bin = new Bin(binA, new byte[] { 0x01, 0x42, 0x03, 0x04, 0x05 });
client.put(null, key, bin);
get(key);
count(key);
lscan(key);
rscan(key);
getInt(key);
}
Aggregations