0

HBase table has Id column. I want to check it, if it isn't exist, controller calls add() method, if it's exist then controller calls update() method. Id value is injected from Controller class to Service class. How can I count row number or check if Id existed?

More, my model has create_at and update_at, how can I update and dont update create_at column? create_at is generated one time when add(), update_at store the last update time.

record.setCreateAt(Timestamp.valueOf(LocalDateTime.now()));
record.setUpdateAt(Timestamp.valueOf(LocalDateTime.now()));
Vy Do
  • 46,709
  • 59
  • 215
  • 313
Quang Minh
  • 31
  • 1
  • 1
  • 6
  • Where would you get the id value, if it does not exists in database? – Popeye Nov 26 '21 at 04:37
  • @Popeye if Id does not exists in hbase, counter(): row_counter = 0 then add() is called, if row_counter = 1 then update() is called – Quang Minh Nov 26 '21 at 04:43
  • I find that statement but it looks like not fit my purpose. https://stackoverflow.com/questions/11375098/hbase-quickly-count-number-of-rows – Quang Minh Nov 26 '21 at 07:55

0 Answers0