2017-02-22 2 views

Antwort

1

Wenn Sie nicht AAAA haben als feste, können Sie wie folgt tun:

FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE); 
String[] matches=new String[]{"AAAA","BBBB"}; 
    for (String match:matches) { 
     byte[] rk = Bytes.toBytesBinary("??" + match + "??????????????"); 
     byte[] fuzzyVal = new byte[]{1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 
     List<Pair<byte[], byte[]>> pairs = new ArrayList<>(); 
     pairs.add(new Pair<>(rk, fuzzyVal)); 
     filterList.addFilter(new FuzzyRowFilter(pairs)); 
    } 
Scan scan=new Scan(); 
    scan.setFilter(filterList); 

Dieser filtert basierend auf allen fuzzyFilters in der Liste und Spiel basiert auf FilterList.Operator.MUST_PASS_ONE. Gehen Sie entsprechend Ihren Anforderungen vor und ändern Sie sie entsprechend.

0

Sorry, aber unter Verwendung

FilterList filterList = new FilterList(/*FilterList.Operator.MUST_PASS_ONE*/); 
    String[] matches=new String[]{"1609","1610"}; 
     for (String match:matches) { 
      byte[] rk = Bytes.toBytesBinary("??" + match + "??????????????"); 
      byte[] fuzzyVal = new byte[]{1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 
      List<Pair<byte[], byte[]>> pairs = new ArrayList<>(); 
      pairs.add(new Pair<>(rk, fuzzyVal)); 
      filterList.addFilter(new FuzzyRowFilter(pairs)); 
     } 
    Scan scan_fuzzy=new Scan(); 
    scan_fuzzy.setFilter(filterList); 

    ResultScanner rs_fuzzy = table.getScanner(scan); 

    for(Result result : rs_fuzzy) { 
     System.out.println(result); 
     System.out.println("Value: " + Bytes.toString(result.getValue(FAMILY,COLUMN))); 
    } 

mein Ergebnis enthält nicht nur die Zeile an den RowKey entsprechen: 02160901222720647002

aber die ganze Reihe (und die RowKey) von meinem Tisch