Java 客户端:
public void scaneByPrefixFilter(String tablename, String rowPrifix) {
try {
HTable table = new HTable(conf, tablename);
Scan s = new Scan();
s.setFilter(new PrefixFilter(rowPrifix.getBytes()));
ResultScanner rs = table.getScanner(s);
for (Result r : rs) {
KeyValue[] kv = r.raw();
for (int i = 0; i < kv.length; i++) {
System.out.print(new String(kv[i].getRow()) + " ");
System.out.print(new String(kv[i].getFamily()) + ":");
System.out.print(new String(kv[i].getQualifier()) + " ");
System.out.print(kv[i].getTimestamp() + " ");
System.out.println(new String(kv[i].getValue()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}