-
SingleColumnValueFilter
使用场景:过滤某列值大于多少小于多少
此处有坑,当匹配不到的时候就默认全部输出
解决办法:
filter.setFilterIfMissing(false);
List<Filter> filters = new ArrayList<Filter>();
filters.add( new SingleColumnValueFilter(Bytes.toBytes("pinfo"), //列族
Bytes.toBytes("t"), //列名
CompareOp.GREATER,Bytes.toBytes("1359901")) //值
filters.add( new SingleColumnValueFilter(Bytes.toBytes("pinfo"),
Bytes.toBytes("t"),
CompareOp.LESS,Bytes.toBytes("1389901"))
FilterList filterList1 = new FilterList(Operator.MUST_PASS_ALL,filters);
sn.setFilter(filterList1);
-
RowFilter
使用场景:Rowkey中包括某些字符串
for (int a=0;a<size;a++)
{
//Filter filter2 = new RowFilter(CompareOp.EQUAL,
// new RegexStringComparator(".*"+maclist.get(a)+"$"));
Filter filter2 = new RowFilter(CompareOp.EQUAL,
new SubstringComparator(maclist.get(a)));
filters.add(filter2);
}
FilterList filterList1 = new FilterList(Operator.MUST_PASS_ONE,filters);
sn.setFilter(filterList1);
-
ValueFilter
使用场景:不需要指定某个列,含指某个值的列的数据都取出来
Scan scan = new Scan();
System.out.println("只列出值包含data1的列");
Filter filter1 = new ValueFilter(CompareFilter.CompareOp.EQUAL,
new SubstringComparator("data1"));
scan.setFilter(filter1);
网友评论