use of com.aerospike.client.async.AsyncQueryPartitionExecutor in project aerospike-client-java by aerospike.
the class AerospikeClient method queryPartitions.
/**
* Asynchronously execute query for specified partitions.
* This method registers the command with an event loop and returns.
* The event loop thread will process the command and send the results to the listener.
* <p>
* Each record result is returned in separate onRecord() calls.
*
* @param eventLoop event loop that will process the command. If NULL, the event
* loop will be chosen by round-robin.
* @param listener where to send results
* @param policy query configuration parameters, pass in null for defaults
* @param statement query filter. Statement instance is not suitable for
* reuse since it's modified in this method.
* @param partitionFilter filter on a subset of data partitions
* @throws AerospikeException if query fails
*/
public final void queryPartitions(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException {
if (eventLoop == null) {
eventLoop = cluster.eventLoops.next();
}
if (policy == null) {
policy = queryPolicyDefault;
}
Node[] nodes = cluster.validateNodes();
// A scan will be performed if the secondary index filter is null.
if (statement.getFilter() == null) {
PartitionTracker tracker = new PartitionTracker(policy, nodes, partitionFilter);
new AsyncQueryPartitionExecutor(eventLoop, listener, cluster, policy, statement, tracker);
} else {
throw new AerospikeException(ResultCode.PARAMETER_ERROR, "queryPartitions() not supported");
}
}
use of com.aerospike.client.async.AsyncQueryPartitionExecutor in project aerospike-client-java by aerospike.
the class AerospikeClient method query.
/**
* Asynchronously execute query on all server nodes.
* This method registers the command with an event loop and returns.
* The event loop thread will process the command and send the results to the listener.
* <p>
* Each record result is returned in separate onRecord() calls.
*
* @param eventLoop event loop that will process the command. If NULL, the event
* loop will be chosen by round-robin.
* @param listener where to send results
* @param policy query configuration parameters, pass in null for defaults
* @param statement query filter. Statement instance is not suitable for
* reuse since it's modified in this method.
* @throws AerospikeException if event loop registration fails
*/
public final void query(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement) throws AerospikeException {
if (eventLoop == null) {
eventLoop = cluster.eventLoops.next();
}
if (policy == null) {
policy = queryPolicyDefault;
}
Node[] nodes = cluster.validateNodes();
// A scan will be performed if the secondary index filter is null.
if (statement.getFilter() == null) {
PartitionTracker tracker = new PartitionTracker(policy, nodes);
new AsyncQueryPartitionExecutor(eventLoop, listener, cluster, policy, statement, tracker);
} else {
new AsyncQueryExecutor(eventLoop, listener, cluster, policy, statement, nodes);
}
}
Aggregations