1.值过滤器:
private static void scanByValueFilte(Table hTable) throws IOException {
Scan scan = new Scan();
SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes ("communityIndex" ),Bytes.toBytes( "communitykey" ), CompareOp.EQUAL, Bytes.toBytes ("2917458ddc43db275225dc9207ff953c"));
scan.setFilter(filter);
ResultScanner scanner = hTable.getScanner(scan);
for (Result result : scanner) {
String rowKeyValue=new String(result.getRow());
for (Cell cellInfo : result.rawCells()) {
String familyInfo=new String(CellUtil.cloneFamily(cellInfo));
String valueInfo=new String(CellUtil.cloneValue(cellInfo ));
String columnInfo=new String(CellUtil.cloneQualifier(cellInfo));
log.info(rowKeyValue+">>"+"列族info:"+familyInfo+" >>列info:"+columnInfo+" >>值info:"+valueInfo);
}
}
}
结果:
2.列过滤器:
public void getInfoByScannerFilter(Table hTable) throws Exception{
Scan scan = new Scan();
Filter filter2 = new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("api_tag")));
scan.setFilter(filter2);
ResultScanner scanner = hTable.getScanner(scan);
for (Result result : scanner) {
String rowKeyValue=new String(result.getRow());
for (Cell cellInfo : result.rawCells()) {
String familyInfo=new String(CellUtil.cloneFamily(cellInfo));
String valueInfo=new String(CellUtil.cloneValue(cellInfo ));
String columnInfo=new String(CellUtil.cloneQualifier(cellInfo));
log.info(rowKeyValue+">>"+"列族info:"+familyInfo+" >>列info:"+columnInfo+" >>值info:"+valueInfo);
}
}
}
结果: