Skip to content

Commit

Permalink
Update BigTable apis to respect a limit of zero (solana-labs#27380)
Browse files Browse the repository at this point in the history
Update apis to respect a limit of zero
  • Loading branch information
Tyera Eulberg authored Aug 24, 2022
1 parent 5975176 commit 7a11571
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 9 additions & 4 deletions storage-bigtable/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,17 @@ impl<F: FnMut(Request<()>) -> InterceptedRequestResult> BigTable<F> {
///
/// 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,
start_at: Option<RowKey>,
end_at: Option<RowKey>,
rows_limit: i64,
) -> Result<Vec<RowKey>> {
if rows_limit == 0 {
return Ok(vec![]);
}
self.refresh_access_token().await;
let response = self
.client
Expand Down Expand Up @@ -466,16 +469,18 @@ impl<F: FnMut(Request<()>) -> InterceptedRequestResult> BigTable<F> {
///
/// 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,
start_at: Option<RowKey>,
end_at: Option<RowKey>,
rows_limit: i64,
) -> Result<Vec<(RowKey, RowData)>> {
if rows_limit == 0 {
return Ok(vec![]);
}
self.refresh_access_token().await;

let response = self
.client
.read_rows(ReadRowsRequest {
Expand Down Expand Up @@ -516,7 +521,7 @@ impl<F: FnMut(Request<()>) -> InterceptedRequestResult> BigTable<F> {
.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()
Expand Down
3 changes: 1 addition & 2 deletions storage-bigtable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Slot>> {
debug!(
"LedgerStorage::get_confirmed_blocks request received: {:?} {:?}",
Expand Down

0 comments on commit 7a11571

Please sign in to comment.