user2296188
user2296188

Reputation: 139

Retrieve the Value of Dynamicaly Generated Columns from Hbase

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.

Upvotes: 2

Views: 48

Answers (1)

Alexander Kuznetsov
Alexander Kuznetsov

Reputation: 3112

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

Upvotes: 1

Related Questions