From 7a11571e7f8170e5496c53fa738f2ce478c2d5db Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 24 Aug 2022 11:44:19 -0700 Subject: [PATCH] Update BigTable apis to respect a limit of zero (#27380) Update apis to respect a limit of zero --- storage-bigtable/src/bigtable.rs | 13 +++++++++---- storage-bigtable/src/lib.rs | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/storage-bigtable/src/bigtable.rs b/storage-bigtable/src/bigtable.rs index 52b2033b3..ac2de0ee4 100644 --- a/storage-bigtable/src/bigtable.rs +++ b/storage-bigtable/src/bigtable.rs @@ -404,7 +404,7 @@ impl) -> InterceptedRequestResult> BigTable { /// /// If `end_at` is provided, the row key listing will end at the key. Otherwise it will /// continue until the `rows_limit` is reached or the end of the table, whichever comes first. - /// If `rows_limit` is zero, the listing will continue until the end of the table. + /// If `rows_limit` is zero, this method will return an empty array. pub async fn get_row_keys( &mut self, table_name: &str, @@ -412,6 +412,9 @@ impl) -> InterceptedRequestResult> BigTable { end_at: Option, rows_limit: i64, ) -> Result> { + if rows_limit == 0 { + return Ok(vec![]); + } self.refresh_access_token().await; let response = self .client @@ -466,7 +469,7 @@ impl) -> InterceptedRequestResult> BigTable { /// /// If `end_at` is provided, the row key listing will end at the key. Otherwise it will /// continue until the `rows_limit` is reached or the end of the table, whichever comes first. - /// If `rows_limit` is zero, the listing will continue until the end of the table. + /// If `rows_limit` is zero, this method will return an empty array. pub async fn get_row_data( &mut self, table_name: &str, @@ -474,8 +477,10 @@ impl) -> InterceptedRequestResult> BigTable { end_at: Option, rows_limit: i64, ) -> Result> { + if rows_limit == 0 { + return Ok(vec![]); + } self.refresh_access_token().await; - let response = self .client .read_rows(ReadRowsRequest { @@ -516,7 +521,7 @@ impl) -> InterceptedRequestResult> BigTable { .read_rows(ReadRowsRequest { table_name: format!("{}{}", self.table_prefix, table_name), app_profile_id: self.app_profile_id.clone(), - rows_limit: 0, // return all keys + rows_limit: 0, // return all existing rows rows: Some(RowSet { row_keys: row_keys .iter() diff --git a/storage-bigtable/src/lib.rs b/storage-bigtable/src/lib.rs index 4e1cb401d..b644509b7 100644 --- a/storage-bigtable/src/lib.rs +++ b/storage-bigtable/src/lib.rs @@ -460,8 +460,7 @@ impl LedgerStorage { /// Fetch the next slots after the provided slot that contains a block /// /// start_slot: slot to start the search from (inclusive) - /// limit: stop after this many slots have been found; if limit==0, all records in the table - /// after start_slot will be read + /// limit: stop after this many slots have been found pub async fn get_confirmed_blocks(&self, start_slot: Slot, limit: usize) -> Result> { debug!( "LedgerStorage::get_confirmed_blocks request received: {:?} {:?}",