Search in sources :

Example 6 with PartitionTracker

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

Example 7 with PartitionTracker

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

Example 8 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method scanAll.

// -------------------------------------------------------
// Scan Operations
// -------------------------------------------------------
/**
 * Read all records in specified namespace and set.  If the policy's
 * <code>concurrentNodes</code> is specified, each server node will be read in
 * parallel.  Otherwise, server nodes are read in series.
 * <p>
 * This call will block until the scan is complete - callbacks are made
 * within the scope of this call.
 *
 * @param policy				scan configuration parameters, pass in null for defaults
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param callback				read callback method - called with record data
 * @param binNames				optional bin to retrieve. All bins will be returned if not specified.
 * @throws AerospikeException	if scan fails
 */
public final void scanAll(ScanPolicy policy, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException {
    if (policy == null) {
        policy = scanPolicyDefault;
    }
    Node[] nodes = cluster.validateNodes();
    PartitionTracker tracker = new PartitionTracker(policy, nodes);
    ScanExecutor.scanPartitions(cluster, policy, namespace, setName, binNames, callback, tracker);
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker) Node(com.aerospike.client.cluster.Node) BatchNode(com.aerospike.client.command.BatchNode)

Example 9 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker in project aerospike-client-java by aerospike.

the class AerospikeClient method scanNode.

/**
 * Read all records in specified namespace and set for one node only.
 * <p>
 * This call will block until the scan is complete - callbacks are made
 * within the scope of this call.
 *
 * @param policy				scan configuration parameters, pass in null for defaults
 * @param node					server node
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param callback				read callback method - called with record data
 * @param binNames				optional bin to retrieve. All bins will be returned if not specified.
 * @throws AerospikeException	if scan fails
 */
public final void scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException {
    if (policy == null) {
        policy = scanPolicyDefault;
    }
    PartitionTracker tracker = new PartitionTracker(policy, node);
    ScanExecutor.scanPartitions(cluster, policy, namespace, setName, binNames, callback, tracker);
}
Also used : PartitionTracker(com.aerospike.client.query.PartitionTracker)

Example 10 with PartitionTracker

use of com.aerospike.client.query.PartitionTracker 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

PartitionTracker (com.aerospike.client.query.PartitionTracker)10 Node (com.aerospike.client.cluster.Node)8 BatchNode (com.aerospike.client.command.BatchNode)8 AsyncQueryPartitionExecutor (com.aerospike.client.async.AsyncQueryPartitionExecutor)5 QueryPartitionExecutor (com.aerospike.client.query.QueryPartitionExecutor)3 AsyncScanPartitionExecutor (com.aerospike.client.async.AsyncScanPartitionExecutor)2 QueryRecordExecutor (com.aerospike.client.query.QueryRecordExecutor)2 AsyncQueryExecutor (com.aerospike.client.async.AsyncQueryExecutor)1