I'm using incr
to increment a counter column in table.Now I need to filter certain records in scan
so that counter is less than some value(say 1).get
show the counter value(which is 4) for a particular row-key in hbase shell as below:
column=q:counter, timestamp=1419403701427, value=\x00\x00\x00\x00\x00\x00\x00\x04
Now if use scan filter to filter exclude this record from scan as below
{FILTER=> "SingleColumnValueFilter('q','counter',<,'binary:1',true,true)" , COLUMNS=>['q:counter'] }
Above specify record with counter value 4 is still shown in scan result.
I have tried true
,false
as third parameter of SingleColumnValueFilter
.
Do I need to specify 1 in byte format or so?
For HBase the column value is just a
byte[]
so it's a bit tricky to make the query with the HBase Shell because the standard filter language will convert everything to strings: http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/admin_hbase_filtering.htmlTo make it work with integers/longs we have to think of it as if we would do with JAVA: convert the value to a
byte[]
and feed it to a SingleColumnValueFilter with a CompareOp.First you have to import the required libraries into HBase Shell
To find rows with a value LESS than BINARY value of 20L
\x00\x00\x00\x00\x00\x00\x00\x14
For integer columns the solution is a little easier (no Long parsing required). To find rows with a value LESS than BINARY value of 20
\x00\x00\x00\x14
Valid compare operators: