我正在使用hbase java客戶端,並且能夠從所有表名,列族和列中獲取hbase數據存儲的元數據,但我無法獲取數據類型HBase的專欄中,我搜索谷歌和才知道,這是不可能得到的數據HBase列數據類型
具有HBase的Java客戶端HTableDescriptor
的幫助的類型,HColumnDescriptor
另一個問題是我收到的元數據這我認爲這不是方式,如果任何人可以優化此代碼將真的幫助我
public List<ColumnFamily> getMetaDataOfTable(String tableName) {
HTable table = null;
try {
HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes
.toBytes(tableName));
HColumnDescriptor[] columnDescriptor = tableDescriptor
.getColumnFamilies();
for (HColumnDescriptor temp : columnDescriptor) {
ColumnFamily columnFamily = new ColumnFamily();
columnFamily.setName(temp.getNameAsString());
columnFamilies.add(columnFamily);
}
table = new HTable(conf, tableName);
Scan scan = new Scan();
for (ColumnFamily columnFamily : columnFamilies) {
scan.addFamily(Bytes.toBytes(columnFamily.getName()));
ResultScanner scanner = table.getScanner(scan);
for (Result result = scanner.next(); result != null; result = scanner
.next()) {
Map<byte[], byte[]> map = result.getFamilyMap(Bytes
.toBytes(columnFamily.getName()));
columnFamily.setColumnsList(getColumns(map));
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
table.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return columnFamilies;
}
請幫助我,如果你能 感謝