use of com.aerospike.client.query.QueryPartitionExecutor in project aerospike-client-java by aerospike.
the class AerospikeClient method queryPartitions.
/**
* Execute query for specified partitions and return record iterator. The query executor puts
* records on a queue in separate threads. The calling thread concurrently pops records off
* the queue through the record iterator.
*
* @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 RecordSet queryPartitions(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException {
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);
QueryPartitionExecutor executor = new QueryPartitionExecutor(cluster, policy, statement, nodes.length, tracker);
return executor.getRecordSet();
} else {
throw new AerospikeException(ResultCode.PARAMETER_ERROR, "queryPartitions() not supported");
}
}
use of com.aerospike.client.query.QueryPartitionExecutor in project aerospike-client-java by aerospike.
the class AerospikeClient method queryNode.
/**
* Execute query on a single server node and return record iterator. The query executor puts
* records on a queue in a separate thread. The calling thread concurrently pops records off
* the queue through the record iterator.
*
* @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 node server node to execute query
* @return record iterator
* @throws AerospikeException if query fails
*/
public final RecordSet queryNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeException {
if (policy == null) {
policy = queryPolicyDefault;
}
// A scan will be performed if the secondary index filter is null.
if (statement.getFilter() == null) {
PartitionTracker tracker = new PartitionTracker(policy, node);
QueryPartitionExecutor executor = new QueryPartitionExecutor(cluster, policy, statement, 1, tracker);
return executor.getRecordSet();
} else {
QueryRecordExecutor executor = new QueryRecordExecutor(cluster, policy, statement, new Node[] { node });
executor.execute();
return executor.getRecordSet();
}
}
use of com.aerospike.client.query.QueryPartitionExecutor in project aerospike-client-java by aerospike.
the class AerospikeClient method query.
// --------------------------------------------------------
// Query functions
// --------------------------------------------------------
/**
* Execute query on all server nodes and return record iterator. The query executor puts
* records on a queue in separate threads. The calling thread concurrently pops records off
* the queue through the record iterator.
*
* @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.
* @return record iterator
* @throws AerospikeException if query fails
*/
public final RecordSet query(QueryPolicy policy, Statement statement) throws AerospikeException {
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);
QueryPartitionExecutor executor = new QueryPartitionExecutor(cluster, policy, statement, nodes.length, tracker);
return executor.getRecordSet();
} else {
QueryRecordExecutor executor = new QueryRecordExecutor(cluster, policy, statement, nodes);
executor.execute();
return executor.getRecordSet();
}
}
Aggregations