mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.common.jdbc.PreparedStatementBase;
|
||||
import com.alibaba.druid.hbase.exec.ExecutePlan;
|
||||
import com.alibaba.druid.hbase.exec.InsertExecutePlan;
|
||||
import com.alibaba.druid.hbase.exec.SingleTableQueryExecutePlan;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
@@ -59,6 +60,9 @@ public class HBasePreparedStatement extends PreparedStatementBase implements Pre
|
||||
|
||||
String tableName = ((SQLIdentifierExpr) insertStmt.getTableSource().getExpr()).getName();
|
||||
|
||||
InsertExecutePlan insertExecutePlan = new InsertExecutePlan();
|
||||
insertExecutePlan.setTableName(tableName);
|
||||
|
||||
throw new SQLException("TODO");
|
||||
} else {
|
||||
throw new SQLException("TODO");
|
||||
|
||||
@@ -1,21 +1,47 @@
|
||||
package com.alibaba.druid.hbase.exec;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
import com.alibaba.druid.hbase.HBaseConnection;
|
||||
import com.alibaba.druid.hbase.HBasePreparedStatement;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
|
||||
public class InsertExecutePlan extends SingleTableExecutePlan {
|
||||
|
||||
private Map<String, SQLExpr> columns = new LinkedHashMap<String, SQLExpr>();
|
||||
private byte[] family = Bytes.toBytes("d");
|
||||
|
||||
@Override
|
||||
public void execute(HBasePreparedStatement statement) throws SQLException {
|
||||
try {
|
||||
HBaseConnection connection = statement.getConnection();
|
||||
HTableInterface htable = connection.getHTable(getTableName());
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
Put put = new Put();
|
||||
for (int i = 0; i < columns.size(); ++i) {
|
||||
// String column = columns.get(i);
|
||||
// Object value = statement.getParameters().get(i);
|
||||
//
|
||||
// byte[] qualifier = Bytes.toBytes(column);
|
||||
// byte[] bytes;
|
||||
//
|
||||
// if (value instanceof String) {
|
||||
// String strValue = (String) value;
|
||||
// bytes = Bytes.toBytes(strValue);
|
||||
// } else {
|
||||
// throw new SQLException("TODO"); // TODO
|
||||
// }
|
||||
//
|
||||
// put.add(family, qualifier, bytes);
|
||||
}
|
||||
|
||||
htable.put(put);
|
||||
} catch (SQLException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
@@ -23,4 +49,12 @@ public class InsertExecutePlan extends SingleTableExecutePlan {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, SQLExpr> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(Map<String, SQLExpr> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user