Efficiently scanning on composite row key in hbase

359 Views Asked by At

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.

1

There are 1 best solutions below

3
On BEST ANSWER

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.