HBase表数据分页处理(4)

/**
 * 检索指定表的第一行记录。<br>
 * (如果在创建表时为此表指定了非默认的命名空间,则需拼写上命名空间名称,格式为【namespace:tablename】)。
 * @param tableName 表名称(*)。
 * @param filterList 过滤器集合,可以为null。
 * @return
 */
public static Result selectFirstResultRow(String tableName,FilterList filterList) {
    if(StringUtils.isBlank(tableName)) return null;
    HTable table = null;
    try {
        table = HBaseTableManageUtil.getHBaseTable(tableName);
        Scan scan = new Scan();
        if(filterList != null) {
            scan.setFilter(filterList);
        }
        ResultScanner scanner = table.getScanner(scan);
        Iterator<Result> iterator = scanner.iterator();
        int index = 0;
        while(iterator.hasNext()) {
            Result rs = iterator.next();
            if(index == 0) {
                scanner.close();
                return rs;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            table.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}

3、HBase表数据分页检索应用实例

HBasePageModel pageModel = new HBasePageModel(pageSize);
pageModel = scanResultByPageFilter(“DLQX:SZYB_DATA”,null,null,null,pageModel);
if(pageModel.getResultList().size() == 0) {
    //本页没有数据,说明已经是最后一页了。
    return;
}

Hadoop+HBase搭建云存储总结 PDF

HBase 结点之间时间不一致造成regionserver启动失败

Hadoop+ZooKeeper+HBase集群配置

Hadoop集群安装&HBase实验环境搭建

基于Hadoop集群的HBase集群的配置

Hadoop安装部署笔记之-HBase完全分布模式安装

单机版搭建HBase环境图文教程详解

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f162c0d2aa44dbd03be32cc188eec853.html