/**
* 通过多条件联合查询
*
* @param tablename
* @param arr
* @return
* @throws IOException
*/
public List queryByFilter(String tablename, List arr)
throws IOException {
HTablePool hTablePool = HBaseUtil.getHTablePool();
HTableInterface hti = hTablePool.getTable(tablename);
FilterList filterList = new FilterList();
Scan s1 = new Scan();
for (String v : arr) {
String[] s = v.split(",");
SubstringComparator comp = new SubstringComparator(s[2]);
filterList.addFilter(new SingleColumnValueFilter(Bytes.toBytes(s[0]),
Bytes.toBytes(s[1]), CompareOp.EQUAL, comp));
/*
* filterList.addFilter(new SingleColumnValueFilter(Bytes
* .toBytes("familyName"), Bytes.toBytes("colName"), CompareOp.EQUAL,
* Bytes.toBytes("8010")));
*/
}
PageFilter pageFilter = new PageFilter(this.querySize);
filterList.addFilter(pageFilter);
s1.setFilter(filterList);
ResultScanner ResultScannerFilterList = hti.getScanner(s1);
SimpleDateFormat fmt = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss:SSS");
System.out.println("hbase 查询结束:" + fmt.format(new Date()));
List queryList = new ArrayList();
for (Result rr = ResultScannerFilterList.next(); rr != null; rr = ResultScannerFilterList
.next()) {
for (KeyValue kv : rr.list()) {
System.out.println("row : " + new String(kv.getRow()));
System.out.println("column : "
+ new String(kv.getKey(), "UTF-8"));
System.out.println("属性名: "
+ new String(kv.getQualifier(), "UTF-8"));
System.out.println("value : "
+ new String(kv.getValue(), "UTF-8"));
System.out.println("Family :" + new String(kv.getFamily())
+ ":");
System.out.println("Timestamp :"
+ String.valueOf(kv.getTimestamp()) + "");
}
}
queryList.add(getBean(rr, null));
}
return queryList;
}