public static final class Execution.Context extends Object
The Context class simply carries a set of objects which define the environment for the search. Important: All objects available through context need to be either truly immutable or support the freeze pattern.
If you are implementing a searcher where you need to create a new Context
instance to create an Execution, you should use the context from the
execution the searcher was invoked from. You can also copy
(Context.shallowCopy()) the incoming context if it is necessary to do
more. In other words, a minimal example would be:
new Execution(searchChain, execution.context())
Modifier and Type | Field and Description |
---|---|
private boolean |
breakdown
Whether the container was considered to be in a breakdown state when
this query started.
|
private boolean |
detailedDiagnostics
Whether the search should perform detailed diagnostics.
|
private IndexFacts |
indexFacts |
private com.yahoo.language.Linguistics |
linguistics
The current linguistics.
|
private Execution |
owner
Always set if this context belongs to an execution, never set if it does not.
|
private RendererRegistry |
rendererRegistry
The current template registry.
|
private SearchChainRegistry |
searchChainRegistry
The search chain registry current when this execution was created, or
when the registry was first accessed, or null if it was not set on
creation or has been accessed yet.
|
private SpecialTokenRegistry |
tokenRegistry
The current set of special tokens.
|
Constructor and Description |
---|
Context()
Create a context used to carry state into another context
|
Context(Execution owner)
Create a context which belongs to an execution
|
Context(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts,
SpecialTokenRegistry tokenRegistry,
RendererRegistry rendererRegistry,
com.yahoo.language.Linguistics linguistics)
Creates a context from arguments, all of which may be null, though
this can be risky.
|
Modifier and Type | Method and Description |
---|---|
(package private) Execution.Context |
copyIfChanged(Execution.Context previous)
This is used when building the Context stack.
|
private com.yahoo.processing.execution.Execution.Environment |
createChildEnvironment()
Creates a child environment if this has an owner, or a root environment otherwise
|
private com.yahoo.processing.execution.Execution.Trace |
createChildTrace()
Creates a child trace if this has an owner, or a root trace otherwise
|
static Execution.Context |
createContextStub()
Creates a context stub with no information.
|
static Execution.Context |
createContextStub(IndexFacts indexFacts)
Create a Context instance where only the index related settings are
initialized.
|
static Execution.Context |
createContextStub(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts)
Create a Context instance where only the search chain registry and index facts are
initialized.
|
static Execution.Context |
createContextStub(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts,
com.yahoo.language.Linguistics linguistics)
Create a Context instance where only the search chain registry, index facts and linguistics are
initialized.
|
boolean |
equals(Execution.Context other) |
boolean |
equals(Object other) |
(package private) void |
fill(Execution.Context other)
The brutal version of populateFrom().
|
boolean |
getBreakdown()
If too many queries time out, the search handler will assume the
system is in a breakdown state.
|
boolean |
getDetailedDiagnostics()
The container has some internal diagnostics mechanisms which may be
costly, and therefore not active by default.
|
IndexFacts |
getIndexFacts()
Returns information about the indexes specified by the search definitions
used in this system, or null if not know.
|
com.yahoo.language.Linguistics |
getLinguistics()
Returns the
Linguistics object assigned to this Context. |
SpecialTokenRegistry |
getTokenRegistry() |
int |
hashCode() |
void |
populateFrom(Execution.Context sourceContext)
Populate missing values in this from the given context.
|
RendererRegistry |
rendererRegistry()
Returns the template registry to use with this execution.
|
SearchChainRegistry |
searchChainRegistry()
Returns the search chain registry to use with this execution.
|
void |
setBreakdown(boolean breakdown) |
void |
setDetailedDiagnostics(boolean breakdown) |
void |
setIndexFacts(IndexFacts indexFacts)
Use this to override index settings for the searchers below
a given searcher, the easiest way to do this is to wrap the incoming
IndexFacts instance in a subclass.
|
void |
setLinguistics(com.yahoo.language.Linguistics linguistics) |
void |
setTokenRegistry(SpecialTokenRegistry tokenRegistry)
Wrapping the incoming special token registry and then setting the
wrapper as the token registry, can be used for changing the set of
special tokens used by succeeding searchers.
|
Execution.Context |
shallowCopy()
Standard shallow copy, the new instance will carry the same
references as this.
|
private boolean detailedDiagnostics
private boolean breakdown
private SearchChainRegistry searchChainRegistry
private IndexFacts indexFacts
private SpecialTokenRegistry tokenRegistry
private RendererRegistry rendererRegistry
private com.yahoo.language.Linguistics linguistics
private final Execution owner
Context()
Context(Execution owner)
public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts, SpecialTokenRegistry tokenRegistry, RendererRegistry rendererRegistry, com.yahoo.language.Linguistics linguistics)
This context is never attached to an execution but is used to carry state into another context.
public static Execution.Context createContextStub()
public static Execution.Context createContextStub(IndexFacts indexFacts)
public static Execution.Context createContextStub(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts)
public static Execution.Context createContextStub(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts, com.yahoo.language.Linguistics linguistics)
public void populateFrom(Execution.Context sourceContext)
sourceContext
- the context from which to get the parametersvoid fill(Execution.Context other)
other
- a Context instance this will copy all state frompublic boolean equals(Execution.Context other)
public Execution.Context shallowCopy()
Execution.Context copyIfChanged(Execution.Context previous)
previous
- another Context instance to compare withpublic IndexFacts getIndexFacts()
public void setIndexFacts(IndexFacts indexFacts)
indexFacts
- an instance to override the following searcher's view of
the indexes.public SearchChainRegistry searchChainRegistry()
public RendererRegistry rendererRegistry()
public SpecialTokenRegistry getTokenRegistry()
public void setTokenRegistry(SpecialTokenRegistry tokenRegistry)
tokenRegistry
- a new registry for overriding behavior of following searcherspublic void setDetailedDiagnostics(boolean breakdown)
public boolean getDetailedDiagnostics()
public boolean getBreakdown()
public void setBreakdown(boolean breakdown)
public com.yahoo.language.Linguistics getLinguistics()
Linguistics
object assigned to this Context. This object provides access to all the
linguistic-related APIs, and comes pre-configured with the Execution given.public void setLinguistics(com.yahoo.language.Linguistics linguistics)
private com.yahoo.processing.execution.Execution.Trace createChildTrace()
private com.yahoo.processing.execution.Execution.Environment createChildEnvironment()
Copyright © 2018. All rights reserved.