How to fetch latest N number of rows from Google BigTable Client [PHP]

Viewed 145

I need to paginate the data I fetch from my BigTable instance. I've tried applying filters and maxResults option but it fetches all the rows within the set range. Can I limit the read query to fetch last n records somehow?

I've tried following:

$bigtable = new BigtableClient($config);
      $table = $bigtable->table('engage', 'engage_dataplatform_' . ceil((int)$store->id / 10000.0));



      $filter = Filter::chain()
        ->addFilter(Filter::limit()->cellsPerColumn(1))
        ->addFilter(Filter::qualifier()->regex("(product_id|name|image_type|link|image|price|status|product_type|sku|average_rating|product_cost)"));

      $rows = $table->readRows([
        'filter' => $filter,
        'rowRanges' => [
          [
            'startKeyClosed' => 'products#'.$store->id.'#',
            'endKeyOpen' => 'products#'.((int)$store->id+1).'#'
          ],
        ],
        'maxResults' => 10,
        'startIndex' => 0,
      ]);
0 Answers
Related