2

For example, here is some records in a hbase table:

123,  column=cf:dcol#0,  value=aaaa
123,  column=cf:dcol#1,  value=bbbb
123,  column=cf:dcol#2,  value=cccc
123,  column=cf:someOtherCol, value=dddd

The column dcol# is create dynamically by increasing the last digit.

Is there a way to get all the dcol# columns using native hbase lib without getting all the columns and knowing the number of dcol columns is available for this rowkey.

Thanks in advance for any input.

Community
  • 1
  • 1
user2296188
  • 139
  • 8

1 Answers1

1

To achieve it you can use ColumnPrefixFilter. See example below

Get get = new Get(Bytes.toBytes(123));
get.addFamily(Bytes.toBytes("cf"));
get.setFilter(new ColumnPrefixFilter(Bytes.toBytes("dcol#")));
Result result = hTable.get(get);
.....
Alexander Kuznetsov
  • 3,062
  • 2
  • 25
  • 29