Package com.yahoo.search.query.context
Class QueryContext
- java.lang.Object
-
- com.yahoo.search.query.context.QueryContext
-
-
Constructor Summary
Constructors Constructor Description QueryContext(int ignored, Query owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryContext
clone()
QueryContext
cloneFor(Query cloneOwner)
Object
getProperty(String name)
Returns a property set anywhere in this context.com.yahoo.processing.execution.Execution.Trace
getTrace()
Returns the execution trace this delegates tovoid
logValue(String key, Object value)
Adds a key-value which will be logged to the access log for this query (by doing toString() on the value).Iterator<com.yahoo.processing.execution.Execution.Trace.LogValue>
logValueIterator()
Returns the values to be written to the access log for thisboolean
render(Writer writer)
void
setProperty(String name, Object value)
Adds a property key-value to this context.String
toString()
Returns a short string description of this (includes the first few messages only, and no newlines)void
trace(Object message, int traceLevel)
void
trace(String message, int traceLevel)
Adds a context message to this context
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QueryContext
public QueryContext(int ignored, Query owner)
-
-
Method Detail
-
trace
public void trace(String message, int traceLevel)
Adds a context message to this context
-
trace
public void trace(Object message, int traceLevel)
-
logValue
public void logValue(String key, Object value)
Adds a key-value which will be logged to the access log for this query (by doing toString() on the value). Multiple values may be set to the same key. A value cannot be removed once set.
-
logValueIterator
public Iterator<com.yahoo.processing.execution.Execution.Trace.LogValue> logValueIterator()
Returns the values to be written to the access log for this
-
setProperty
public void setProperty(String name, Object value)
Adds a property key-value to this context. If the same name is set multiple times, the behavior is thus:- Within a single context (thread/query clone), the last value set is used
- Across multiple traces, the last value from the last deepest nested thread/clone is used. In the case of multiple threads writing the value concurrently to their clone, it is of course undefined which one will be used.
- Parameters:
name
- the name of the propertyvalue
- the value of the property, or null to set this property to null
-
getProperty
public Object getProperty(String name)
Returns a property set anywhere in this context. Note that even though this call is itself "thread robust", the object values returned may in some scenarios not be written behind a synchronization barrier, so when accessing objects which are not inherently thread safe, synchronization should be considered.Note that this method have a time complexity which is proportional to the number of cloned/created queries times the average number of properties in each.
-
toString
public String toString()
Returns a short string description of this (includes the first few messages only, and no newlines)
-
render
public boolean render(Writer writer) throws IOException
- Throws:
IOException
-
cloneFor
public QueryContext cloneFor(Query cloneOwner)
-
getTrace
public com.yahoo.processing.execution.Execution.Trace getTrace()
Returns the execution trace this delegates to
-
clone
public QueryContext clone()
-
-