Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

HBASE Incr clarification

avatar
Expert Contributor

Hi I have below clarification on incr command.

1)what is the meaning of COUNTER VALUE = 23 i can see cf1:no3 is incremented to 3 but i did not what is meant by COUNTER VALUE = 23?

2)How to identify no of rows[3 row(s)]?Is it no of distinct keys present in HBASE table?

3)The below command is showing following error.can not we use incr on existing column in HBASE?

incr 'emp_vamsi','123','cf1:no',3

Error:- ERROR: org.apache.hadoop.hbase.DoNotRetryIOException: org.apache.hadoop.hbase.DoNotRetryIOException: Attempted to increment field that isn't 64 bits wide incr 'emp_vamsi','123','cf1:no3',3

Below is my source:
hbase(main):028:0> scan 'emp_vamsi'
ROW                                COLUMN+CELL                                                                                       
 123                               column=cf1:name, timestamp=1477459091210, value=vamsi1                                            
 123                               column=cf1:no, timestamp=1477546999021, value=1                                                   
 123                               column=cf1:no1, timestamp=1477547356118, value=\x00\x00\x00\x00\x00\x00\x00\x19                   
 123                               column=cf1:no3, timestamp=1477547272487, value=\x00\x00\x00\x00\x00\x00\x00\x14                   
 123                               column=cf1:no34, timestamp=1477547405178, value=\x00\x00\x00\x00\x00\x00\x00\x15                  
 123                               column=cf1:role, timestamp=1477459091210, value=TL                                                
 345                               column=cf1:name, timestamp=1477459091210, value=vishnu                                            
 345                               column=cf1:role, timestamp=1477459091210, value=HR                                                
 567                               column=cf1:name, timestamp=1477459091210, value=ramya                                             
 567                               column=cf1:role, timestamp=1477459091210, value=wife                                              
3 row(s) in 0.0350 seconds


Incr command:
hbase(main):029:0> incr 'emp_vamsi','123','cf1:no3',3
COUNTER VALUE = 23


hbase(main):030:0> scan 'emp_vamsi'
ROW                                COLUMN+CELL                                                                                       
 123                               column=cf1:name, timestamp=1477459091210, value=vamsi1                                            
 123                               column=cf1:no, timestamp=1477546999021, value=1                                                   
 123                               column=cf1:no1, timestamp=1477547356118, value=\x00\x00\x00\x00\x00\x00\x00\x19                   
 123                               column=cf1:no3, timestamp=1477547447862, value=\x00\x00\x00\x00\x00\x00\x00\x17                   
 123                               column=cf1:no34, timestamp=1477547405178, value=\x00\x00\x00\x00\x00\x00\x00\x15                  
 123                               column=cf1:role, timestamp=1477459091210, value=TL                                                
 345                               column=cf1:name, timestamp=1477459091210, value=vishnu                                            
 345                               column=cf1:role, timestamp=1477459091210, value=HR                                                
 567                               column=cf1:name, timestamp=1477459091210, value=ramya                                             
 567                               column=cf1:role, timestamp=1477459091210, value=wife                                              
3 row(s) in 0.0440 seconds


1 ACCEPTED SOLUTION

avatar
@vamsi valiveti

bq. 1)what is the meaning of COUNTER VALUE = 23 i can see cf1:no3 is incremented to 3 but i did not what is meant by COUNTER VALUE = 23?

COUNTER VALUE printed is latest value after incrementing the value to specified number. In your case the column value before incrementing might be 20.

=> Hbase::Table - test
hbase(main):013:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 1
0 row(s) in 0.0080 seconds

hbase(main):014:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 2
0 row(s) in 0.0060 seconds

hbase(main):015:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 3
0 row(s) in 0.0040 seconds

bq. 2)How to identify no of rows[3 row(s)]?Is it no of distinct keys present in HBASE table?

Yes. It's distinct row keys in the table.

bq. 3)The below command is showing following error.can not we use incr on existing column in HBASE?

Yes we cannot use incr on existing column. The column value should be initialized with incr only.

View solution in original post

2 REPLIES 2

avatar
@vamsi valiveti

bq. 1)what is the meaning of COUNTER VALUE = 23 i can see cf1:no3 is incremented to 3 but i did not what is meant by COUNTER VALUE = 23?

COUNTER VALUE printed is latest value after incrementing the value to specified number. In your case the column value before incrementing might be 20.

=> Hbase::Table - test
hbase(main):013:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 1
0 row(s) in 0.0080 seconds

hbase(main):014:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 2
0 row(s) in 0.0060 seconds

hbase(main):015:0> incr 'test', 'spam', 'foo:bar', 1
COUNTER VALUE = 3
0 row(s) in 0.0040 seconds

bq. 2)How to identify no of rows[3 row(s)]?Is it no of distinct keys present in HBASE table?

Yes. It's distinct row keys in the table.

bq. 3)The below command is showing following error.can not we use incr on existing column in HBASE?

Yes we cannot use incr on existing column. The column value should be initialized with incr only.

avatar
Expert Contributor

Thanks Rajesh for your valuable time