1

There is a column lets say Countries in hbase and I want to prefix on this column(this is not a row key) then I will use ColumnPrefixFilter and do something like this

    ColumnPrefixFilter columnPrefixFilter = new ColumnPrefixFilter("IND".getBytes());

but here I have two problems :-

  1. I don't have any option to specify the column family and namespace name so that it should search only in countries column.
  2. Secondly this filter is not working and giving no response whereas entry with INDIA value is present. These are the dependencies I am using for hbase.

    <hbase-client.version>2.0.1</hbase-client.version>
    <hbase-ds.version>0.0.2-SNAPSHOT</hbase-ds.version>
    
agrawal1084
  • 129
  • 2
  • 11

1 Answers1

1

I didn't get to know why it was not working with ColumnPrefixFilter though I got an alternative to do something like this.

   SingleColumnValueFilter filter = new SingleColumnValueFilter(COLUMN_FAMILY_NAME, QUALIFIER_NAME, CompareOperator.EQUAL,
            new BinaryPrefixComparator("IND".getBytes()));

It is working like a charm. Though I will wait if someone can explain why it was not working with ColumnPrefixFilter.

agrawal1084
  • 129
  • 2
  • 11
  • 1
    `ColumnPrefixFilter` looks for column families starting `IND`, not values. The answer you wrote is the correct solution. – Ben Watson Oct 31 '18 at 12:43