mirror of https://github.com/apache/druid.git
Restore backwards compatibility of Query. (#4185)
This commit is contained in:
parent
5b69f2eff2
commit
60caa641f3
|
@ -176,12 +176,6 @@ public abstract class BaseQuery<T extends Comparable<T>> implements Query<T>
|
|||
return withOverriddenContext(ImmutableMap.<String, Object>of(QUERYID, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> withDefaultTimeout(long defaultTimeout)
|
||||
{
|
||||
return withOverriddenContext(ImmutableMap.of(QueryContexts.DEFAULT_TIMEOUT_KEY, defaultTimeout));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,4 @@ public interface Query<T>
|
|||
String getId();
|
||||
|
||||
Query<T> withDataSource(DataSource dataSource);
|
||||
|
||||
Query<T> withDefaultTimeout(long defaultTimeout);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package io.druid.query;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.druid.java.util.common.ISE;
|
||||
|
||||
public class QueryContexts
|
||||
|
@ -114,6 +115,11 @@ public class QueryContexts
|
|||
return timeout;
|
||||
}
|
||||
|
||||
public static <T> Query<T> withDefaultTimeout(Query<T> query, long defaultTimeout)
|
||||
{
|
||||
return query.withOverriddenContext(ImmutableMap.of(QueryContexts.DEFAULT_TIMEOUT_KEY, defaultTimeout));
|
||||
}
|
||||
|
||||
static <T> long getDefaultTimeout(Query<T> query)
|
||||
{
|
||||
final long defaultTimeout = parseLong(query, DEFAULT_TIMEOUT_KEY, DEFAULT_TIMEOUT_MILLIS);
|
||||
|
|
|
@ -106,7 +106,7 @@ public class QueryContextsTest
|
|||
);
|
||||
Assert.assertEquals(300_000, QueryContexts.getTimeout(query));
|
||||
|
||||
query = query.withDefaultTimeout(60_000);
|
||||
query = QueryContexts.withDefaultTimeout(query, 60_000);
|
||||
Assert.assertEquals(60_000, QueryContexts.getTimeout(query));
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class QueryContextsTest
|
|||
);
|
||||
Assert.assertEquals(1000, QueryContexts.getTimeout(query));
|
||||
|
||||
query = query.withDefaultTimeout(1_000_000);
|
||||
query = QueryContexts.withDefaultTimeout(query, 1_000_000);
|
||||
Assert.assertEquals(1000, QueryContexts.getTimeout(query));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import io.druid.java.util.common.guava.Yielders;
|
|||
import io.druid.query.DruidMetrics;
|
||||
import io.druid.query.GenericQueryMetricsFactory;
|
||||
import io.druid.query.Query;
|
||||
import io.druid.query.QueryContexts;
|
||||
import io.druid.query.QueryInterruptedException;
|
||||
import io.druid.query.QueryMetrics;
|
||||
import io.druid.query.QuerySegmentWalker;
|
||||
|
@ -190,7 +191,7 @@ public class QueryResource implements QueryCountStatsProvider
|
|||
queryId = UUID.randomUUID().toString();
|
||||
query = query.withId(queryId);
|
||||
}
|
||||
query = query.withDefaultTimeout(config.getDefaultQueryTimeout());
|
||||
query = QueryContexts.withDefaultTimeout(query, config.getDefaultQueryTimeout());
|
||||
|
||||
toolChest = warehouse.getToolChest(query);
|
||||
|
||||
|
|
Loading…
Reference in New Issue