HBASE : Do i need to have column which is present in key which is composite

StackOverflow https://stackoverflow.com/questions/23625123

  •  21-07-2023
  •  | 
  •  

Question

I have a hbase table which have key as A_B_C and the columnns are D and E. Do i need to have A, B and C also in columns if i want to read them or can I split my key on "_" and figure out A, B and C.

Which is better approach?

Was it helpful?

Solution

No, you don't need to have A,B & C as columns. You can fetch them as part of your rowkeys. Infact, it would be more efficient if the values you need are part of your rowkeys.

Just get the rowkey, convert it to Java String type(Use Bytes.toString()) and split on "_" using String.split().

OTHER TIPS

If you are looking to scan a row key by parts, probably you could use the apt filters.

For example,

new RowFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator(your key regex))

Javadocs @ RowFilter and RegexStringComparator would be helpful.

There is no need for your columns to come across your keys.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top