2016-04-27 91 views

回答

0

讀取所有當前和以前版本的數據,您可以指定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

+0

您是否使用UDF在Hive中創建表格 – Jig232