0

I have my hbase table structured as follows:

a1:b1
a1:b2
a2:b1
a3:b2

Is there any way I can efficiently check if the first part of the row key exists in the hbase table? I do not want to retrieve the records, I just want to check if a1, a2, a3 exist.

PythonBoi
  • 17
  • 3

1 Answers1

0

If you are doing this via a Scan, then you can operate only on row keys, without loading any columns by adding the following filters to your Scan:

KeyOnlyFilter

FirstKeyOnlyFilter

However if you are doing this via a get, then I think you'd have to specify at least one column. If I remember correctly, an error will be thrown if you haven't added any columns to your get.

VS_FF
  • 2,353
  • 3
  • 16
  • 34
  • 1
    Recent versions of HBase client contains Get.isCheckExistenceOnly() method – Lagrang Jul 11 '19 at 14:31
  • I'm relatively new to HBase and I wanted to find out what to go with. I don't really have to scan my table and get records, I just have to check if my partial row key exists in the table. So can I utilise "get" even though I don't have the complete row key? – PythonBoi Jul 12 '19 at 02:54
  • I don't believe get works on partial row keys (because how would it know exactly WHAT to get, if say you have 3 records with the same partial row key start?). Scan would do that well. MAKE SURE you specify the start row however, because otherwise it will scan the whole table before arriving at the first match of your partial key. If you specify the start row, it will get to the right point right away and that works really well. – VS_FF Jul 12 '19 at 07:18