public class Execution
extends com.yahoo.processing.execution.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.
Modifier and Type | Class and Description |
---|---|
static class |
Execution.Context
The execution context is the search chain's current view of the indexes,
search chain registrys, etc.
|
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTEPREFETCH |
private Execution.Context |
context
A searcher's view of state external to the search chain.
|
private Execution.Context[] |
contextCache
Array for hiding context changes done in search by searcher following
another.
|
private int |
entryIndex
The index of where in the chain this Execution has its initial entry point.
|
private static Logger |
log |
private TimeTracker |
timer
Time spent in each state of filling, searching or pinging.
|
Modifier | Constructor and Description |
---|---|
private |
Execution(com.yahoo.component.chain.Chain<? extends com.yahoo.processing.Processor> searchChain,
Execution.Context context,
int searcherIndex)
Creates a new execution for a search chain or a single searcher.
|
|
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.
|
|
Execution(Execution.Context context)
Creates an which executes nothing
|
|
Execution(Execution execution)
Creates an execution from another.
|
|
Execution(Searcher searcher,
Execution.Context context)
Creates an execution from a single searcher
|
Modifier and Type | Method and Description |
---|---|
Execution.Context |
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.
|
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
|
void |
fill(Result result)
Fill hit properties with data using the default summary
class, possibly overridden with the 'summary' request parameter.
|
void |
fill(Result result,
String summaryClass)
Calls fill on the next searcher in this chain.
|
void |
fillAttributes(Result result)
Fill hit properties with values from all in-memory attributes.
|
private Pong |
invokePing(Ping ping,
Searcher next) |
protected void |
nextProcessor() |
protected void |
onInvoking(com.yahoo.processing.Request request,
com.yahoo.processing.Processor processor) |
private void |
onInvokingFill(Searcher searcher,
Result result,
String summaryClass) |
protected void |
onReturning(com.yahoo.processing.Request request,
com.yahoo.processing.Processor processor,
com.yahoo.processing.Response response) |
private void |
onReturningFill(Searcher searcher,
Result result,
String summaryClass) |
Pong |
ping(Ping ping)
Calls ping on the next search in this chain.
|
private void |
popContext() |
protected void |
previousProcessor() |
com.yahoo.processing.Response |
process(com.yahoo.processing.Request request)
Does return search(((Query)request)
|
private void |
pushContext() |
Result |
search(Query query)
Calls search on the next searcher in this chain.
|
SearchChainRegistry |
searchChainRegistry()
Returns the search chain registry to use with this execution.
|
TimeTracker |
timer() |
public static final String ATTRIBUTEPREFETCH
private final int entryIndex
private final TimeTracker timer
private final Execution.Context context
private final Execution.Context[] contextCache
private static final Logger log
public Execution(Execution 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.
public Execution(Execution.Context context)
public Execution(com.yahoo.component.chain.Chain<? extends Searcher> searchChain, Execution.Context context)
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); } }
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 contextIllegalArgumentException
- if searchChain is nullpublic Execution(Searcher searcher, Execution.Context context)
private Execution(com.yahoo.component.chain.Chain<? extends com.yahoo.processing.Processor> searchChain, Execution.Context context, int searcherIndex)
searchChain
- the search chain to execute, must be null if searcher is setcontext
- execution context for the searchsearcherIndex
- index of the first searcher to invoke, see
Execution(Execution)IllegalArgumentException
- if searchChain is nullpublic final com.yahoo.processing.Response process(com.yahoo.processing.Request request)
process
in class com.yahoo.processing.execution.Execution
public Result search(Query query)
protected void onInvoking(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor)
onInvoking
in class com.yahoo.processing.execution.Execution
protected com.yahoo.processing.Response defaultResponse(com.yahoo.processing.Request request)
defaultResponse
in class com.yahoo.processing.execution.Execution
public void fillAttributes(Result result)
fill(com.yahoo.search.Result)
to get that data for filtering.
Calling this on already filled results has no cost.
result
- the result to fillpublic void fill(Result result)
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.
result
- the result to fillpublic void fill(Result result, String summaryClass)
public Pong ping(Ping ping)
protected void onReturning(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor, com.yahoo.processing.Response response)
onReturning
in class com.yahoo.processing.execution.Execution
protected void previousProcessor()
previousProcessor
in class com.yahoo.processing.execution.Execution
protected void nextProcessor()
nextProcessor
in class com.yahoo.processing.execution.Execution
private void popContext()
private void pushContext()
public SearchChainRegistry searchChainRegistry()
public Execution.Context context()
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.
public TimeTracker timer()
Copyright © 2018. All rights reserved.