use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestBitExp method callModify.
@Test
public void callModify() {
Key key = new Key(args.namespace, args.set, 5001);
client.delete(null, key);
Bin bin = new Bin(binA, new byte[] { 0x01, 0x42, 0x03, 0x04, 0x05 });
client.put(null, key, bin);
resize(key);
insert(key);
remove(key);
set(key);
or(key);
xor(key);
and(key);
not(key);
lshift(key);
rshift(key);
add(key);
subtract(key);
setInt(key);
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestUDF method writeUsingUdf.
@Test
public void writeUsingUdf() {
Key key = new Key(args.namespace, args.set, "udfkey1");
Bin bin = new Bin(args.getBinName("udfbin1"), "string value");
client.execute(null, key, "record_example", "writeBin", Value.get(bin.name), bin.value);
Record record = client.get(null, key, bin.name);
assertBinEqual(key, record, bin);
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestQueryFilter method writeRecord.
private static void writeRecord(String userKey, String name, String password) {
Key key = new Key(args.namespace, args.set, userKey);
Bin bin1 = new Bin("name", name);
Bin bin2 = new Bin("password", password);
client.put(null, key, bin1, bin2);
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestQueryExecute method queryExecuteOperate.
@Test
public void queryExecuteOperate() {
int begin = 3;
int end = 9;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setFilter(Filter.range(binName1, begin, end));
Bin bin = new Bin("foo", "bar");
ExecuteTask task = client.execute(null, stmt, Operation.put(bin));
task.waitTillComplete(3000, 3000);
String expected = bin.value.toString();
stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setFilter(Filter.range(binName1, begin, end));
RecordSet rs = client.query(null, stmt);
try {
int count = 0;
while (rs.next()) {
Record record = rs.getRecord();
String value = record.getString(bin.name);
if (value == null) {
fail("Bin " + bin.name + " not found");
}
if (!value.equals(expected)) {
fail("Data mismatch. Expected " + expected + ". Received " + value);
}
count++;
}
assertEquals(end - begin + 1, count);
} finally {
rs.close();
}
}
use of com.aerospike.client.Bin in project aerospike-client-java by aerospike.
the class TestQueryFilterExp method prepare.
@BeforeClass
public static void prepare() {
Policy policy = new Policy();
// Do not timeout on index create.
policy.socketTimeout = 0;
try {
IndexTask task = client.createIndex(policy, args.namespace, setName, indexName, binName, IndexType.NUMERIC);
task.waitTillComplete();
} catch (AerospikeException ae) {
if (ae.getResultCode() != ResultCode.INDEX_ALREADY_EXISTS) {
throw ae;
}
}
// Write records with string keys
for (int i = 1; i <= size; i++) {
Key key = new Key(args.namespace, setName, keyPrefix + i);
List<Integer> list = null;
Map<String, String> map = null;
if (i == 1) {
list = new ArrayList<Integer>(5);
list.add(1);
list.add(2);
list.add(4);
list.add(9);
list.add(20);
// map will be null, which means mapbin will not exist in this record.
} else if (i == 2) {
list = new ArrayList<Integer>(3);
list.add(5);
list.add(9);
list.add(100);
// map will be null, which means mapbin will not exist in this record.
} else if (i == 3) {
map = new HashMap<String, String>();
map.put("A", "AAA");
map.put("B", "BBB");
map.put("C", "BBB");
// list will be null, which means listbin will not exist in this record.
} else {
list = new ArrayList<Integer>(0);
map = new HashMap<String, String>(0);
}
client.put(null, key, new Bin(binName, i), new Bin("bin2", i), new Bin("listbin", list), new Bin("mapbin", map));
}
}
Aggregations