Class Execution
An execution of a search chain. This keeps track of the call state for an execution (in the calling thread) of the searchers of a search chain.
To execute a search chain, simply do
Result result = new Execution(mySearchChain, execution.context()).search(query)
See also AsyncExecution
, which performs an execution in a separate thread than the caller.
Execution instances should not be reused for multiple separate executions.
- Author:
- bratseth
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The execution context is the search chain's current view of the indexes, search chain registrys, etc.Nested classes/interfaces inherited from class com.yahoo.processing.execution.Execution
com.yahoo.processing.execution.Execution.Environment<COMPONENT extends com.yahoo.processing.Processor>, com.yahoo.processing.execution.Execution.Trace
-
Constructor Summary
ConstructorDescriptionExecution
(com.yahoo.component.chain.Chain<? extends Searcher> searchChain, Execution.Context context) The usually best way of creating a new execution for a search chain.Creates an execution from another.Execution
(Execution.Context context) Creates an which executes nothingExecution
(Searcher searcher, Execution.Context context) Creates an execution from a single searcher -
Method Summary
Modifier and TypeMethodDescriptioncontext()
Returns the context of this execution, which contains various objects which are looked up through a memory barrier at the point this is created and which is guaranteed to be frozen during the execution of this query.protected com.yahoo.processing.Response
defaultResponse
(com.yahoo.processing.Request request) The default response returned from this kind of execution when there are not further processors - an empty Resultvoid
Fill hit properties with data using the default summary class, possibly overridden with the 'summary' request parameter.void
Calls fill on the next searcher in this chain.void
fillAttributes
(Result result) Deprecated.use fill(Result, String)protected void
protected void
onReturning
(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor, com.yahoo.processing.Response response) Calls ping on the next search in this chain.protected void
final com.yahoo.processing.Response
process
(com.yahoo.processing.Request request) Does return search(((Query)request)Calls search on the next searcher in this chain.Returns the search chain registry to use with this execution.timer()
Methods inherited from class com.yahoo.processing.execution.Execution
chain, createRoot, createRoot, environment, next, nextIndex, onInvoking, toString, trace
-
Constructor Details
-
Execution
Creates an execution from another. This execution will start at the current next searcher in the given execution, rather than at the start.
The relevant state of the given execution is copied before this method returns - the argument execution can then be reused for any other purpose.
-
Execution
Creates an which executes nothing -
Execution
public Execution(com.yahoo.component.chain.Chain<? extends Searcher> searchChain, Execution.Context context) The usually best way of creating a new execution for a search chain. This is the one suitable for a production environment. It is safe to use the incoming context from the search directly:public Result search(Query query, Execution execution) { SearchChain searchChain = fancyChainSelectionRoutine(query); if (searchChain != null) { return new Execution(searchChain, execution.context()); else { return execution.search(query); } }
- Parameters:
searchChain
- the search chain to executecontext
- the execution context from which this is populated (the given context is not changed nor retained by this), or null to not populate from a context- Throws:
IllegalArgumentException
- if searchChain is null
-
Execution
Creates an execution from a single searcher
-
-
Method Details
-
process
public final com.yahoo.processing.Response process(com.yahoo.processing.Request request) Does return search(((Query)request)- Overrides:
process
in classcom.yahoo.processing.execution.Execution
-
search
Calls search on the next searcher in this chain. If there is no next, an empty result is returned. -
defaultResponse
protected com.yahoo.processing.Response defaultResponse(com.yahoo.processing.Request request) The default response returned from this kind of execution when there are not further processors - an empty Result- Overrides:
defaultResponse
in classcom.yahoo.processing.execution.Execution
-
fillAttributes
Deprecated.use fill(Result, String)Fill hit properties with values from some in-memory attributes. Not all attributes are included, and *which* attributes are subject to change depending on what Vespa needs internally. Applications should prefer to define their own summary class with only the in-memory attributes they need, and call fill(result, "foo") with the name of their own summary class instead of "foo".- Parameters:
result
- the result to fill
-
fill
Fill hit properties with data using the default summary class, possibly overridden with the 'summary' request parameter.Fill must be called before any property (accessed by getProperty/getField) is accessed on the hit. It should be done as late as possible for performance reasons.
Calling this on already filled results has no cost.
- Parameters:
result
- the result to fill
-
fill
Calls fill on the next searcher in this chain. If there is no next, nothing is done. -
ping
Calls ping on the next search in this chain. If there is no next, a Pong is created and returned. -
onReturning
protected void onReturning(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor, com.yahoo.processing.Response response) - Overrides:
onReturning
in classcom.yahoo.processing.execution.Execution
-
previousProcessor
protected void previousProcessor()- Overrides:
previousProcessor
in classcom.yahoo.processing.execution.Execution
-
nextProcessor
protected void nextProcessor()- Overrides:
nextProcessor
in classcom.yahoo.processing.execution.Execution
-
searchChainRegistry
Returns the search chain registry to use with this execution. This is a snapshot taken at creation of this execution if available. -
context
Returns the context of this execution, which contains various objects which are looked up through a memory barrier at the point this is created and which is guaranteed to be frozen during the execution of this query.Note that the context itself can be changed. Such changes will be visible to downstream searchers, but not after returning from the modifying searcher. In other words, a change in the context will not be visible to the preceding searchers when the result is returned from the searcher which modified the context.
-
timer
- Returns:
- the TimeTracker instance associated with this Execution
-