Question about using page filter in bigtable scan with startrow

80 views
Skip to first unread message

Zhihua Wen

unread,
May 13, 2019, 4:32:01 PM5/13/19
to Google Cloud Bigtable Discuss
I just want to confirm whether bitable always return the least row with rowkey >= startRow if I set the page filter limit to 1.

I understand setting the page filter limit to 1 may still return more than 1 results because the scan limit was applied separately on each server. 

But if I sort the results and return the row  with the least row key, will it guarantee to be the global minimal rowkey >= startKey?

My example code is as below where I use time stamp as end of the row key after a prefix and I set limit to 1, I print out the min row in the results if it is available.

From my experiment, it seems it is true that it always return the row with min row key satisfying the scan condition. But I just want to confirm it, otherwise we may need to always scan the table without a page limit.



        long ts = 1556953200000L;
        String startRow =  ROWKEY_PREFIX + ts;

        try (Connection connection = BigtableConfiguration.connect(config)) {
            final Scan scan = new Scan();
            final TableName tableName = TableName.valueOf(TABLE_NAME);
            try (Table table = connection.getTable(tableName)) {
                scan.withStartRow(Bytes.toBytes(startRow));
                scan.setFilter(new PageFilter(1));
                final ResultScanner resultScanner = table.getScanner(scan);
                Optional<Result> optional = Lists.newArrayList(resultScanner)
                        .stream()
                        .min(Comparator.comparing(result -> Bytes.toString(result.getRow())));
                optional.ifPresent(result -> {
                    System.out.println(Bytes.toString(result.getRow()));
                });
            }
        }

Reply all
Reply to author
Forward
0 new messages