我无法在hbase中筛选数据

3mpgtkmj  于 2021-06-03  发布在  Hadoop
关注(0)|答案(0)|浏览(247)

我正在尝试从hbase中筛选一些数据它是一个measuretimestamp作为字符串。过滤值超出我的过滤范围;这是我的密码:

try {
    FilterList filters = new FilterList();

    Filter filter = new SingleColumnValueFilter(
        Bytes.toBytes("measure"), 
        Bytes.toBytes("measureTimestamp"), 
        CompareOp.GREATER_OR_EQUAL, 
        Bytes.toBytes("0000000100")); // ??column1???aaa?????
    filters.addFilter(filter);

    Filter filter1 = new SingleColumnValueFilter(
        Bytes.toBytes("measure"), 
        Bytes.toBytes("measureTimestamp"), 
        CompareOp.LESS_OR_EQUAL, 
        Bytes.toBytes("0000015000"));
    filters.addFilter(filter1);

    Filter filter2 = new SingleColumnValueFilter(
        Bytes.toBytes("measure"), 
        Bytes.toBytes("captor_id"), 
        CompareOp.EQUAL, 
        new BinaryComparator(Bytes.toBytes("2")));
    filters.addFilter(filter2);

    Scan scan = new Scan();
    scan.setFilter(filters);
    rs = table.getScanner(scan);
    for (Result r: rs) {
        System.out.println("Cle Ligne :" + new String(r.getRow()));
        for (KeyValue keyValue: r.raw()) {
            System.out.println("-" + new String(keyValue.getQualifier()) + " = : " + new String(keyValue.getValue()));
        }
    }
    rs.close();

} catch (IOException e) {
    e.printStackTrace();
}

谁能帮我一下吗。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题