use of com.aerospike.client.Log.Level in project aerospike-client-java by aerospike.
the class Batch method batchReadHeaders.
/**
* Read record header data in one batch.
*/
private void batchReadHeaders(AerospikeClient client, Parameters params, String keyPrefix, int size) throws Exception {
// Batch gets into one call.
Key[] keys = new Key[size];
for (int i = 0; i < size; i++) {
keys[i] = new Key(params.namespace, params.set, keyPrefix + (i + 1));
}
Record[] records = client.getHeader(null, keys);
for (int i = 0; i < records.length; i++) {
Key key = keys[i];
Record record = records[i];
Level level = Level.ERROR;
int generation = 0;
int expiration = 0;
if (record != null && (record.generation > 0 || record.expiration > 0)) {
level = Level.INFO;
generation = record.generation;
expiration = record.expiration;
}
console.write(level, "Record: ns=%s set=%s key=%s generation=%d expiration=%d", key.namespace, key.setName, key.userKey, generation, expiration);
}
if (records.length != size) {
console.error("Record size mismatch. Expected %d. Received %d.", size, records.length);
}
}
use of com.aerospike.client.Log.Level in project aerospike-client-java by aerospike.
the class Batch method batchReads.
/**
* Read records in one batch.
*/
private void batchReads(AerospikeClient client, Parameters params, String keyPrefix, String binName, int size) throws Exception {
// Batch gets into one call.
Key[] keys = new Key[size];
for (int i = 0; i < size; i++) {
keys[i] = new Key(params.namespace, params.set, keyPrefix + (i + 1));
}
Record[] records = client.get(null, keys, binName);
for (int i = 0; i < records.length; i++) {
Key key = keys[i];
Record record = records[i];
Level level = Level.ERROR;
Object value = null;
if (record != null) {
level = Level.INFO;
value = record.getValue(binName);
}
console.write(level, "Record: ns=%s set=%s key=%s bin=%s value=%s", key.namespace, key.setName, key.userKey, binName, value);
}
if (records.length != size) {
console.error("Record size mismatch. Expected %d. Received %d.", size, records.length);
}
}