You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Slava Gorelik <sl...@gmail.com> on 2010/03/07 15:47:08 UTC

Regular expression as column qualifier

Hi.
Is it possible to use regex as column qualifier in the get operation ?

Thank You and Best Regards.

Re: Regular expression as column qualifier

Posted by Slava Gorelik <sl...@gmail.com>.
Thanks Lars

On Sun, Mar 7, 2010 at 5:33 PM, Lars Francke <la...@gmail.com> wrote:

> > Thank You for quick reply, but I'm not talking about row key, but about
> > column qualifier (column key).
>
> Oh! I'm sorry - must have misread that.
>
> The answer is unfortunately the same. It is not possible to do
> something like that in the get operation. With the addColumn function
> you have to add the specific qualifier you're looking for and in the
> result you can only iterate over every column qualifier to see if it
> matches.
>
> But you can use a scan here too as there is a filter that filters
> based on column qualifiers[1]. I can't say what the best solution for
> your specific problem is though.
>
> Hope that helps.
>
> Lars
>
> [1] <
> http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/QualifierFilter.html
> >
>

Re: Regular expression as column qualifier

Posted by Lars Francke <la...@gmail.com>.
> Thank You for quick reply, but I'm not talking about row key, but about
> column qualifier (column key).

Oh! I'm sorry - must have misread that.

The answer is unfortunately the same. It is not possible to do
something like that in the get operation. With the addColumn function
you have to add the specific qualifier you're looking for and in the
result you can only iterate over every column qualifier to see if it
matches.

But you can use a scan here too as there is a filter that filters
based on column qualifiers[1]. I can't say what the best solution for
your specific problem is though.

Hope that helps.

Lars

[1] <http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/QualifierFilter.html>

Re: Regular expression as column qualifier

Posted by Slava Gorelik <sl...@gmail.com>.
Hi Lars,
Thank You for quick reply, but I'm not talking about row key, but about
column qualifier (column key).

Best Regards.

On Sun, Mar 7, 2010 at 5:03 PM, Lars Francke <la...@gmail.com> wrote:

> Hi,
>
> > Is it possible to use regex as column qualifier in the get operation ?
>
> no, that's not possible. For a "get"[1] operation you need to specify
> the exact row key you are looking for and there will be at most one
> result.
>
> You can use a "scan"[2] (which may return multiple results) in
> combination with a RowFilter[3] and a RegexStringComparator[4]. See
> the tests[5] for a few examples.
>
> Cheers,
> Lars
>
> [1] <
> http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/client/HTable.html#get(org.apache.hadoop.hbase.client.Get)
> >
> [2] <
> http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/client/HTable.html#getScanner(org.apache.hadoop.hbase.client.Scan)
> >
> [3] <
> http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/RowFilter.html
> >
> [4] <
> http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/RegexStringComparator.html
> >
> [5] <
> http://svn.apache.org/viewvc/hadoop/hbase/tags/0.20.3/src/test/org/apache/hadoop/hbase/filter/TestFilter.java?revision=902976&view=markup
> >
>

Re: Regular expression as column qualifier

Posted by Lars Francke <la...@gmail.com>.
Hi,

> Is it possible to use regex as column qualifier in the get operation ?

no, that's not possible. For a "get"[1] operation you need to specify
the exact row key you are looking for and there will be at most one
result.

You can use a "scan"[2] (which may return multiple results) in
combination with a RowFilter[3] and a RegexStringComparator[4]. See
the tests[5] for a few examples.

Cheers,
Lars

[1] <http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/client/HTable.html#get(org.apache.hadoop.hbase.client.Get)>
[2] <http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/client/HTable.html#getScanner(org.apache.hadoop.hbase.client.Scan)>
[3] <http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/RowFilter.html>
[4] <http://hadoop.apache.org/hbase/docs/r0.20.3/api/org/apache/hadoop/hbase/filter/RegexStringComparator.html>
[5] <http://svn.apache.org/viewvc/hadoop/hbase/tags/0.20.3/src/test/org/apache/hadoop/hbase/filter/TestFilter.java?revision=902976&view=markup>