java - Hbase FilterList as 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中提出问题。客户端代码中的某处似乎确实存在错误。
推荐阅读
- java - 如何模拟其对象在测试方法之外初始化的方法?
- python - 如果在以太坊地址中发现任何余额,我该如何设置停止?
- javascript - 为映射的对象元素赋予不同的样式
- python - 使用 Scapy 解析 pcap 文件中的 Modbus 数据包
- echarts - 根据数据更改 barWidth
- java - E/AndroidRuntime:致命异常:grpc-default-executor-0 PID:10113
- python - 遍历对象数组 - Python 哈希表
- javascript - 如何在 React js 中的 select 输入值中传递 html 标签?
- sql - How to use count "how many times a particular customer made inquiries"?
- javascript - 将普通 JSON 对象转换为类似文件夹的结构的逻辑