mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
hbase support refactor
This commit is contained in:
@@ -40,16 +40,22 @@ public class HBasePreparedStatement extends PreparedStatementBase implements Pre
|
||||
throw new SQLException("not support multi-statement");
|
||||
}
|
||||
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) stmtList.get(0);
|
||||
SQLSelectQueryBlock selectQueryBlock = (SQLSelectQueryBlock) stmt.getSelect().getQuery();
|
||||
SQLStatement sqlStmt = stmtList.get(0);
|
||||
if (sqlStmt instanceof SQLSelectStatement) {
|
||||
SQLSelectStatement selectStmt = (SQLSelectStatement) sqlStmt;
|
||||
|
||||
SQLExprTableSource tableSource = (SQLExprTableSource) selectQueryBlock.getFrom();
|
||||
String tableName = ((SQLIdentifierExpr) tableSource.getExpr()).getName();
|
||||
SQLSelectQueryBlock selectQueryBlock = (SQLSelectQueryBlock) selectStmt.getSelect().getQuery();
|
||||
|
||||
SingleTableQueryExecutePlan singleTableQueryExecuetePlan = new SingleTableQueryExecutePlan();
|
||||
singleTableQueryExecuetePlan.setTableName(tableName);
|
||||
SQLExprTableSource tableSource = (SQLExprTableSource) selectQueryBlock.getFrom();
|
||||
String tableName = ((SQLIdentifierExpr) tableSource.getExpr()).getName();
|
||||
|
||||
this.executePlan = singleTableQueryExecuetePlan;
|
||||
SingleTableQueryExecutePlan singleTableQueryExecuetePlan = new SingleTableQueryExecutePlan();
|
||||
singleTableQueryExecuetePlan.setTableName(tableName);
|
||||
|
||||
this.executePlan = singleTableQueryExecuetePlan;
|
||||
} else {
|
||||
throw new SQLException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
public ExecutePlan getExecutePlan() {
|
||||
@@ -75,7 +81,7 @@ public class HBasePreparedStatement extends PreparedStatementBase implements Pre
|
||||
|
||||
@Override
|
||||
public ResultSet executeQuery() throws SQLException {
|
||||
return this.executePlan.executeScan(this);
|
||||
return this.executePlan.executeQuery(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,5 +6,5 @@ import com.alibaba.druid.hbase.HBasePreparedStatement;
|
||||
import com.alibaba.druid.hbase.HBaseResultSet;
|
||||
|
||||
public interface ExecutePlan {
|
||||
HBaseResultSet executeScan(HBasePreparedStatement statement) throws SQLException;
|
||||
HBaseResultSet executeQuery(HBasePreparedStatement statement) throws SQLException;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SingleTableQueryExecutePlan implements ExecutePlan {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HBaseResultSet executeScan(HBasePreparedStatement statement) throws SQLException {
|
||||
public HBaseResultSet executeQuery(HBasePreparedStatement statement) throws SQLException {
|
||||
try {
|
||||
HBaseConnection connection = statement.getConnection();
|
||||
HTableInterface htable = connection.getHTable(tableName);
|
||||
|
||||
Reference in New Issue
Block a user