Class QueryPlus<T>

java.lang.Object
org.apache.druid.query.QueryPlus<T>

public final class QueryPlus<T> extends Object
An immutable composite object of Query + extra stuff needed in QueryRunners.
  • Method Details

    • wrap

      public static <T> QueryPlus<T> wrap(Query<T> query)
      Returns the minimum bare QueryPlus object with the given query. getQueryMetrics() of the QueryPlus object, returned from this factory method, returns null.
    • getQuery

      public Query<T> getQuery()
    • unwrapQuery

      public <C extends Query<T>> C unwrapQuery(Class<C> clazz)
    • getQueryMetrics

      @Nullable public QueryMetrics<?> getQueryMetrics()
    • withIdentity

      public QueryPlus<T> withIdentity(String identity)
      Returns the same QueryPlus object with the identity replaced. This new identity will affect future calls to withoutQueryMetrics() but will not affect any currently-existing queryMetrics.
    • withQueryMetrics

      public QueryPlus<T> withQueryMetrics(QueryToolChest<T,? extends Query<T>> queryToolChest)
      Returns the same QueryPlus object, if it already has QueryMetrics (getQueryMetrics() returns not null), or returns a new QueryPlus object with Query from this QueryPlus and QueryMetrics created using the given QueryToolChest, via QueryToolChest.makeMetrics(Query) method. By convention, callers of withQueryMetrics() must also call .getQueryMetrics().emit() on the returned QueryMetrics object, regardless if this object is the same as the object on which .withQueryMetrics() was initially called (i. e. it already had non-null QueryMetrics), or if it is a new QueryPlus object. See MetricsEmittingQueryRunner for example.
    • withoutThreadUnsafeState

      public QueryPlus<T> withoutThreadUnsafeState()
      Returns a QueryPlus object without the components which are unsafe for concurrent use from multiple threads, therefore couldn't be passed down in concurrent or async QueryRunners. Currently the only unsafe component is QueryMetrics, i. e. withoutThreadUnsafeState() call is equivalent to withoutQueryMetrics().
    • withMaxQueuedBytes

      public QueryPlus<T> withMaxQueuedBytes(long maxQueuedBytes)
      Equivalent of withQuery(getQuery().withOverriddenContext(ImmutableMap.of(MAX_QUEUED_BYTES_KEY, maxQueuedBytes))).
    • withQuery

      public <U> QueryPlus<U> withQuery(Query<U> replacementQuery)
      Returns a QueryPlus object with QueryMetrics from this QueryPlus object, and the provided Query.
    • run

      public Sequence<T> run(QuerySegmentWalker walker, ResponseContext context)
    • optimizeForSegment

      public QueryPlus<T> optimizeForSegment(PerSegmentQueryOptimizationContext optimizationContext)