• Hbase条件筛选


    需求来自于,模糊查找当天的所有记录,并查找对应列的记录数

    public static void main(String[] args) throws Exception{
    //创建HBase连接 Configuration conf
    = HBaseConfiguration.create();
    //设定需要查询的表 HTable table
    = new HTable(conf,"EVENT_LOG_LBS_HIS"); Scan scan = new Scan();
    //设定模糊时间戳 String startStr
    = "-20160530";
    //使用Hbase内置过滤器 scan.setFilter(findCount(startStr)); ResultScanner rowscan
    = table.getScanner(scan); int i = 1;
    //遍历结果
    for(Result rs : rowscan){ System.out.println("第" + i + "条: rowkey= " + Bytes.toString(rs.getRow())); i++;
    //根据结果行中某一列的值,进行条件筛选 String aaa
    = Bytes.toString(rs.getValue("f1".getBytes(),"LS_channel_type".getBytes())); if(aaa.equals("2"){ System.out.println(Bytes.toString(rs.getRow())); } } public static FilterList findCount(String startstr){ Filter filter = new RowFilter(CompareFilter.CompareOp.GREATER_OR_EQUAL,new RegexStringComparator(startstr)); return filter; }

     其实可以都写成内置过滤器,不过HBase还没有深入学习,暂时先这样写啦~

  • 相关阅读:
    【转】算法的时间复杂度
    FFT 物理意义(转)
    【转】FIR学习1
    【转】DFT DTFT DFS FFT的关系
    【转】TCL中的数组
    【转】setup time和hold time的周期问题(slack)
    【转】TCL语法简介
    【转】亚稳态分析
    ubuntu下Samba服务器搭建
    第一次生成uImage出现的问题解决
  • 原文地址:https://www.cnblogs.com/yangsy0915/p/5543403.html
Copyright © 2020-2023  润新知