Class Execution

java.lang.Object
com.yahoo.processing.execution.Execution
com.yahoo.search.searchchain.Execution

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.

Author:
bratseth
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static 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

    Constructors
    Constructor
    Description
    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 execution)
    Creates an execution from another.
    Creates an which executes nothing
    Execution(Searcher searcher, Execution.Context context)
    Creates an execution from a single searcher
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    Deprecated.
    use fill(Result, String)
    protected void
     
    protected void
    onInvoking(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor)
     
    protected void
    onReturning(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor, com.yahoo.processing.Response response)
     
    ping(Ping ping)
    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)
    search(Query query)
    Calls search on the next searcher in this chain.
    Returns the search chain registry to use with this execution.
     

    Methods inherited from class com.yahoo.processing.execution.Execution

    chain, createRoot, createRoot, environment, next, nextIndex, toString, trace

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Execution

      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.

    • Execution

      public Execution(Execution.Context context)
      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 execute
      context - 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

      public Execution(Searcher searcher, Execution.Context context)
      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 class com.yahoo.processing.execution.Execution
    • search

      public Result search(Query query)
      Calls search on the next searcher in this chain. If there is no next, an empty result is returned.
    • onInvoking

      protected void onInvoking(com.yahoo.processing.Request request, com.yahoo.processing.Processor processor)
      Overrides:
      onInvoking in class com.yahoo.processing.execution.Execution
    • 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 class com.yahoo.processing.execution.Execution
    • fillAttributes

      @Deprecated public void fillAttributes(Result result)
      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

      public void fill(Result result)
      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

      public void fill(Result result, String summaryClass)
      Calls fill on the next searcher in this chain. If there is no next, nothing is done.
    • ping

      public Pong ping(Ping 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 class com.yahoo.processing.execution.Execution
    • previousProcessor

      protected void previousProcessor()
      Overrides:
      previousProcessor in class com.yahoo.processing.execution.Execution
    • nextProcessor

      protected void nextProcessor()
      Overrides:
      nextProcessor in class com.yahoo.processing.execution.Execution
    • searchChainRegistry

      public SearchChainRegistry searchChainRegistry()
      Returns the search chain registry to use with this execution. This is a snapshot taken at creation of this execution if available.
    • context

      public 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.

      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

      public TimeTracker timer()
      Returns:
      the TimeTracker instance associated with this Execution