将多前缀行过滤器设置为扫描仪 hbase java
Set Multiple prefix row filter to scanner hbase java
我想创建一个扫描器,它会给我带有 2 个前缀过滤器的结果
例如,我希望所有行的键以字符串 "x" 开头或以字符串 "y".
开头
目前我知道只能通过以下方式使用一个前缀来做到这一点:
scan.setRowPrefixFilter(prefixFiltet)
我刚刚尝试过,但您似乎无法将正则表达式添加到 RowPrefixFilter,所以我想解决方案是使用
发出两个请求
scan.setRowPrefixFilter("x")
scan.setRowPrefixFilter("y")
这将为您提供所需的行。
在这种情况下,您不能使用 setRowPrefixFilter
API,您必须使用更通用的 setFilter
API,例如:
scan.setFilter(
new FilterList(
FilterList.Operator.MUST_PASS_ONE,
new PrefixFilter('xx'),
new PrefixFilter('yy')
)
);
我已经实现了一个批量集前缀过滤器,也许可以帮到你
List<String> bindCodes = new ArrayList<>();
bindCodes.add("CM0001");
bindCodes.add("CE7563");
bindCodes.add("DR6785");
Scan scan = new Scan();
scan.setCaching(50);//set get batch numbers
//set Column
scan.addColumn(HTableColumnEnum.GPS_CF_1.getCfName().getBytes(), LOCATION_CREATE_DATE_ARRAY);
//set Family
scan.addFamily(HTableColumnEnum.GPS_CF_1.getCfName().getBytes());
//create filterList
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
//put mulit prefix row key
bindCodes.forEach(s -> {
filterList.addFilter(new PrefixFilter(Bytes.toBytes(s)));
});
//set filterList to scan
scan.setFilter(filterList);
我想创建一个扫描器,它会给我带有 2 个前缀过滤器的结果
例如,我希望所有行的键以字符串 "x" 开头或以字符串 "y".
开头
目前我知道只能通过以下方式使用一个前缀来做到这一点:
scan.setRowPrefixFilter(prefixFiltet)
我刚刚尝试过,但您似乎无法将正则表达式添加到 RowPrefixFilter,所以我想解决方案是使用
发出两个请求scan.setRowPrefixFilter("x")
scan.setRowPrefixFilter("y")
这将为您提供所需的行。
在这种情况下,您不能使用 setRowPrefixFilter
API,您必须使用更通用的 setFilter
API,例如:
scan.setFilter(
new FilterList(
FilterList.Operator.MUST_PASS_ONE,
new PrefixFilter('xx'),
new PrefixFilter('yy')
)
);
我已经实现了一个批量集前缀过滤器,也许可以帮到你
List<String> bindCodes = new ArrayList<>();
bindCodes.add("CM0001");
bindCodes.add("CE7563");
bindCodes.add("DR6785");
Scan scan = new Scan();
scan.setCaching(50);//set get batch numbers
//set Column
scan.addColumn(HTableColumnEnum.GPS_CF_1.getCfName().getBytes(), LOCATION_CREATE_DATE_ARRAY);
//set Family
scan.addFamily(HTableColumnEnum.GPS_CF_1.getCfName().getBytes());
//create filterList
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
//put mulit prefix row key
bindCodes.forEach(s -> {
filterList.addFilter(new PrefixFilter(Bytes.toBytes(s)));
});
//set filterList to scan
scan.setFilter(filterList);