hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Purtell <apurt...@apache.org>
Subject Re: HBase REST SingleColumnValueFilter
Date Thu, 16 Feb 2012 19:31:46 GMT
Hi,

One option is to build a Scan object and attach the filter construction you would like using
the Java API:

   Scan scan = new Scan();
   Filter filter = new ... ;

   scan.setFilter(filter);

 
and then use REST's model API to construct and submit the request:

   ScannerModel model = ScannerModel.fromScan(scan);
   // submit the scanner model using methods in org.apache.hadoop.hbase.rest.client

But for non Java clients you can stringify the filter:

   String filterAsJSON = ScannerModel.stringifyFilter(filter);

Building a Filter object hierarchy and dumping the JSON representation of it can be done interactively
using the HBase shell, which is JRuby. 

This will give you back a representation of the scanner that you can plug in.

    curl -v -H 'Content-Type: text/xml' \
      -d '<Scanner startRow="ddo" stopRow="ddp" batch="1024" 
         filter="FILTER JSON REPRESENTATION GOES HERE"/>'

Of course documenting the JSON representations of filters would be quite helpful I realize,
but filters have been evolving and I didn't want to produce documentation that would be quickly
out of date. Patches for such documentation and maintenance thereof would always be welcome!


Best regards,


    - Andy

Problems worthy of attack prove their worth by hitting back. - Piet Hein (via Tom White)



----- Original Message -----
> From: Mario Lassnig <mario.lassnig@cern.ch>
> To: user@hbase.apache.org
> Cc: 
> Sent: Thursday, February 16, 2012 2:48 AM
> Subject: HBase REST SingleColumnValueFilter
> 
> Hello,
> 
> I cannot figure out how to use filters in the HBase REST interface (HBase 
> 0.90.4-cdh3u3). The documentation just gives me a schema definition for a 
> "filter string", but doesn't show how to use it.
> 
> So, I'm able to do this:
> 
> curl -v -H 'Content-Type: text/xml' -d '<Scanner 
> startRow="ddo" stopRow="ddp" 
> batch="1024"/>' 'http://hbasegw:8080/table/scanner'
> 
> and then retrieve with
> 
> curl -s -H "Content-Type: text/xml" 
> http://hbasegw:8080/table/scanner/13293426893883128482b
> 
> But now I want to use a few SingleColumnValueFilters that all must succeed 
> (e.g., like the java FilterList(FilterList.Operator.MUST_PASS_ALL..)
> 
> and have to encode that somehow in the XML. Does anyone have an example for 
> this?
> 
> Thanks, Mario
> 

Mime
View raw message