You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by John Sichi <js...@facebook.com> on 2010/09/13 19:07:12 UTC

question on Scan.setStopRow

Hey hbasers,

I'm working on pushing predicates down from Hive, and starting with a very basic case (equality on a simple key).  This ends up looking like a get, but for now it still uses TableInputFormatBase since later we'll be extending it to range scans as well.

After converting the key to byte [] startRow, I do the following, since stopRow is exclusive rather than inclusive:

    byte [] stopRow = new byte[startRow.length + 1];
    System.arraycopy(startRow, 0, stopRow, 0, startRow.length);
    scan.setStartRow(startRow);
    scan.setStopRow(stopRow);

I just wanted to confirm

(a) Is this the correct way to create a stopRow for a point lookup (appending a single zero byte to make the successor lexical value)?

(b) Do I also need a WhileMatchFilter, or is setStartRow+setStopRow guaranteed to do all the filtering directly?

Thanks,
JVS


Re: question on Scan.setStopRow

Posted by Stack <st...@duboce.net>.
On Mon, Sep 13, 2010 at 10:07 AM, John Sichi <js...@facebook.com> wrote:
> Hey hbasers,
>
> I'm working on pushing predicates down from Hive, and starting with a very basic case (equality on a simple key).  This ends up looking like a get, but for now it still uses TableInputFormatBase since later we'll be extending it to range scans as well.
>
> After converting the key to byte [] startRow, I do the following, since stopRow is exclusive rather than inclusive:
>
>    byte [] stopRow = new byte[startRow.length + 1];
>    System.arraycopy(startRow, 0, stopRow, 0, startRow.length);
>    scan.setStartRow(startRow);
>    scan.setStopRow(stopRow);
>
> I just wanted to confirm
>
> (a) Is this the correct way to create a stopRow for a point lookup (appending a single zero byte to make the successor lexical value)?
>


That looks like it should work.

You've seen InclusiveStopFilter?


> (b) Do I also need a WhileMatchFilter, or is setStartRow+setStopRow guaranteed to do all the filtering directly?
>

You don't need to add filters if you are using setStartRow,
setStopRow.  Internally they do the business themselves [1].

Let us know if it gives you trouble John,
St.Ack

1. The 'business' is performed in the HRegion scanner.  Here is where
it is created http://hbase.apache.org/docs/r0.89.20100726/xref/org/apache/hadoop/hbase/regionserver/HRegion.html#2299
 Here in the internal 'next' on the region scanner is where it acts on
stop row: http://hbase.apache.org/docs/r0.89.20100726/xref/org/apache/hadoop/hbase/regionserver/HRegion.html#2394

RE: question on Scan.setStopRow

Posted by Jonathan Gray <jg...@facebook.com>.
(a) Looks right to me.

(b) Your expected behavior is to return just the single startRow, correct?  Then all you need are start/stop rows, no other filtering necessary.

JG

> -----Original Message-----
> From: John Sichi [mailto:jsichi@facebook.com]
> Sent: Monday, September 13, 2010 10:07 AM
> To: user@hbase.apache.org
> Subject: question on Scan.setStopRow
> 
> Hey hbasers,
> 
> I'm working on pushing predicates down from Hive, and starting with a
> very basic case (equality on a simple key).  This ends up looking like
> a get, but for now it still uses TableInputFormatBase since later we'll
> be extending it to range scans as well.
> 
> After converting the key to byte [] startRow, I do the following, since
> stopRow is exclusive rather than inclusive:
> 
>     byte [] stopRow = new byte[startRow.length + 1];
>     System.arraycopy(startRow, 0, stopRow, 0, startRow.length);
>     scan.setStartRow(startRow);
>     scan.setStopRow(stopRow);
> 
> I just wanted to confirm
> 
> (a) Is this the correct way to create a stopRow for a point lookup
> (appending a single zero byte to make the successor lexical value)?
> 
> (b) Do I also need a WhileMatchFilter, or is setStartRow+setStopRow
> guaranteed to do all the filtering directly?
> 
> Thanks,
> JVS