Reputation: 11234
I have an HBase table that has 2 versions. How do I get
the row of a specific version?
create 'mytable', {NAME=>'cf1',VERSIONS=>2}
put 'mytable', 'row1', 'cf1:lang','english', {VERSIONS=>1} //version 1 value
put 'mytable', 'row1', 'cf1:lang', 'spanish', {VERSIONS=>2} //version 2 value
get 'mytable','row1' //gets the latest version
COLUMN CELL
cf1:lang timestamp=1521884601517, value=spanish
Now I want to get the row that has the value english
, so I do
get 'mytable','row1',{COLUMN=>'cf1',VERSIONS=>1} //I expect 'english'
COLUMN CELL
cf1:lang timestamp=1521884601517, value=spanish
probably I have misunderstood versions in HBase. Any inputs?
Upvotes: 0
Views: 433
Reputation: 4476
When create, VERSIONS=>2
means that row remain 2 versions of data.
When get, VERSIONS=>1
means that the most recent 1 data will return.
Get a specific version, you can achieve that by using explicit version, which you can reference the following steps:
hbase(main):062:0> create 'mytable', {NAME=>'cf1',VERSIONS=>2}
0 row(s) in 1.2360 seconds
=> Hbase::Table - mytable
hbase(main):063:0> put 'mytable', 'row1', 'cf1:lang', 'english', 1521900360000
0 row(s) in 0.0160 seconds
hbase(main):064:0> put 'mytable', 'row1', 'cf1:lang', 'spanish', 1521900370000
0 row(s) in 0.0030 seconds
hbase(main):065:0> get 'mytable','row1',{COLUMN=>'cf1',TIMESTAMP => 1521900360000}
COLUMN CELL
cf1:lang timestamp=1521900360000, value=english
1 row(s) in 0.0030 seconds
Upvotes: 1