public class AsyncExecution extends Object
AsyncExecution is implemented as an asynchronous wrapper around Execution that returns Future.
This is used in the following wayExecution execution = new Execution(searchChain, context); AsyncExecution asyncExecution = new AsyncExecution(execution); Future<Result> future = asyncExecution.search(query) try { result = future.get(timeout, TimeUnit.milliseconds); } catch(TimeoutException e) { // Handle timeout }
Note that the query is not a thread safe object and cannot be shared between multiple concurrent executions - a clone() must be made, or a new query created for each AsyncExecution instance.
Execution
Constructor and Description |
---|
AsyncExecution(com.yahoo.component.chain.Chain<? extends Searcher> chain,
Execution.Context context)
Creates an async execution.
|
AsyncExecution(com.yahoo.component.chain.Chain<? extends Searcher> chain,
Execution execution)
Creates an async execution.
|
AsyncExecution(Execution execution)
Creates an async execution from an existing execution.
|
Modifier and Type | Method and Description |
---|---|
FutureResult |
fill(Result result,
String summaryClass)
The future of this functions returns the original Result
|
FutureResult |
search(Query query)
Does an async search, note that the query argument cannot simultaneously
be used to execute any other searches, a clone() must be made of the
query for each async execution if the same query is to be used in more
than one.
|
FutureResult |
searchAndFill(Query query) |
static List<Result> |
waitForAll(Collection<FutureResult> tasks,
long timeoutMs) |
public AsyncExecution(com.yahoo.component.chain.Chain<? extends Searcher> chain, Execution execution)
chain
- the chain to executeexecution
- the execution holding the context of thispublic AsyncExecution(com.yahoo.component.chain.Chain<? extends Searcher> chain, Execution.Context context)
chain
- the chain to executecontext
- the the context of thispublic AsyncExecution(Execution execution)
Creates an async execution from an existing execution. This async execution will execute the chain from the given execution, starting from the next searcher in that chain. This is handy to execute multiple queries to the rest of the chain in parallel. If the Execution is freshly instantiated, the search will obviously start from the first searcher.
The state of the given execution is read on construction of this and not used later - the argument execution can be reused for other purposes.
execution
- the execution from which the state of this is createdExecution.Execution(Chain, com.yahoo.search.searchchain.Execution.Context)
,
AsyncExecution(Chain, Execution)
public FutureResult search(Query query)
Execution
public FutureResult searchAndFill(Query query)
public FutureResult fill(Result result, String summaryClass)
Execution
public static List<Result> waitForAll(Collection<FutureResult> tasks, long timeoutMs)
Copyright © 2018. All rights reserved.