HBase的分页实现相对复杂一些。核心思想是结合分页过滤器PageFilter(pageSize)和查询设置开始行scan.setStartRow(lastRow),lastRow为上一次查询rowkey,需要注意的是该rowkey是一个数组,对应多字段的存储位置;

不同用户登录会产生不同lastRow,因此我们把lastRow存储到session中,参考PageLastRowCache

      为了解耦,我们又把对lastRow操作封装到HBaseDaoImpl,以便开发写代码的时候不需要关心lastRow的操作。

public PageInfo searchXControl(QueryControlRuleQO qo,IntegerpageSize,Integer currteIndex) throwsException {

       //条件过滤器

       FilterList filterList = new QueryControlRuleFilterList(qo).getFilterList();

       //获得符合条件结果总数

       Long total = getTotal(controlTableName, filterList);

       //过滤器集合

       FilterList fl=new FilterList();

       //分页过滤器

       Filterfilter = new PageFilter(pageSize);

       fl.addFilter(filterList);

       fl.addFilter(filter);

        //封装结果集

       List<XControl> list = getList(XControl.classcontrolTableName, fl, currteIndex);

      

        log.info("--------------------- total : " + list.size());

        //返回结果集

      PageInfo page = new PageInfo(total, list);

        return page;

    }


更多精彩内容请关注:http://bbs.superwu.cn

关注超人学院微信二维码:hbase列表分页

关注超人学院java免费学习交流群:hbase列表分页

转载于:https://my.oschina.net/crxy/blog/424356

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2021-12-12
  • 2021-12-12
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案