hbase support refactor

This commit is contained in:
温少
2012-05-19 08:26:20 +08:00
parent 5ca7000362
commit a1dc243c26
3 changed files with 16 additions and 10 deletions
@@ -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);