public interface SqlExecutor
Each execution (both query and non-query shall return an non-negative execution ID(execId). Negative execution IDs are reserved for error handling.
User shall be able to query the status of an execution even after it's finished, so the executor shall keep record of all the execution unless being asked to remove them ( when removeExecution is called.)
IMPORTANT: An executor shall support two ways of supplying data: 1. Say user selects profiles of users who visited LinkedIn in the last 5 mins. There could be millions of rows, but the UI only need to show a small fraction. That's retrieveQueryResult, accepting a row range (startRow and endRow). Note that UI may ask for the same data over and over, like when user switches from page 1 to page 2 and data stream changes at the same time, the two pages may actually have overlapped or even same data.
2. Say user wants to see clicks on a LinkedIn page of certain person from now on. In this mode consumeQueryResult shall be used. UI can keep asking for new rows, and once the rows are consumed, it's no longer necessary for the executor to keep them. If lots of rows come in, the UI may be only interested in the last certain rows (as it's in a logview mode), so all data older can be dropped.
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String[]> |
consumeQueryResult(ExecutionContext context,
int startRow,
int endRow)
Consumes rows from query result.
|
NonQueryResult |
executeNonQuery(ExecutionContext context,
java.io.File file)
Executes all the NON-QUERY statements in the sqlFile.
|
NonQueryResult |
executeNonQuery(ExecutionContext context,
java.util.List<java.lang.String> statements) |
QueryResult |
executeQuery(ExecutionContext context,
java.lang.String statement) |
EnvironmentVariableHandler |
getEnvironmentVariableHandler() |
int |
getRowCount() |
org.apache.samza.sql.schema.SqlSchema |
getTableSchema(ExecutionContext context,
java.lang.String tableName) |
java.lang.String |
getVersion()
Gets the version of this executor.
|
java.util.List<SqlFunction> |
listFunctions(ExecutionContext context) |
java.util.List<java.lang.String> |
listTables(ExecutionContext context) |
ExecutionStatus |
queryExecutionStatus(int execId) |
void |
removeExecution(ExecutionContext context,
int exeId)
Removing an ongoing execution shall result in an error.
|
java.util.List<java.lang.String[]> |
retrieveQueryResult(ExecutionContext context,
int startRow,
int endRow)
Row starts at 0.
|
void |
start(ExecutionContext context)
SqlExecutor shall be ready to accept all other calls after start() is called.
|
void |
stop(ExecutionContext context)
Indicates no further calls will be made thus it's safe for the executor to clean up.
|
void |
stopExecution(ExecutionContext context,
int exeId) |
void start(ExecutionContext context) throws ExecutorException
context - The ExecutionContext at the time of the call.ExecutorException - if the Executor encounters an error.void stop(ExecutionContext context) throws ExecutorException
context - The ExecutionContext at the time of the call.ExecutorException - if the Executor encounters an error.EnvironmentVariableHandler getEnvironmentVariableHandler()
java.util.List<java.lang.String> listTables(ExecutionContext context) throws ExecutorException
context - The ExecutionContext at the time of the call.ExecutorException - if the Executor encounters an error.org.apache.samza.sql.schema.SqlSchema getTableSchema(ExecutionContext context, java.lang.String tableName) throws ExecutorException
context - The ExecutionContext at the time of the call.tableName - Name of the table to get the schema for.ExecutorException - if the Executor encounters an error.QueryResult executeQuery(ExecutionContext context, java.lang.String statement) throws ExecutorException
context - The ExecutionContext at the time of the call.statement - statement to executeExecutorException - if the Executor encounters an error.int getRowCount()
throws ExecutorException
ExecutorException - if the Executor encounters an error.java.util.List<java.lang.String[]> retrieveQueryResult(ExecutionContext context, int startRow, int endRow) throws ExecutorException
context - The ExecutionContext at the time of the call.startRow - Start row index (inclusive)endRow - End row index (inclusive)ExecutorException - if the Executor encounters an error.java.util.List<java.lang.String[]> consumeQueryResult(ExecutionContext context, int startRow, int endRow) throws ExecutorException
context - The ExecutionContext at the time of the call.startRow - Start row index (inclusive)endRow - End row index (inclusive)ExecutorException - if the Executor encounters an error.NonQueryResult executeNonQuery(ExecutionContext context, java.io.File file) throws ExecutorException
context - The ExecutionContext at the time of the call.file - A File object to read statements from.ExecutorException - if the Executor encounters an error.NonQueryResult executeNonQuery(ExecutionContext context, java.util.List<java.lang.String> statements) throws ExecutorException
context - The ExecutionContext at the time of the call.statements - A list of non-query sql statements.ExecutorException - if the Executor encounters an error.void stopExecution(ExecutionContext context, int exeId) throws ExecutorException
context - The ExecutionContext at the time of the call.exeId - Execution ID.ExecutorException - if the Executor encounters an error.void removeExecution(ExecutionContext context, int exeId) throws ExecutorException
context - The ExecutionContext at the time of the callexeId - Execution ID.ExecutorException - if the Executor encounters an error.ExecutionStatus queryExecutionStatus(int execId) throws ExecutorException
execId - Execution ID.ExecutorException - if the Executor encounters an error.java.util.List<SqlFunction> listFunctions(ExecutionContext context) throws ExecutorException
context - The ExecutionContext at the time of the call.ExecutorException - if the Executor encounters an error.java.lang.String getVersion()