Search in sources :

Example 1 with QueryPartitionExecutor

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");
    }
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) QueryPartitionExecutor(com.aerospike.client.query.QueryPartitionExecutor)

Example 2 with QueryPartitionExecutor

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();
    }
}
Also used : QueryRecordExecutor(com.aerospike.client.query.QueryRecordExecutor) PartitionTracker(com.aerospike.client.query.PartitionTracker) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) QueryPartitionExecutor(com.aerospike.client.query.QueryPartitionExecutor)

Example 3 with QueryPartitionExecutor

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();
    }
}
Also used : QueryRecordExecutor(com.aerospike.client.query.QueryRecordExecutor) PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode) AsyncQueryPartitionExecutor(com.aerospike.client.async.AsyncQueryPartitionExecutor) QueryPartitionExecutor(com.aerospike.client.query.QueryPartitionExecutor)

Aggregations

AsyncQueryPartitionExecutor (com.aerospike.client.async.AsyncQueryPartitionExecutor)3 PartitionTracker (com.aerospike.client.query.PartitionTracker)3 QueryPartitionExecutor (com.aerospike.client.query.QueryPartitionExecutor)3 Node (com.aerospike.client.cluster.Node)2 BatchNode (com.aerospike.client.command.BatchNode)2 QueryRecordExecutor (com.aerospike.client.query.QueryRecordExecutor)2