hbase通过row key 的前缀查询记录

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();
   }
}
上一篇:android 服务器json


下一篇:OS X 平台的 8 个实用终端工具