use of com.aerospike.client.query.PartitionFilter in project aerospike-client-java by aerospike.
the class AsyncScanPage method runScan.
private void runScan(AerospikeClient client, EventLoop eventLoop) {
int pageSize = 30;
console.info("Scan max " + pageSize + " records.");
ScanPolicy policy = new ScanPolicy();
policy.maxRecords = pageSize;
PartitionFilter filter = PartitionFilter.all();
RecordSequenceListener listener = new RecordSequenceListener() {
private int count = 0;
@Override
public void onRecord(Key key, Record record) throws AerospikeException {
count++;
}
@Override
public void onSuccess() {
console.info("Records returned: " + count);
notifyComplete();
}
@Override
public void onFailure(AerospikeException e) {
console.error("Scan failed: " + Util.getErrorMessage(e));
notifyComplete();
}
};
client.scanPartitions(eventLoop, listener, policy, filter, params.namespace, setName);
}
use of com.aerospike.client.query.PartitionFilter in project aerospike-client-java by aerospike.
the class ScanResume method runExample.
/**
* Terminate a scan and then resume scan later.
*/
@Override
public void runExample(AerospikeClient client, Parameters params) throws Exception {
String binName = "bin";
String setName = "resume";
writeRecords(client, params, setName, binName, 200);
// Serialize node scans so scan callback atomics are not necessary.
ScanPolicy policy = new ScanPolicy();
policy.concurrentNodes = false;
PartitionFilter filter = PartitionFilter.all();
recordCount = 0;
recordMax = 50;
console.info("Start scan terminate");
try {
client.scanPartitions(policy, filter, params.namespace, setName, this);
} catch (AerospikeException.ScanTerminated e) {
console.info("Scan terminated as expected");
}
console.info("Records returned: " + recordCount);
// PartitionFilter could be serialized at this point.
// Resume scan now.
recordCount = 0;
recordMax = 0;
console.info("Start scan resume");
client.scanPartitions(policy, filter, params.namespace, setName, this);
console.info("Records returned: " + recordCount);
}
use of com.aerospike.client.query.PartitionFilter in project aerospike-client-java by aerospike.
the class ScanPage method runExample.
/**
* Scan in pages.
*/
@Override
public void runExample(AerospikeClient client, Parameters params) throws Exception {
String binName = "bin";
String setName = "page";
writeRecords(client, params, setName, binName, 190);
recordCount = new AtomicInteger();
ScanPolicy policy = new ScanPolicy();
policy.maxRecords = 100;
PartitionFilter filter = PartitionFilter.all();
// Scan 3 pages of records.
for (int i = 0; i < 3 && !filter.isDone(); i++) {
recordCount.set(0);
console.info("Scan page: " + i);
client.scanPartitions(policy, filter, params.namespace, setName, this);
console.info("Records returned: " + recordCount.get());
}
}
Aggregations