Class QueryContext

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class QueryContext
    extends java.lang.Object
    implements java.lang.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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ID  
    • 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)  
      java.lang.Object getProperty​(java.lang.String name)
      Returns a property set anywhere in this context.
      com.yahoo.processing.execution.Execution.Trace getTrace()
      Returns the execution trace this delegates to
      void logValue​(java.lang.String key, java.lang.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.
      java.util.Iterator<com.yahoo.processing.execution.Execution.Trace.LogValue> logValueIterator()
      Returns the values to be written to the access log for this
      boolean render​(java.io.Writer writer)  
      void setProperty​(java.lang.String name, java.lang.Object value)
      Adds a property key-value to this context.
      java.lang.String toString()
      Returns a short string description of this (includes the first few messages only, and no newlines)
      void trace​(java.lang.Object message, int traceLevel)  
      void trace​(java.lang.String message, int traceLevel)
      Adds a context message to this context
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • QueryContext

        public QueryContext​(int ignored,
                            Query owner)
    • Method Detail

      • trace

        public void trace​(java.lang.String message,
                          int traceLevel)
        Adds a context message to this context
      • trace

        public void trace​(java.lang.Object message,
                          int traceLevel)
      • logValue

        public void logValue​(java.lang.String key,
                             java.lang.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 java.util.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​(java.lang.String name,
                                java.lang.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 java.lang.Object getProperty​(java.lang.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 java.lang.String toString()
        Returns a short string description of this (includes the first few messages only, and no newlines)
        Overrides:
        toString in class java.lang.Object
      • render

        public boolean render​(java.io.Writer writer)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getTrace

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

        public QueryContext clone()
        Overrides:
        clone in class java.lang.Object