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"))); 

 

相关文章:

  • 2020-05-10
  • 2020-05-13
  • 2020-05-20
  • 2022-01-17
  • 2021-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-06
  • 2022-12-23
  • 2021-06-07
  • 2021-05-01
  • 2022-01-24
  • 2022-12-23
  • 2020-05-04
相关资源
相似解决方案