码迷,mamicode.com
首页 > 其他好文 > 详细

hbase列表分页

时间:2015-06-03 17:46:39      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:hadoop   超人学院   hbase   


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
关注超人学院微信二维码:技术分享
关注超人学院java免费学习交流群:技术分享

hbase列表分页

标签:hadoop   超人学院   hbase   

原文地址:http://blog.csdn.net/crxy2014/article/details/46347133

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!