From 7f766255eedd799a5cb298edc6526451245cae87 Mon Sep 17 00:00:00 2001 From: Piotr Dulikowski Date: Thu, 16 Feb 2023 17:56:41 +0100 Subject: [PATCH] connection: remove query_all Now that we got rid of all uses of query_all in the code, we can finally get rid of it and of all the other code that depended on it - most notably, QueryResult::merge_with_next_page_res for which it won't be possible to translate it to the upcoming iterator-based deserialization interface. --- scylla/src/transport/connection.rs | 65 +--------------------------- scylla/src/transport/query_result.rs | 17 -------- 2 files changed, 1 insertion(+), 81 deletions(-) diff --git a/scylla/src/transport/connection.rs b/scylla/src/transport/connection.rs index 9f91c7a6b5..97b3821058 100644 --- a/scylla/src/transport/connection.rs +++ b/scylla/src/transport/connection.rs @@ -29,7 +29,7 @@ use std::{ net::{Ipv4Addr, Ipv6Addr}, }; -use super::errors::{BadKeyspaceName, BadQuery, DbError, QueryError}; +use super::errors::{BadKeyspaceName, DbError, QueryError}; use super::iterator::RowIterator; use crate::batch::{Batch, BatchStatement}; @@ -458,69 +458,6 @@ impl Connection { .await } - /// Performs query_single_page multiple times to query all available pages - pub async fn query_all( - &self, - query: &Query, - values: impl ValueList, - ) -> Result { - // This method is used only for driver internal queries, so no need to consult execution profile here. - self.query_all_with_consistency( - query, - values, - query - .config - .determine_consistency(self.config.default_consistency), - query.get_serial_consistency(), - ) - .await - } - - pub async fn query_all_with_consistency( - &self, - query: &Query, - values: impl ValueList, - consistency: Consistency, - serial_consistency: Option, - ) -> Result { - if query.get_page_size().is_none() { - // Page size should be set when someone wants to use paging - return Err(QueryError::BadQuery(BadQuery::Other( - "Called Connection::query_all without page size set!".to_string(), - ))); - } - - let mut final_result = QueryResult::default(); - - let serialized_values = values.serialized()?; - let mut paging_state: Option = None; - - loop { - // Send next paged query - let mut cur_result: QueryResult = self - .query_with_consistency( - query, - &serialized_values, - consistency, - serial_consistency, - paging_state, - ) - .await? - .into_query_result()?; - - // Set paging_state for the next query - paging_state = cur_result.paging_state.take(); - - // Add current query results to the final_result - final_result.merge_with_next_page_res(cur_result); - - if paging_state.is_none() { - // No more pages to query, we can return the final result - return Ok(final_result); - } - } - } - pub async fn execute_with_consistency( &self, prepared_statement: &PreparedStatement, diff --git a/scylla/src/transport/query_result.rs b/scylla/src/transport/query_result.rs index 426553cbaf..ca861e787b 100644 --- a/scylla/src/transport/query_result.rs +++ b/scylla/src/transport/query_result.rs @@ -131,23 +131,6 @@ impl QueryResult { .enumerate() .find(|(_id, spec)| spec.name == name) } - - /// This function is used to merge results of multiple paged queries into one.\ - /// other is the result of a new paged query.\ - /// It is merged with current result kept in self.\ - pub(crate) fn merge_with_next_page_res(&mut self, other: QueryResult) { - if let Some(other_rows) = other.rows { - match &mut self.rows { - Some(self_rows) => self_rows.extend(other_rows), - None => self.rows = Some(other_rows), - } - }; - - self.warnings.extend(other.warnings); - self.tracing_id = other.tracing_id; - self.paging_state = other.paging_state; - self.col_specs = other.col_specs; - } } /// [`QueryResult::rows()`](QueryResult::rows) or a similar function called on a bad QueryResult.\