You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by aaaa342156 <ka...@outlook.com> on 2014/10/03 13:35:36 UTC

single column value filter to find rows greater than a certain date not working

I am storing date in a column in Hbase table. I am using below syntax to find
dates greater than 20110810 but the resultset is bringing back all the rows.
Any thoughts.

Filter filter = new SingleColumnValueFilter(Bytes.toBytes("cf"),
Bytes.toBytes("d"), CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("20110810"));
scan.setFilter(filter);
ResultScanner rs = table.getScanner(scan);



--
View this message in context: http://apache-hbase.679495.n3.nabble.com/single-column-value-filter-to-find-rows-greater-than-a-certain-date-not-working-tp4064684.html
Sent from the HBase User mailing list archive at Nabble.com.

Re: single column value filter to find rows greater than a certain date not working

Posted by lars hofhansl <la...@apache.org>.
> Bytes.toBytes("20110810")

Is that exactly how you are storing the dates? As string converted to bytes? Or did you store them as a long converted to bytes?

Also note that this is a fairly inefficient way if doing this. If this is the typical access pattern you should put the data in the row key and use Scan.{start|stop}Row to filter.


-- Lars



________________________________
 From: aaaa342156 <ka...@outlook.com>
To: user@hbase.apache.org 
Sent: Friday, October 3, 2014 4:35 AM
Subject: single column value filter to find rows greater than a certain date not working
 

I am storing date in a column in Hbase table. I am using below syntax to find
dates greater than 20110810 but the resultset is bringing back all the rows.
Any thoughts.

Filter filter = new SingleColumnValueFilter(Bytes.toBytes("cf"),
Bytes.toBytes("d"), CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("20110810"));
scan.setFilter(filter);
ResultScanner rs = table.getScanner(scan);



--
View this message in context: http://apache-hbase.679495.n3.nabble.com/single-column-value-filter-to-find-rows-greater-than-a-certain-date-not-working-tp4064684.html
Sent from the HBase User mailing list archive at Nabble.com.

Re: single column value filter to find rows greater than a certain date not working

Posted by Ted Yu <yu...@gmail.com>.
Which release of hbase are you using ?

Can you come up with unit test that shows this problem ?

BTW Your use case is covered by TestSingleColumnValueFilter.java

On Fri, Oct 3, 2014 at 4:35 AM, aaaa342156 <ka...@outlook.com> wrote:

> I am storing date in a column in Hbase table. I am using below syntax to
> find
> dates greater than 20110810 but the resultset is bringing back all the
> rows.
> Any thoughts.
>
> Filter filter = new SingleColumnValueFilter(Bytes.toBytes("cf"),
> Bytes.toBytes("d"), CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("20110810"));
> scan.setFilter(filter);
> ResultScanner rs = table.getScanner(scan);
>
>
>
> --
> View this message in context:
> http://apache-hbase.679495.n3.nabble.com/single-column-value-filter-to-find-rows-greater-than-a-certain-date-not-working-tp4064684.html
> Sent from the HBase User mailing list archive at Nabble.com.
>