mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
hbase support
This commit is contained in:
@@ -16,6 +16,7 @@ public class HBaseResultSet extends ResultSetBase {
|
||||
private HBaseStatementInterface statement;
|
||||
private ResultScanner scanner;
|
||||
private Result result;
|
||||
private byte[] family = Bytes.toBytes("d");
|
||||
|
||||
public HBaseResultSet(HBaseStatementInterface statement, ResultScanner scanner){
|
||||
super(statement);
|
||||
@@ -60,13 +61,21 @@ public class HBaseResultSet extends ResultSetBase {
|
||||
public Object getObjectInternal(int columnIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getString(String columnName) throws SQLException {
|
||||
byte[] bytes = getBytes(columnName);
|
||||
return Bytes.toString(bytes);
|
||||
}
|
||||
|
||||
public byte[] getBytes(String columnName) throws SQLException {
|
||||
if ("@ROW".equals(columnName)) {
|
||||
return result.getRow();
|
||||
}
|
||||
|
||||
byte[] qualifier = Bytes.toBytes(columnName);
|
||||
byte[] family = Bytes.toBytes("d");
|
||||
byte[] value = result.getValue(family, qualifier);
|
||||
return Bytes.toString(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.alibaba.druid.hbase.exec;
|
||||
|
||||
public interface ExecutePlan {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.alibaba.druid.hbase.exec;
|
||||
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
|
||||
public class SingleTableQueryExecutePlan implements ExecutePlan {
|
||||
|
||||
private HTableInterface htable;
|
||||
|
||||
public HTableInterface getHtable() {
|
||||
return htable;
|
||||
}
|
||||
|
||||
public void setHtable(HTableInterface htable) {
|
||||
this.htable = htable;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,10 @@ public class HBaseDriverTest extends TestCase {
|
||||
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM test");
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString("@ROW"));
|
||||
System.out.print(' ');
|
||||
System.out.print(rs.getString("id"));
|
||||
System.out.println();
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
Reference in New Issue
Block a user