Hbase FilterList为MUST_PASS_ONE,带有两个RowFilters,返回所有内容



我有一个名为odds_api的列族,其行数为rowkey:/bt=/bm=/mk=/se=??:

/bt=1/bm=MN/mk=344/se=23394/odds_api
/bt=1/bm=BY/mk=344/se=23394/odds_api
/bt=1/bm=SN/mk=344/se=23394/odds_api
/bt=1/bm=BB/mk=344/se=23394/odds_api
/bt=1/bm=SF/mk=344/se=23394/odds_api
/bt=1/bm=XY/mk=344/se=23394/odds_api

我想基于bm值的列表进行过滤,也就是基于bm=SF,BB,MN的过滤器。

为此,我创建了一个MUST_PASS_ONE的filterList,其中包含1到多个rowFilters(取决于用户请求的值(

public ResultScanner scan(String id , List<String> bms) throws BigTableGetException {
try{
Table table = connection.getTable(TableName.valueOf(this.tableName));
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes("odds_api"));
FilterList mainFilterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
bms.stream()
.forEach(bm -> {
mainFilterList.addFilter(new RowFilter(CompareOp.EQUAL, new RegexStringComparator("/bt="+id+"/bm="+bm+".*")));
});
System.out.println("this is the filter list " + mainFilterList.toString());
scan.setFilter(mainFilterList);
return table.getScanner(scan);
}catch (IOException ex){
throw new BigTableGetException("Failed to get rows in BigTable", ex);
}
}

(我知道——forEach的无意义流!(

当只指定一个bm时,此操作正常,打印语句:

this is the filter list FilterList OR (1/1): [RowFilter (EQUAL, /bt=1/bm=B4.*)]

但是,如果指定了多个,则返回所有内容,打印语句:

this is the filter list FilterList OR (2/2): [RowFilter (EQUAL, /bt=1/bm=B4.*), RowFilter (EQUAL, /bt=1/bm=PP.*)]

事实上,如果我输入两个或多个"不正确"的bm值,它仍然会返回所有内容!

我已阅读:https://www.oreilly.com/library/view/hbase-the-definitive/9781449314682/ch04.html

我也试过移动bt=?过滤到一个单独的MUST_PASS_ALL过滤器,然后为bm=?

this is the filter list FilterList AND (2/2): [FilterList AND (1/1): [RowFilter (EQUAL, .*bt=1)], FilterList OR (2/2): [RowFilter (EQUAL, .*/bm=B4.*), RowFilter (EQUAL, .*/bm=PP.*)]]

同样的问题。

我一定错过了什么明显的东西,如果有任何帮助,我们将不胜感激。

hbase版本:

<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-1.x</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-1.x-hadoop</artifactId>
<version>1.4.0</version>
</dependency>

您是否考虑过使用单个正则表达式?"/bt=FOO/bm=(A|B|C|D(.*"应该有效。

此外,请在中提出一个问题https://github.com/GoogleCloudPlatform/cloud-bigtable-client.客户端代码中似乎确实有一个错误。

最新更新