public static <T> Query<T> withDefaultTimeout(Query<T> query, long defaultTimeout) { return query.withOverriddenContext(ImmutableMap.of(QueryContexts.DEFAULT_TIMEOUT_KEY, defaultTimeout)); }
public static <T> Query<T> withTimeout(Query<T> query, long timeout) { return query.withOverriddenContext(ImmutableMap.of(TIMEOUT_KEY, timeout)); }
private static Query<?> readQuery( final HttpServletRequest req, final InputStream in, final ResponseContext context ) throws IOException { Query baseQuery = context.getObjectMapper().readValue(in, Query.class); String prevEtag = getPreviousEtag(req); if (prevEtag != null) { baseQuery = baseQuery.withOverriddenContext( ImmutableMap.of(HEADER_IF_NONE_MATCH, prevEtag) ); } return baseQuery; }
public static <T> Query<T> withMaxScatterGatherBytes(Query<T> query, long maxScatterGatherBytesLimit) { Object obj = query.getContextValue(MAX_SCATTER_GATHER_BYTES_KEY); if (obj == null) { return query.withOverriddenContext(ImmutableMap.of(MAX_SCATTER_GATHER_BYTES_KEY, maxScatterGatherBytesLimit)); } else { long curr = ((Number) obj).longValue(); if (curr > maxScatterGatherBytesLimit) { throw new IAE( "configured [%s = %s] is more than enforced limit of [%s].", MAX_SCATTER_GATHER_BYTES_KEY, curr, maxScatterGatherBytesLimit ); } else { return query; } } }
public <T, QueryType extends Query<T>> QueryType withTimeoutAndMaxScatterGatherBytes( final QueryType query, ServerConfig serverConfig ) { Query<T> newQuery = QueryContexts.verifyMaxQueryTimeout( QueryContexts.withMaxScatterGatherBytes( QueryContexts.withDefaultTimeout( (Query) query, Math.min(serverConfig.getDefaultQueryTimeout(), serverConfig.getMaxQueryTimeout()) ), serverConfig.getMaxScatterGatherBytes() ), serverConfig.getMaxQueryTimeout() ); return (QueryType) newQuery.withOverriddenContext(ImmutableMap.of(DirectDruidClient.QUERY_FAIL_TIME, this.startTimeMillis + QueryContexts.getTimeout(newQuery))); } }
subquery = (GroupByQuery) ((QueryDataSource) dataSource).getQuery().withOverriddenContext(subqueryContext);
SpecificQueryRunnable(final QueryPlus<T> queryPlus, final Map<String, Object> responseContext) { this.queryPlus = queryPlus; this.responseContext = responseContext; this.query = queryPlus.getQuery(); this.toolChest = warehouse.getToolChest(query); this.strategy = toolChest.getCacheStrategy(query); this.useCache = CacheUtil.useCacheOnBrokers(query, strategy, cacheConfig); this.populateCache = CacheUtil.populateCacheOnBrokers(query, strategy, cacheConfig); this.isBySegment = QueryContexts.isBySegment(query); // Note that enabling this leads to putting uncovered intervals information in the response headers // and might blow up in some cases https://github.com/druid-io/druid/issues/2108 this.uncoveredIntervalsLimit = QueryContexts.getUncoveredIntervalsLimit(query); this.downstreamQuery = query.withOverriddenContext(makeDownstreamQueryContext()); }
final Query<T> rewrittenQuery = query.withOverriddenContext(contextBuilder.build());
queryToRun = query.withOverriddenContext(ImmutableMap.<String, Object>of("finalize", false)); metricManipulationFn = MetricManipulatorFns.finalizing();
queryToRun = query.withOverriddenContext(ImmutableMap.<String, Object>of("finalize", false)); metricManipulationFn = MetricManipulatorFns.finalizing();