public class DirectStatement extends AbstractStatement implements SqlLifecycleManager.Cancelable
execute() to execute the query. The caller must close
the returned Sequence.close() to report metrics, or AbstractStatement.closeQuietly()
otherwise.
The cancel() method may be called from any thread and cancels
the query.
All other methods are optional and are generally for introspection.
The class supports two threading models. In the simple case, the same thread creates this object and executes the query. In the split model, a request thread creates this object and plans the query. A separate response thread consumes results and performs any desired logging, etc. The object is transferred between threads, with no overlapping access.
As statement holds no resources and need not be called. Only the
Sequence returned from execute() need be closed.
Use this class for tests and JDBC execution. Use the HTTP variant,
HttpStatement for HTTP requests.
| Modifier and Type | Class and Description |
|---|---|
class |
DirectStatement.ResultSet
Represents the execution plan for a query with the ability to run
that plan (once).
|
| Modifier and Type | Field and Description |
|---|---|
protected PrepareResult |
prepareResult |
protected DirectStatement.ResultSet |
resultSet |
cancellationResourceActions, fullResourceActions, plannerContext, queryPlus, reporter, sqlToolbox| Constructor and Description |
|---|
DirectStatement(SqlToolbox lifecycleToolbox,
SqlQueryPlus sqlRequest) |
DirectStatement(SqlToolbox lifecycleToolbox,
SqlQueryPlus queryPlus,
String remoteAddress) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
void |
close()
Releases resources and emits logs and metrics as defined the
associated reporter.
|
void |
closeWithError(Throwable e)
Convenience method to close the statement and report an error
associated with the statement.
|
protected PlannerResult |
createPlan(DruidPlanner planner)
Plan the query, which also produces the sequence that runs
the query.
|
protected DirectStatement.ResultSet |
createResultSet(PlannerResult plannerResult)
Wrapper around result set creation for the sole purpose of tests which
inject failures.
|
Sequence<Object[]> |
execute()
Convenience method to perform Direct execution of a query.
|
DirectStatement.ResultSet |
plan()
Prepares and plans a query for execution, returning a result set to
execute the query.
|
PrepareResult |
prepareResult() |
allResources, authorize, authorizer, closeQuietly, query, reporter, resources, sqlQueryId, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitresourcesprotected PrepareResult prepareResult
protected DirectStatement.ResultSet resultSet
public DirectStatement(SqlToolbox lifecycleToolbox, SqlQueryPlus queryPlus, String remoteAddress)
public DirectStatement(SqlToolbox lifecycleToolbox, SqlQueryPlus sqlRequest)
public Sequence<Object[]> execute()
plan() step and the DirectStatement.ResultSet.run() step.public DirectStatement.ResultSet plan()
DirectStatement.ResultSet.run() to run the resulting plan.protected PlannerResult createPlan(DruidPlanner planner)
protected DirectStatement.ResultSet createResultSet(PlannerResult plannerResult)
public PrepareResult prepareResult()
public void cancel()
cancel in interface SqlLifecycleManager.Cancelablepublic void close()
AbstractStatementclose in interface Closeableclose in interface AutoCloseableclose in class AbstractStatementpublic void closeWithError(Throwable e)
AbstractStatementstmt.reporter().failed(e);
stmt.close();
closeWithError in class AbstractStatementCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.