HBASE中的SingleColumnValueFilter给出错误

时间:2016-04-01 11:28:06

标签: hadoop hbase cloudera

我正在尝试使用HBase过滤器,目前仍然使用SingleColumnValueFilter

以下是我尝试的查询:

scan 'hi_rate', {COLUMNS => 'cf1:RateExpirationDate', LIMIT => 10, FILTER => "SingleColumnValueFilter(=,'19068PA','cf1','RateExpirationDate')"}

scan 'hi_rate', {LIMIT => 10, FILTER => "SingleColumnValueFilter(=,'19068PA','cf1','RateExpirationDate')"}

scan 'hi_rate', {LIMIT => 10, FILTER => "SingleColumnValueFilter('cf1','RateExpirationDate',=,'19068PA')"}

他们都给出了同样的错误:

  

错误:不正确的过滤字符串SingleColumnValueFilter(=,'19068PA',   'cf1','RateExpirationDate')

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

我在HBase表上查询的一般语法如下:

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.util.Bytes

scan 'table_name', {FILTER => SingleColumnValueFilter.new(Bytes.toBytes('column_family_name'), Bytes.toBytes('column_name'), CompareFilter::CompareOp.valueOf('EQUAL'), Bytes.toBytes('value')) }

根据您的表格更改table_name,column_family_name和column_name。

假设

table_name = hi_rate 
column_family_name = cf1 
column_name = RateExpirationDate 
value = 19068PA

然后您的查询将变为

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.util.Bytes

scan 'hi_rate', {FILTER => SingleColumnValueFilter.new(Bytes.toBytes('cf1'), Bytes.toBytes('RateExpirationDate'), CompareFilter::CompareOp.valueOf('EQUAL'), Bytes.toBytes('19068PA')) }