Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new deserialization API #1057

Merged
merged 25 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
51c1005
iterator: fix QueryPager docstring
wprzytula Nov 7, 2024
e67e5da
query_result: fix QueryRowsResult's docstrings
wprzytula Nov 10, 2024
463b9b5
treewide: rename Session to LegacySession
piodul Mar 15, 2023
ed57255
session: make generic and introduce "session kind" parameter
piodul Mar 16, 2023
8e36957
session: move query-related methods to a separate block
piodul Mar 16, 2023
6daf833
session: re-introduce the Session type as an alias
piodul Mar 16, 2023
c1416dd
session_builder: rename build->build_legacy and then reintroduce
piodul Mar 16, 2023
e9d4719
tests: scylla_supports_tablets[_legacy] suffix
wprzytula Aug 8, 2024
37ff7c6
session: partly de-genericise internal query/exec functions
piodul Mar 13, 2023
c229ae5
session: return new QueryResult from internal methods
piodul Mar 13, 2023
22f28cd
session: add interface methods for the new deser API
piodul Mar 13, 2023
2ec2885
connection: switch to the new deserialization framework
piodul Mar 14, 2023
b3f4a04
caching_session: make generic over session APIs
piodul Mar 14, 2023
001b5bb
caching_session: fix docstring references
wprzytula Nov 6, 2024
db6bee0
caching_session: modernize tests
piodul Mar 14, 2023
6d9d971
connection: migrate query_iter to new deserialization framework
wprzytula Mar 12, 2024
f3aae01
topology: reduce `query_filter_keyspace_name` monomorphisation penalty
wprzytula Nov 7, 2024
2b5f386
{session,tracing}: switch to the new deser framework for tracing info
piodul Mar 17, 2023
5919cf9
treewide: switch tests to use the new framework
wprzytula Mar 12, 2024
9a092f9
examples: adjust to use the new interface
piodul Mar 14, 2023
a204a7b
codewide: migrate doctests to new deser API
wprzytula Aug 14, 2024
e99b875
session_test: regression test empty collections deserialization
wprzytula May 21, 2024
f1e7e02
codewide: introduce DeserializeOwned{Row,Value}
wprzytula Nov 10, 2024
98b382d
iterator: rename RowIteratorWorker to PagerWorker
wprzytula Nov 12, 2024
d4a222c
iterator: fix QueryPager::rows_stream() lifetime constraints
wprzytula Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
codewide: introduce DeserializeOwned{Row,Value}
As noted in a review comment, parsing `for<'r> DeserializeValue<'r, 'r>`
to understand it's requiring an owned type is nontrivial and could be
replaced with a subtrait with an informative name.
Therefore, this commit introduces DeserializeOwnedRow and
DeserializeOwnedValue (to be used by the `scylla` crate itself only).
  • Loading branch information
wprzytula committed Nov 12, 2024
commit f1e7e020235463b6289791d4d0233e8804ba058f
7 changes: 7 additions & 0 deletions scylla/src/lib.rs
Original file line number Diff line number Diff line change
@@ -230,6 +230,13 @@ pub mod deserialize {
UdtIterator, UdtTypeCheckErrorKind,
};
}

// Shorthands for better readability.
#[cfg_attr(not(test), allow(unused))]
pub(crate) trait DeserializeOwnedValue: for<'r> DeserializeValue<'r, 'r> {}
impl<T> DeserializeOwnedValue for T where T: for<'r> DeserializeValue<'r, 'r> {}
pub(crate) trait DeserializeOwnedRow: for<'r> DeserializeRow<'r, 'r> {}
impl<T> DeserializeOwnedRow for T where T: for<'r> DeserializeRow<'r, 'r> {}
Lorak-mmk marked this conversation as resolved.
Show resolved Hide resolved
}

pub mod authentication;
4 changes: 2 additions & 2 deletions scylla/src/transport/cql_collections_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::deserialize::DeserializeOwnedValue;
use crate::transport::session::Session;
use scylla_cql::types::deserialize::value::DeserializeValue;

use crate::frame::response::result::CqlValue;
use crate::test_utils::{create_new_session_builder, setup_tracing};
@@ -36,7 +36,7 @@ async fn insert_and_select<InsertT, SelectT>(
expected: &SelectT,
) where
InsertT: SerializeValue,
SelectT: for<'r> DeserializeValue<'r, 'r> + PartialEq + std::fmt::Debug,
SelectT: DeserializeOwnedValue + PartialEq + std::fmt::Debug,
{
session
.query_unpaged(
6 changes: 3 additions & 3 deletions scylla/src/transport/cql_types_test.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate as scylla;
use crate::deserialize::DeserializeOwnedValue;
use crate::frame::response::result::CqlValue;
use crate::frame::value::{Counter, CqlDate, CqlTime, CqlTimestamp};
use crate::test_utils::{create_new_session_builder, scylla_supports_tablets, setup_tracing};
use crate::transport::session::Session;
use crate::utils::test_utils::unique_keyspace_name;
use itertools::Itertools;
use scylla_cql::frame::value::{CqlTimeuuid, CqlVarint};
use scylla_cql::types::deserialize::value::DeserializeValue;
use scylla_cql::types::serialize::value::SerializeValue;
use scylla_macros::{DeserializeValue, SerializeValue};
use std::cmp::PartialEq;
@@ -74,7 +74,7 @@ async fn init_test(table_name: &str, type_name: &str) -> Session {
// Expected values and bound values are computed using T::from_str
async fn run_tests<T>(tests: &[&str], type_name: &str)
where
T: SerializeValue + for<'r> DeserializeValue<'r, 'r> + FromStr + Debug + Clone + PartialEq,
T: SerializeValue + DeserializeOwnedValue + FromStr + Debug + Clone + PartialEq,
{
let session: Session = init_test(type_name, type_name).await;
session.await_schema_agreement().await.unwrap();
@@ -1799,7 +1799,7 @@ async fn test_udt_with_missing_field() {
expected: TR,
) where
TQ: SerializeValue,
TR: for<'r> DeserializeValue<'r, 'r> + PartialEq + Debug,
TR: DeserializeOwnedValue + PartialEq + Debug,
{
session
.query_unpaged(
3 changes: 2 additions & 1 deletion scylla/src/transport/iterator.rs
wprzytula marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ use super::query_result::ColumnSpecs;
use super::session::RequestSpan;
use crate::cql_to_rust::{FromRow, FromRowError};

use crate::deserialize::DeserializeOwnedRow;
use crate::frame::response::{
result,
result::{ColumnSpec, Row},
@@ -1076,7 +1077,7 @@ impl<RowT> TypedRowStream<RowT> {
/// It only works with owned types! For example, &str is not supported.
impl<RowT> Stream for TypedRowStream<RowT>
where
RowT: for<'r> DeserializeRow<'r, 'r>,
RowT: DeserializeOwnedRow,
{
type Item = Result<RowT, QueryError>;

4 changes: 2 additions & 2 deletions scylla/src/transport/session_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::batch::{Batch, BatchStatement};
use crate::deserialize::DeserializeValue;
use crate::deserialize::DeserializeOwnedValue;
use crate::prepared_statement::PreparedStatement;
use crate::query::Query;
use crate::retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession};
@@ -3100,7 +3100,7 @@ async fn test_deserialize_empty_collections() {
session.use_keyspace(&ks, true).await.unwrap();

async fn deserialize_empty_collection<
Collection: Default + for<'frame> DeserializeValue<'frame, 'frame> + SerializeValue,
Collection: Default + DeserializeOwnedValue + SerializeValue,
>(
session: &Session,
collection_name: &str,
4 changes: 2 additions & 2 deletions scylla/src/transport/topology.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::deserialize::DeserializeOwnedRow;
use crate::frame::response::event::Event;
use crate::routing::Token;
use crate::statement::query::Query;
@@ -15,7 +16,6 @@ use futures::Stream;
use rand::seq::SliceRandom;
use rand::{thread_rng, Rng};
use scylla_cql::frame::frame_errors::RowsParseError;
use scylla_cql::types::deserialize::row::DeserializeRow;
use scylla_cql::types::deserialize::TypeCheckError;
use scylla_macros::DeserializeRow;
use std::borrow::BorrowMut;
@@ -930,7 +930,7 @@ fn query_filter_keyspace_name<'a, R>(
convert_typecheck_error: impl FnOnce(TypeCheckError) -> MetadataError + 'a,
) -> impl Stream<Item = Result<R, QueryError>> + 'a
where
R: for<'r> DeserializeRow<'r, 'r> + 'static,
R: DeserializeOwnedRow + 'static,
{
let conn = conn.clone();