Reputation: 37
I want to read all the data from hbase table using Hive. Should be able to read all the Current and previous versions data from hbase
Upvotes: 0
Views: 652
Reputation: 202
You can specify the number of version
you get for Scan and Get and it will retrieve them:
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
: Versioning is by default disabled while creating table.
So, you need to enable it.
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}
For Hbase-hive
integration follow the ref. link :
https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration
Upvotes: 0