Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a maximum version number in hbase?

Tags:

hbase

If I want to insert in a table:

row | fam:qualifier | timestamp | value
1 | foo:bar | 12345 | 2
1 | foo:bar | 12346 | 3
1 | foo:bar | 12347 | 2
1 | foo:bar | 12348 | 1
.
.
. 
1 | foo:bar | 123410 | 2

I can specify in the hbase shell the maximum number of version to get fom a specific row but when I specify for instance '100' it return me only 4 versions... Is there any maximum?

like image 563
JohnJohnGa Avatar asked Oct 21 '11 17:10

JohnJohnGa


2 Answers

It only returns 4 versions because the column family is set to store a maximum of 4 versions.

If you want to store more versions you need to alter the CF. Using the hbase shell:

hbase> alter 'table_foo', {NAME => 'column_fam_foo', VERSIONS => 100}

The default for max versions is 1*:

http://hbase.apache.org/book/schema.versions.html

*It seems the default value for max versions was changed from 3 to 1 at some point.

like image 87
codingFoo Avatar answered Oct 21 '22 13:10

codingFoo


the answer is partly right. Not true: hbase STORES three versions. Proof see below. True: you can set the maximum amount of versions which hbase returns through

alter 'marketdata', NAME => 'field', VERSIONS => 100   

But for now let's assume, I didn't change the version variable.

I have ten entries in my hbase, with timestamps from 0 to 9. The most current timestamp is:

hbase(main):025:0> get 'marketdata', 'instrument1', {COLUMN => 'field:ask'}                                 
COLUMN                             CELL                                                                                   
 field:ask                     timestamp=9,         value=0.9940174211042572                                                  
1 row(s) in 0.0590 seconds

hbase(main):026:0> 

The values from timestamp 1 to 5 that are shown are:

hbase(main):027:0> get 'marketdata', 'instrument1', {COLUMN => 'field:ask', TIMERANGE => [0,5], VERSIONS=>5}
COLUMN                             CELL                                                                                   
 field:ask                     timestamp=4, value=0.530618878519702                                                   
 field:ask                     timestamp=3, value=0.051028316270589014                                                
 field:ask                     timestamp=2,     value=0.11949750640509116                                                 
3 row(s) in 0.0130 seconds

hbase(main):028:0>

... and when i set my end timestamp to 10, it still shows only the last three versions BEFORE that timestamp and suppresses the former ones:

hbase(main):028:0> get 'marketdata', 'instrument1', {COLUMN => 'field:ask', TIMERANGE => [0,10], VERSIONS=>5}
COLUMN                             CELL                                                                                   
 field:ask                     timestamp=9,     value=0.9940174211042572                                                  
 field:ask                     timestamp=8,     value=0.6941263513176372                                                  
 field:ask                     timestamp=7,     value=0.1814043435754933                                                  
3 row(s) in 0.0400 seconds

hbase(main):029:0> 
like image 36
user1052080 Avatar answered Oct 21 '22 11:10

user1052080