HBase FuzzyRowFilter不';行不通
我有一个由20个字符组成的行键,如下所示: XXXXAAXXXXXXXXXXXXXHBase FuzzyRowFilter不';行不通,filter,hbase,Filter,Hbase,我有一个由20个字符组成的行键,如下所示: XXXXAAXXXXXXXXXXXXX 我想使用FuzzyRowFilter扫描2到6位置上的AA值。但是AA不是固定值。如果AAAA不是固定值,可以这样做: FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE); String[] matches=new String[]{"AAAA","BBBB"}; for (String match:match
我想使用
FuzzyRowFilter
扫描2到6位置上的AA值。但是AA
不是固定值。如果AAAA不是固定值,可以这样做:
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
String[] matches=new String[]{"AAAA","BBBB"};
for (String match:matches) {
byte[] rk = Bytes.toBytesBinary("??" + match + "??????????????");
byte[] fuzzyVal = new byte[]{1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
List<Pair<byte[], byte[]>> pairs = new ArrayList<>();
pairs.add(new Pair<>(rk, fuzzyVal));
filterList.addFilter(new FuzzyRowFilter(pairs));
}
Scan scan=new Scan();
scan.setFilter(filterList);
FilterList FilterList=new FilterList(FilterList.Operator.MUST\u PASS\u ONE);
字符串[]匹配=新字符串[]{“AAAA”,“BBBB”};
for(字符串匹配:匹配){
byte[]rk=Bytes.tobytes二进制(“??”+匹配+”);
byte[]fuzzyVal=新字节[]{1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
列表对=新的ArrayList();
添加(新对(rk,fuzzyVal));
addFilter(新的FuzzyRowFilter(对));
}
扫描=新扫描();
scan.setFilter(过滤器列表);
这将基于列表中的所有FuzzyFilter进行筛选,并基于FilterList.Operator.MUST\u PASS\u ONE进行匹配。
根据您的要求,进行相应的修改。抱歉,请使用
FilterList filterList = new FilterList(/*FilterList.Operator.MUST_PASS_ONE*/);
String[] matches=new String[]{"1609","1610"};
for (String match:matches) {
byte[] rk = Bytes.toBytesBinary("??" + match + "??????????????");
byte[] fuzzyVal = new byte[]{1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
List<Pair<byte[], byte[]>> pairs = new ArrayList<>();
pairs.add(new Pair<>(rk, fuzzyVal));
filterList.addFilter(new FuzzyRowFilter(pairs));
}
Scan scan_fuzzy=new Scan();
scan_fuzzy.setFilter(filterList);
ResultScanner rs_fuzzy = table.getScanner(scan);
for( Result result : rs_fuzzy) {
System.out.println(result);
System.out.println("Value: " + Bytes.toString(result.getValue(FAMILY,COLUMN)));
}
FilterList FilterList=new FilterList(/*FilterList.Operator.MUST_PASS_ONE*/);
字符串[]匹配=新字符串[]{“1609”,“1610”};
for(字符串匹配:匹配){
byte[]rk=Bytes.tobytes二进制(“??”+匹配+”);
byte[]fuzzyVal=新字节[]{1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
列表对=新的ArrayList();
添加(新对(rk,fuzzyVal));
addFilter(新的FuzzyRowFilter(对));
}
扫描扫描_fuzzy=新扫描();
扫描模糊设置过滤器(过滤器列表);
ResultScanner r r_fuzzy=table.getScanner(扫描);
用于(结果:rs_模糊){
系统输出打印项次(结果);
System.out.println(“Value:+Bytes.toString(result.getValue(FAMILY,COLUMN)));
}
我的结果不仅仅包含与rowkey:02160901222720647002对应的行
但是我桌子上的所有行(和行键)