HBase: Custom Scanner to Receive Columns Using Prefix Only

I use a scanner to extract strings from HBase. I can set which columns I want using the addColumn () method. However, I really need to be able to get a variable number of columns, all of which start with the same prefix.

So, all the columns that I want to start, for example, with "USA". I need to get all the columns that start with this, for example “USA-Virginia”, “USA-Hawaii”, etc. I don't want values ​​like Canada-Quebec. For full column names, there are no predefined values ​​anywhere. I just need all of them that start with "USA." Is there a way to get HBase Scanners to do this? I do not see much point in writing custom scanners.

I looked at custom filters, but it just restricts the rows that I get, as opposed to specifying the columns that I want to return. Thoughts?

I cannot change the structure of my data, and all my data is under one column family.

Thanks for any ideas. I am running CDH3u4.

+3
source share
2

, ColumnPrefixFilter
http://archive.cloudera.com/cdh/3/hbase/apidocs/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html

- : -

filter = new ColumnPrefixFilter(Bytes.toBytes("USA"))
+4

org.apache.hadoop.hbase.filter.SubstringComparator, .

0

All Articles