有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

hadoop在java中实现hbase的compareFilter

我想在java中做类似的事情,就像我们在hbase中的comparefilter中做的那样

hbase(main):003:0> import org.apache.hadoop.hbase.filter.CompareFilter
hbase(main):005:0> import org.apache.hadoop.hbase.filter.SubstringComparator
hbase(main):006:0> scan 'CUTOFF21', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new("C11\x09143662"))}

共 (1) 个答案

  1. # 1 楼答案

    请参见以下来自hereBinaryComparatorRegexStringComparatorSubstringComparator示例

      Scan scan = new Scan();
        scan.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("col-1"));
    
        Filter filter1 = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL, 1
          new BinaryComparator(Bytes.toBytes("row-22")));
        scan.setFilter(filter1);
        ResultScanner scanner1 = table.getScanner(scan);
        for (Result res : scanner1) {
          System.out.println(res);
        }
        scanner1.close();
    
        Filter filter2 = new RowFilter(CompareFilter.CompareOp.EQUAL, 2
          new RegexStringComparator(".*-.5"));
        scan.setFilter(filter2);
        ResultScanner scanner2 = table.getScanner(scan);
        for (Result res : scanner2) {
          System.out.println(res);
        }
        scanner2.close();
    
        Filter filter3 = new RowFilter(CompareFilter.CompareOp.EQUAL, 3
          new SubstringComparator("-5"));
        scan.setFilter(filter3);
        ResultScanner scanner3 = table.getScanner(scan);
        for (Result res : scanner3) {
          System.out.println(res);
        }
        scanner3.close();
    

    你的案子是这样的

     Filter filter3 = new RowFilter(CompareFilter.CompareOp.EQUAL, 3
              new SubstringComparator("C11\x09143662"));
            scan.setFilter(filter3);
            ResultScanner scanner3 = table.getScanner(scan);
            for (Result res : scanner3) {
              System.out.println(res);
            }
            scanner3.close();