Skip to content

Commit

Permalink
treewide: adjust docstrings and variable names to statement terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
muzarski committed Feb 17, 2025
1 parent 9e56b3a commit 61124fd
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 136 deletions.
36 changes: 18 additions & 18 deletions scylla/src/client/execution_profile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `ExecutionProfile` is a grouping of configurable options regarding query execution.
//! `ExecutionProfile` is a grouping of configurable options regarding CQL statement execution.
//!
//! Profiles can be created to represent different workloads, which thanks to them
//! can be run conveniently on a single session.
Expand Down Expand Up @@ -38,12 +38,12 @@
//! ```
//!
//! ### Example
//! To create an `ExecutionProfile` and attach it to a `Query`:
//! To create an [`ExecutionProfile`] and attach it to a [`Statement`](crate::statement::Statement):
//! ```
//! # extern crate scylla;
//! # use std::error::Error;
//! # async fn check_only_compiles() -> Result<(), Box<dyn Error>> {
//! use scylla::query::Query;
//! use scylla::statement::Statement;
//! use scylla::statement::Consistency;
//! use scylla::client::execution_profile::ExecutionProfile;
//! use std::time::Duration;
Expand All @@ -55,10 +55,10 @@
//!
//! let handle = profile.into_handle();
//!
//! let mut query1 = Query::from("SELECT * FROM ks.table");
//! let mut query1 = Statement::from("SELECT * FROM ks.table");
//! query1.set_execution_profile_handle(Some(handle.clone()));
//!
//! let mut query2 = Query::from("SELECT pk FROM ks.table WHERE pk = ?");
//! let mut query2 = Statement::from("SELECT pk FROM ks.table WHERE pk = ?");
//! query2.set_execution_profile_handle(Some(handle));
//! # Ok(())
//! # }
Expand All @@ -82,7 +82,7 @@
//! let profile = base_profile.to_builder()
//! .consistency(Consistency::All)
//! .build();
//
//!
//! # Ok(())
//! # }
//! ```
Expand Down Expand Up @@ -112,7 +112,7 @@
//! # async fn check_only_compiles() -> Result<(), Box<dyn Error>> {
//! use scylla::client::session::Session;
//! use scylla::client::session_builder::SessionBuilder;
//! use scylla::query::Query;
//! use scylla::statement::Statement;
//! use scylla::statement::Consistency;
//! use scylla::client::execution_profile::ExecutionProfile;
//!
Expand All @@ -133,8 +133,8 @@
//! .build()
//! .await?;
//!
//! let mut query1 = Query::from("SELECT * FROM ks.table");
//! let mut query2 = Query::from("SELECT pk FROM ks.table WHERE pk = ?");
//! let mut query1 = Statement::from("SELECT * FROM ks.table");
//! let mut query2 = Statement::from("SELECT pk FROM ks.table WHERE pk = ?");
//!
//! query1.set_execution_profile_handle(Some(handle1.clone()));
//! query2.set_execution_profile_handle(Some(handle2.clone()));
Expand Down Expand Up @@ -259,16 +259,16 @@ impl ExecutionProfileBuilder {
self
}

/// Specify a default consistency to be used for queries.
/// Specify a default consistency to be used for statement executions.
/// It's possible to override it by explicitly setting a consistency on the chosen query.
pub fn consistency(mut self, consistency: Consistency) -> Self {
self.consistency = Some(consistency);
self
}

/// Specify a default serial consistency to be used for queries.
/// Specify a default serial consistency to be used for statement executions.
/// It's possible to override it by explicitly setting a serial consistency
/// on the chosen query.
/// on the chosen statement.
pub fn serial_consistency(mut self, serial_consistency: Option<SerialConsistency>) -> Self {
self.serial_consistency = Some(serial_consistency);
self
Expand Down Expand Up @@ -297,7 +297,7 @@ impl ExecutionProfileBuilder {
self
}

/// Sets the [`RetryPolicy`] to use by default on queries.
/// Sets the [`RetryPolicy`] to use by default on statements.
/// The default is [DefaultRetryPolicy](crate::policies::retry::DefaultRetryPolicy).
/// It is possible to implement a custom retry policy by implementing the trait [`RetryPolicy`].
///
Expand Down Expand Up @@ -390,11 +390,11 @@ impl Default for ExecutionProfileBuilder {
}
}

/// A profile that groups configurable options regarding query execution.
/// A profile that groups configurable options regarding statement execution.
///
/// Execution profile is immutable as such, but the driver implements double indirection of form:
/// query/Session -> ExecutionProfileHandle -> ExecutionProfile
/// which enables on-fly changing the actual profile associated with all entities (query/Session)
/// statement/Session -> [`ExecutionProfileHandle`] -> [`ExecutionProfile`]
/// which enables on-fly changing the actual profile associated with all entities (statement/Session)
/// by the same handle.
#[derive(Debug, Clone)]
pub struct ExecutionProfile(pub(crate) Arc<ExecutionProfileInner>);
Expand Down Expand Up @@ -493,7 +493,7 @@ impl ExecutionProfile {

/// A handle that points to an ExecutionProfile.
///
/// Its goal is to enable remapping all associated entities (query/Session)
/// Its goal is to enable remapping all associated entities (statement/Session)
/// to another execution profile at once.
/// Note: Cloned handles initially point to the same Arc'ed execution profile.
/// However, as the mapping has yet another level of indirection - through
Expand Down Expand Up @@ -521,7 +521,7 @@ impl ExecutionProfileHandle {
}

/// Makes the handle point to a new execution profile.
/// All entities (queries/Session) holding this handle will reflect the change.
/// All entities (statement/Session) holding this handle will reflect the change.
pub fn map_to_another_profile(&mut self, profile: ExecutionProfile) {
self.0 .0.store(profile.0)
}
Expand Down
20 changes: 10 additions & 10 deletions scylla/src/client/pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,47 +662,47 @@ impl QueryPager {
}

pub(crate) async fn new_for_query(
query: Statement,
statement: Statement,
execution_profile: Arc<ExecutionProfileInner>,
cluster_state: Arc<ClusterState>,
metrics: Arc<Metrics>,
) -> Result<Self, NextPageError> {
let (sender, receiver) = mpsc::channel::<Result<ReceivedPage, NextPageError>>(1);

let consistency = query
let consistency = statement
.config
.consistency
.unwrap_or(execution_profile.consistency);
let serial_consistency = query
let serial_consistency = statement
.config
.serial_consistency
.unwrap_or(execution_profile.serial_consistency);

let page_size = query.get_validated_page_size();
let page_size = statement.get_validated_page_size();

let routing_info = RoutingInfo {
consistency,
serial_consistency,
..Default::default()
};

let retry_session = query
let retry_session = statement
.get_retry_policy()
.map(|rp| &**rp)
.unwrap_or(&*execution_profile.retry_policy)
.new_session();

let parent_span = tracing::Span::current();
let worker_task = async move {
let query_ref = &query;
let statement_ref = &statement;

let page_query = |connection: Arc<Connection>,
consistency: Consistency,
paging_state: PagingState| {
async move {
connection
.query_raw_with_consistency(
query_ref,
statement_ref,
consistency,
serial_consistency,
Some(page_size),
Expand All @@ -712,7 +712,7 @@ impl QueryPager {
}
};

let query_ref = &query;
let query_ref = &statement;

let span_creator = move || {
let span = RequestSpan::new_query(&query_ref.contents);
Expand All @@ -724,13 +724,13 @@ impl QueryPager {
sender: sender.into(),
page_query,
statement_info: routing_info,
query_is_idempotent: query.config.is_idempotent,
query_is_idempotent: statement.config.is_idempotent,
query_consistency: consistency,
retry_session,
execution_profile,
metrics,
paging_state: PagingState::start(),
history_listener: query.config.history_listener.clone(),
history_listener: statement.config.history_listener.clone(),
current_request_id: None,
current_attempt_id: None,
parent_span,
Expand Down
Loading

0 comments on commit 61124fd

Please sign in to comment.