Skip to content

Commit add9b22

Browse files
authored
Merge pull request #1442 from Lorak-mmk/prepared-statement-optimization
PreparedStatement: put id and lwt in shared state
2 parents 198ca33 + 362b6b7 commit add9b22

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

.github/workflows/book.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
with:
3232
# We can't use cache here, or mdbook will complain about multiple candidates for dependency.
3333
cache: false
34+
# This is a workaround for https://github.com/actions-rust-lang/setup-rust-toolchain/issues/79
35+
# and https://github.com/rust-lang/mdBook/issues/2501
36+
# When either mdbook or setup-rust-toolchain fix the issue, we can remove this.
37+
- name: Set default toolchain globally
38+
run: rustup default stable
3439
- name: Install mdbook
3540
uses: taiki-e/install-action@v2
3641
with:

scylla/src/statement/prepared.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,31 @@ use crate::routing::partitioner::{Partitioner, PartitionerHasher, PartitionerNam
9696
pub struct PreparedStatement {
9797
pub(crate) config: StatementConfig,
9898
/// Tracing IDs of all queries used to prepare this statement.
99+
// TODO(2.0): Unpub this, move this to PreparedStatementSharedData, and expose a getter.
99100
pub prepare_tracing_ids: Vec<Uuid>,
100101

101-
id: Bytes,
102102
shared: Arc<PreparedStatementSharedData>,
103103
page_size: PageSize,
104104
partitioner_name: PartitionerName,
105-
is_confirmed_lwt: bool,
106105
}
107106

108107
#[derive(Debug)]
109108
struct PreparedStatementSharedData {
109+
id: Bytes,
110110
metadata: PreparedMetadata,
111111
result_metadata: Arc<ResultMetadata<'static>>,
112112
statement: String,
113+
is_confirmed_lwt: bool,
113114
}
114115

115116
impl Clone for PreparedStatement {
116117
fn clone(&self) -> Self {
117118
Self {
118119
config: self.config.clone(),
119120
prepare_tracing_ids: Vec::new(),
120-
id: self.id.clone(),
121121
shared: self.shared.clone(),
122122
page_size: self.page_size,
123123
partitioner_name: self.partitioner_name.clone(),
124-
is_confirmed_lwt: self.is_confirmed_lwt,
125124
}
126125
}
127126
}
@@ -137,23 +136,23 @@ impl PreparedStatement {
137136
config: StatementConfig,
138137
) -> Self {
139138
Self {
140-
id,
141139
shared: Arc::new(PreparedStatementSharedData {
140+
id,
142141
metadata,
143142
result_metadata,
144143
statement,
144+
is_confirmed_lwt: is_lwt,
145145
}),
146146
prepare_tracing_ids: Vec::new(),
147147
page_size,
148-
config,
149148
partitioner_name: Default::default(),
150-
is_confirmed_lwt: is_lwt,
149+
config,
151150
}
152151
}
153152

154153
/// Retrieves the ID of this prepared statement.
155154
pub fn get_id(&self) -> &Bytes {
156-
&self.id
155+
&self.shared.id
157156
}
158157

159158
/// Retrieves the statement string of this prepared statement.
@@ -200,7 +199,7 @@ impl PreparedStatement {
200199
/// Note: this a Scylla-specific optimisation. Therefore, the result
201200
/// will be always false for Cassandra.
202201
pub fn is_confirmed_lwt(&self) -> bool {
203-
self.is_confirmed_lwt
202+
self.shared.is_confirmed_lwt
204203
}
205204

206205
/// Computes the partition key of the target table from given values —

0 commit comments

Comments
 (0)