Bigtable Scan.setReversed() not working in version 1.2.1?

844 views Asked by At

I am using JAVA API to scan Bigtable by partial row-key, both backward and forward. This code works well, but ONLY forward:

    Scan s = new Scan();
    s.setReversed(true);    
    s.setStartRow(rowKey);          
    s.setStopRow(rowKeyEnd); 
    ResultScanner scanner = tbl.getScanner(s);
    for (Result row : scanner)
    {   
        String rk = new String(row.getRow());
        System.out.println("Row: " + rk);
    }

It seems like the line .setReversed(true); does not have any impact on its own, regardless of whether I set it before or after setting the start and end row-keys. If I switch start and end row keys in .setStartRow() and .setStopRow(), then I get an Exception in the iteration code (Result row : scanner):
Caused by: com.google.bigtable.repackaged.io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Error in field 'row_ranges' : Error in element #0 : start_key must be less than end_key

As I understand from this discussion when reversing a Scan in HBase, which is the startKey and which is the stopKey?, the Reverse Scan doesn't work in versions below 0.98, but I see my server-side version as 1.2.1 in Google Cloud Console:

hbase(main):023:0> version 1.2.1, r8d8a7107dc4ccbf36a92f64675dc60392f85c015, Wed Mar 30 11:29:35 CDT 2016

Also, my client-side JAR is bigtable-hbase-1.2-0.9.4.jar

My row-keys are formatted in the following fashion, as a test:
John*1*XXX
John*2*XXX
John*3*XXX

Is there a better way to get this done please?

2

There are 2 answers

1
Solomon Duskis On BEST ANSWER

Unfortunately, Bigtable does not support reverse scanning. The HBase API mostly lines up with Cloud Bigtable, but not all. You found one of the missing features in Bigtable.

0
gnvk On

Reverse scans are now available in Preview.