Hbase Filter之PrefixFilter

 PrefixFilter

      PrefixFilter是将rowkey前缀为指定字符串的数据全部过滤出来并返回给用户。例如:

Scan scan = new Scan();
scan.setFilter(new PrefixFilter(Bytes.toBytes("def")));

  但是hbase的PrefixFilter比较粗暴,并没有根据filter做过多的查询优化。上述代码会scan整个区间的数据,得到一条数据就判断其是否符合前缀条件,不符合就读吓一条,直到找到前缀为def的数据。因此,我们可以指定一下startkey。

Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes("def")); scan.setFilter(new PrefixFilter(Bytes.toBytes("def"))); 
原文地址:https://www.cnblogs.com/Evil-Rebe/p/11691936.html