0
我想使用Hive從hbase表中讀取所有數據。 應該能夠從HBase的如何從Hive中讀取hbase當前版本和以前版本的數據
我想使用Hive從hbase表中讀取所有數據。 應該能夠從HBase的如何從Hive中讀取hbase當前版本和以前版本的數據
讀取所有當前和以前版本的數據,您可以指定number of version
你得到掃描和獲取,它會檢索它們:
HTable cTable = new HTable(TableName);
Get res = new Get(Bytes.toBytes(key));
//set no. of version that you want to fetch.
res.setMaxVersions(verNo); <--
Result fetchRow = cTable.get(res);
NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long,byte[] >>> allVersions = fetchRow.getMap();
Note
:版本默認情況下禁用同時創建表格。 所以,你需要啓用它。
create 'employee',{NAME=>"myname",Versions=>2},'office' //Here versioning is enabled for column "myname" as "2" and no versioning for column "office"
describe 'employee' // show you versioning information.
alter 'employee',NAME=>'office',VERSIONS =>4 // Alter
// Put and scan the table - it will show new and old value
put 'employee','1','myname:name','Jigyasa1'
put 'employee','1','myname:name','Jigyasa2'
put 'employee','1','office:name','Add1'
put 'employee','1','office:name','Add2'
scan 'employee',{VERSIONS=>10}
對於Hbase-hive
集成請參考參考文獻。鏈接: https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration
您是否使用UDF在Hive中創建表格 – Jig232