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