使用spring-hbaseTemplate过滤器

hbase过滤器的总结就不在这贴了,可以参考下面的链接,我这边把我工作时候用到的一些方法贴过来,主要使用到过滤器有:
1.FilterList 过滤器的集合,用于存放各种过滤器
2.RowFilter 行健正则过滤
3.PageFilter 分页过滤器,可以理解为过滤条数
4.设置开始的key和结束的key(也算是一种过滤吧)

    Scan scan = new Scan();
    scan.setStartRow(startKey.getBytes(encoding));// 开始的key
    scan.setStopRow(stopKey.getBytes(encoding));// 结束的key

详细的过滤器总结:http://blog.csdn.net/u012185296/article/details/47338549
以下是在spring-hbaseTemplate的基础上封装的代码:

HbaseService

package com.sinorail.srcloud.monitor.service.hbase;

import java.io.IOException;
import java.util.List;

import org.apache.hadoop.hbase.client.Result;

public interface HbaseService {
   
    /**
     * 查询全表的数据
     * @param tablename
     * @return
     */
    public List<Result> scaner(String tablename);
    /**
     * 根据rowKey查询单条记录
     * @param tableName
     * @param rowKey
     * @return
     */
    public Result getRow(String tableName, String rowKey); 
    /**
     * 根据regxKey正则匹配数据
     * @param tableName
     * @param regxKey
     * @return
     */
    public List<Result> getRegexRow(String tableName,String regxKey);
    /**
     * 根据regxKey正则匹配数据,取出num条
     * @param tableName
     * @param regxKey 
     * @param num
     * @return
     */
    public List<Result> getRegexRow(String tableName,String regxKey,int num);
    /**
     * 根据startKey和endKey的范围匹配数据
     * @param tableName
     * @param startKey
     * @param stopKey
     * @return
     */
    public List<Result> getStartRowAndEndRow(String tableName, String startKey, String stopKey);
    /**
     * 确定startKey和endKey的范围,根据regKey匹配数据
     * @param tableName
     * @param startKey
     * @param stopKey
     * @param regxKey
     * @return
     */
    public List<Result> getRegexRow(String tableName, String startKey, String stopKey, String regxKey);
    /**
     * 确定startKey和endKey的范围,根据regKey匹配数据,取出num条
     * @param tableName
     * @param startKey
     * @param stopKey
     * @param regxKey
     * @param num
     * @return
     */
    public List<Result> getRegexRow(String tableName, String startKey, String stopKey, String regxKey,int num);
    /**
     * 添加数据
     * @param rowKey
     * @param tableName
     * @param column
     * @param value
     */
    public void addData(String rowKey, String tableName, String[] column, String[] value);
    /**
     * 删除记录
     * @param tableName
     * @param rowKeys
     */
    public void delRecord(String tableName, String... rowKeys);
    /**
     * 修改一条数据
     * @param tableName
     * @param rowKey
     * @param familyName
     * @param column
     * @param value
     * @throws IOException
     */
    public void updateTable(String tableName, String rowKey,String familyName, String column[], String value[]) throws IOException;
    /**
     * 查找最新的一条数据,或者说倒序查询
     * @param tableName
     * @return
     */
    public Result getNewRow(String tableName);
    /**
     * 正则查出所有匹配的key
     * @param tableName
     * @param regxKey
     * @return
     */
    public List<String> queryKeys(String tableName,String regxKey);
    /**
     * 增加表中对应字段的值
     * @param tableName
     * @param cf
     * @param rowKey
     * @param column
     * @param num
     * @return
     */
    long incrQualifier(String tableName, String cf, String rowKey, String column, long num);
    Result getNewRow(String tableName, String regxKey);

}

HbaseServiceImpl


                
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值