mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.alibaba.druid.hdriver;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
public interface HConnection extends Connection {
|
||||
|
||||
}
|
||||
@@ -5,14 +5,14 @@ import java.sql.DriverPropertyInfo;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnection;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnectionImpl;
|
||||
|
||||
public class HDriver implements Driver {
|
||||
|
||||
public static String PREFIX = "jdbc:druid-hbase:";
|
||||
|
||||
@Override
|
||||
public HBaseConnection connect(String url, Properties info) throws SQLException {
|
||||
public HBaseConnectionImpl connect(String url, Properties info) throws SQLException {
|
||||
if (!acceptsURL(url)) {
|
||||
return null;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class HDriver implements Driver {
|
||||
|
||||
info.put("hbase.zookeeper.quorum", rest);
|
||||
|
||||
return new HBaseConnection(engine, info);
|
||||
return new HBaseConnectionImpl(engine, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.alibaba.druid.hdriver;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnection;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnectionImpl;
|
||||
|
||||
public interface HStatement extends Statement {
|
||||
HBaseConnection getConnection() throws SQLException;
|
||||
HBaseConnectionImpl getConnection() throws SQLException;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ 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.hdriver.impl.jdbc.HBaseConnection;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnectionImpl;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HPreparedStatementImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils;
|
||||
@@ -21,7 +21,7 @@ public class InsertExecutePlan extends SingleTableExecutePlan {
|
||||
@Override
|
||||
public boolean execute(HPreparedStatementImpl statement) throws SQLException {
|
||||
try {
|
||||
HBaseConnection connection = statement.getConnection();
|
||||
HBaseConnectionImpl connection = statement.getConnection();
|
||||
String dbType = connection.getConnectProperties().getProperty("dbType");
|
||||
|
||||
Put put = null;
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import org.apache.hadoop.hbase.filter.RowFilter;
|
||||
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnection;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnectionImpl;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HPreparedStatementImpl;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HResultSetMetaData;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HScannerResultSet;
|
||||
@@ -72,7 +72,7 @@ public class SingleTableQueryExecutePlan extends SingleTableExecutePlan {
|
||||
@Override
|
||||
public HScannerResultSet executeQuery(HPreparedStatementImpl statement) throws SQLException {
|
||||
try {
|
||||
HBaseConnection connection = statement.getConnection();
|
||||
HBaseConnectionImpl connection = statement.getConnection();
|
||||
String dbType = connection.getConnectProperties().getProperty("dbType");
|
||||
|
||||
Scan scan = new Scan();
|
||||
|
||||
+5
-4
@@ -21,15 +21,16 @@ import java.util.Properties;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
|
||||
import com.alibaba.druid.hdriver.HConnection;
|
||||
import com.alibaba.druid.hdriver.HEngine;
|
||||
import com.alibaba.druid.util.jdbc.ConnectionBase;
|
||||
|
||||
public class HBaseConnection extends ConnectionBase implements Connection {
|
||||
public class HBaseConnectionImpl extends ConnectionBase implements HConnection {
|
||||
|
||||
|
||||
private final HEngine engine;
|
||||
|
||||
public HBaseConnection(HEngine engine, Properties info){
|
||||
public HBaseConnectionImpl(HEngine engine, Properties info){
|
||||
super(engine.getUrl(), info);
|
||||
this.engine = engine;
|
||||
|
||||
@@ -127,7 +128,7 @@ public class HBaseConnection extends ConnectionBase implements Connection {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (iface == Connection.class || iface == HBaseConnection.class) {
|
||||
if (iface == Connection.class || iface == HBaseConnectionImpl.class) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@ public class HBaseConnection extends ConnectionBase implements Connection {
|
||||
return (T) engine;
|
||||
}
|
||||
|
||||
if (iface == Connection.class || iface == HBaseConnection.class) {
|
||||
if (iface == Connection.class || iface == HBaseConnectionImpl.class) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
private final String sql;
|
||||
private String[] columnNames;
|
||||
|
||||
private HBaseConnection hbaseConnection;
|
||||
private HBaseConnectionImpl hbaseConnection;
|
||||
|
||||
private ExecutePlan executePlan;
|
||||
|
||||
private String dbType = "hbase";
|
||||
|
||||
public HPreparedStatementImpl(HBaseConnection conn, String sql) throws SQLException{
|
||||
public HPreparedStatementImpl(HBaseConnectionImpl conn, String sql) throws SQLException{
|
||||
super(conn);
|
||||
this.sql = sql;
|
||||
this.hbaseConnection = conn;
|
||||
@@ -140,7 +140,7 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
}
|
||||
|
||||
@Override
|
||||
public HBaseConnection getConnection() throws SQLException {
|
||||
public HBaseConnectionImpl getConnection() throws SQLException {
|
||||
return hbaseConnection;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@ import com.alibaba.druid.util.jdbc.StatementBase;
|
||||
|
||||
public class HStatementImpl extends StatementBase implements Statement, HStatement {
|
||||
|
||||
private HBaseConnection conn;
|
||||
private HBaseConnectionImpl conn;
|
||||
|
||||
public HStatementImpl(HBaseConnection conn){
|
||||
public HStatementImpl(HBaseConnectionImpl conn){
|
||||
super(conn);
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HBaseConnection getConnection() throws SQLException {
|
||||
public HBaseConnectionImpl getConnection() throws SQLException {
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user