hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Wolf <opus...@gmail.com>
Subject Re: Scanning the last N rows
Date Fri, 02 Mar 2012 21:42:43 GMT

Ah ha!  So the row key orders the results, I just do an unbounded Scan, 
and stop after N iterations.

Like this...

        Scan scan = new Scan();
        Filter filter = new SingleColumnValueFilter(...);
        scan.setFilter(filter);
        ResultScanner scanner = hTable.getScanner(scan);
        Iterator<Result> it = scanner.iterator();
        for ( int i=0; i<1000 && it.hasNext(); i++) {
            Result result = it.next();
            ... do stuff with result...
        }

Do I have to worry about efficiency?  Is the Server madly retrieving 
rows, in the background, that the Client will never use?

Thanks
P



On 3/2/12 4:31 PM, Doug Meil wrote:
> Hi there-
>
> Take a look at this section of the book...
>
> http://hbase.apache.org/book.html#reverse.timestamp
>
>
>
>
> On 3/2/12 4:02 PM, "Peter Wolf"<opus111@gmail.com>  wrote:
>
>> Hello all,
>>
>> I want to retrieve the most recent N rows from a table, with some column
>> qualifiers.
>>
>> I can't find a Filter, or anything obvious in my books, or via Google.
>>
>> What is the idiom for doing this?
>>
>> Thanks
>> Peter
>>
>


Mime
View raw message