Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> paging results filter


Copy link to this message
-
Re: paging results filter
I think you need
PageFilter<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/PageFilter.html>
.

HTH

Warm Regards,
Tariq
https://mtariq.jux.com/
cloudfront.blogspot.com
On Thu, Jan 24, 2013 at 6:20 PM, Toby Lazar <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I need to create a client function that allows paging of scan results
> (initially return results 1-20, then click on page to to show results
> 21-40, 41-60, etc.) without needing to remember the start rowkey.  I
> beleive that a filter would be far more efficient than implementing the
> logic client-side.  I couldn't find any OOTB filter for this functionality
> so I wrote the class below.  It seems to work fine for me, but can anyone
> comment if this approach makes sense?  Is there another OOTB filter that I
> can use instead?
>
> Thank you,
>
> Toby
>
>
>
> import java.io.DataInput;
> import java.io.DataOutput;
> import java.io.IOException;
> import org.apache.hadoop.hbase.filter.FilterBase;
> public class PageOffsetFilter extends FilterBase {
>  private long startRowCount;
>  private long endRowCount;
>
>  private int count = 0;
>  public PageOffsetFilter() {
>  }
>
>  public PageOffsetFilter(long pageNumber, long pageSize) {
>
>   if(pageNumber<1)
>    pageNumber=1;
>
>   startRowCount = (pageNumber - 1) * pageSize;
>   endRowCount = (pageSize * pageNumber)-1;
>  }
>  @Override
>  public boolean filterAllRemaining() {
>   return count > endRowCount;
>  }
>  @Override
>  public boolean filterRow() {
>
>   count++;
>   if(count <= startRowCount) {
>    return true;
>   } else {
>    return false;
>   }
>
>  }
>
>  @Override
>  public void readFields(DataInput dataInput) throws IOException {
>
>   this.startRowCount = dataInput.readLong();
>   this.endRowCount = dataInput.readLong();
>  }
>  @Override
>  public void write(DataOutput dataOutput) throws IOException {
>   dataOutput.writeLong(startRowCount);
>   dataOutput.writeLong(endRowCount);
>  }
>
> }
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB