hbase support

This commit is contained in:
温少
2012-05-18 23:41:10 +08:00
4 changed files with 37 additions and 3 deletions
@@ -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();