Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

One of multiple HBase Filters being ignored

Highlighted

One of multiple HBase Filters being ignored

New Contributor

This is something that should be pretty straightforward that isn't working for some reason. I'm trying to query a table and return rows that match 2 filters. I'm getting a single result that matches one of the filters and doesn't have the other column in it.

I was expecting this code to return all rows where PersonAddressHash =

ba3d1874fee1d9076bde083d819c6a2165ec5790 AND PdfHash =

5151c1394a08a61cbd4d821914bbdca5fa333975dd413685bd1f6b086f555f3e, but its only matching on the PdfHash:

        Scan scan = new Scan();
        // Create filters and add them to scan object
        SingleColumnValueFilter filter1 = new SingleColumnValueFilter(
            Bytes.toBytes("data"), 
            Bytes.toBytes("PersonAddressHash"), 
            CompareOperator.EQUAL, 
            Bytes.toBytes("ba3d1874fee1d9076bde083d819c6a2165ec5790"));
        SingleColumnValueFilter filter2 = new SingleColumnValueFilter(
            Bytes.toBytes("data"), 
            Bytes.toBytes("PdfHash"), 
            CompareOperator.EQUAL, 
            Bytes.toBytes("5151c1394a08a61cbd4d821914bbdca5fa333975dd413685bd1f6b086f555f3e")
        FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
        filters.addFilter(filter1);
        filters.addFilter(filter2);
        scan.setFilter(filters);
        // Read the results into a JSON array, then print it to stdout
        ResultScanner scanner = table.getScanner(scan);
        JSONArray resultsJSON = new JSONArray();
        for (Result result : scanner) {
            JSONObject swap = new JSONObject();
            for (Cell cell : result.listCells()) {
                String qualifier = Bytes.toString(CellUtil.cloneQualifier(cell));
                String value = Bytes.toString(CellUtil.cloneValue(cell));
                swap.put(qualifier, value);
            }
            resultsJSON.put(swap);
        }
        System.out.print(resultsJSON.toString(4));
    }

I'm specifying FilterList.Operator.MUST_PASS_ALL yet its only passing one of the filters. My only guess is about the missing column perhaps? Not sure why this isn't working, help appreciated.