use of com.aerospike.client.task.ExecuteTask in project aerospike-client-java by aerospike.
the class QueryExecute method runQueryExecute.
private void runQueryExecute(AerospikeClient client, Parameters params, String indexName, String binName1, String binName2) throws Exception {
int begin = 3;
int end = 9;
console.info("For ns=%s set=%s index=%s bin=%s >= %s <= %s", params.namespace, params.set, indexName, binName1, begin, end);
console.info("Even integers: add 100 to existing " + binName1);
console.info("Multiple of 5: delete " + binName2 + " bin");
console.info("Multiple of 9: delete record");
Statement stmt = new Statement();
stmt.setNamespace(params.namespace);
stmt.setSetName(params.set);
stmt.setFilter(Filter.range(binName1, begin, end));
ExecuteTask task = client.execute(params.writePolicy, stmt, "record_example", "processRecord", Value.get(binName1), Value.get(binName2), Value.get(100));
task.waitTillComplete();
}
use of com.aerospike.client.task.ExecuteTask in project aerospike-client-java by aerospike.
the class TestQueryExecute method queryExecute.
@Test
public void queryExecute() {
int begin = 3;
int end = 9;
Statement stmt = new Statement();
stmt.setNamespace(args.namespace);
stmt.setSetName(args.set);
stmt.setFilter(Filter.range(binName1, begin, end));
ExecuteTask task = client.execute(null, stmt, "record_example", "processRecord", Value.get(binName1), Value.get(binName2), Value.get(100));
task.waitTillComplete();
validateRecords();
}
use of com.aerospike.client.task.ExecuteTask in project aerospike-client-java by aerospike.
the class AerospikeClient method execute.
// ----------------------------------------------------------
// Query/Execute UDF
// ----------------------------------------------------------
/**
* Apply user defined function on records that match the statement filter.
* Records are not returned to the client.
* This asynchronous server call will return before command is complete.
* The user can optionally wait for command completion by using the returned
* ExecuteTask instance.
*
* @param policy write configuration parameters, pass in null for defaults
* @param statement record filter
* @param packageName server package where user defined function resides
* @param functionName function name
* @param functionArgs to pass to function name, if any
* @throws AerospikeException if command fails
*/
public final ExecuteTask execute(WritePolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeException {
if (policy == null) {
policy = writePolicyDefault;
}
statement.setAggregateFunction(packageName, functionName, functionArgs);
statement.prepare(false);
Node[] nodes = cluster.getNodes();
if (nodes.length == 0) {
throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty.");
}
Executor executor = new Executor(cluster, policy, nodes.length);
for (Node node : nodes) {
ServerCommand command = new ServerCommand(policy, statement);
executor.addCommand(node, command);
}
executor.execute(nodes.length);
return new ExecuteTask(cluster, policy, statement);
}
Aggregations