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

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

  •  21-07-2023
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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().

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top