Class QueryContext

  • All Implemented Interfaces:
    Cloneable

    public class QueryContext
    extends Object
    implements Cloneable
    A proxy to the Execution.trace() which exists for legacy reasons. Calls to this is forwarded to owningQuery.getModel().getExecution().trace().
    Author:
    Steinar Knutsen, bratseth
    • 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 property
        value - 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)
        Overrides:
        toString in class Object
      • getTrace

        public com.yahoo.processing.execution.Execution.Trace getTrace()
        Returns the execution trace this delegates to