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

Remove CqlType in favor of ColumnType #1166

Merged
merged 20 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 5 additions & 5 deletions scylla-cql/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};

use scylla_cql::frame::request::query::PagingState;
use scylla_cql::frame::request::SerializableRequest;
use scylla_cql::frame::response::result::ColumnType;
use scylla_cql::frame::response::result::{ColumnType, NativeType};
use scylla_cql::frame::{request::query, Compression, SerializedRequest};
use scylla_cql::serialize::row::SerializedValues;

Expand All @@ -28,18 +28,18 @@ fn serialized_request_make_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("LZ4Compression.SerializedRequest");
let query_args = [
("INSERT foo INTO ks.table_name (?)", {
values.add_value(&1234, &ColumnType::Int).unwrap();
values.add_value(&1234, &ColumnType::Native(NativeType::Int)).unwrap();
values.clone()
}),
("INSERT foo, bar, baz INTO ks.table_name (?, ?, ?)", {
values.add_value(&"a value", &ColumnType::Text).unwrap();
values.add_value(&"i am storing a string", &ColumnType::Text).unwrap();
values.add_value(&"a value", &ColumnType::Native(NativeType::Text)).unwrap();
values.add_value(&"i am storing a string", &ColumnType::Native(NativeType::Text)).unwrap();
values.clone()
}),
(
"INSERT foo, bar, baz, boop, blah INTO longer_keyspace.a_big_table_name (?, ?, ?, ?, 1000)",
{
values.add_value(&"dc0c8cd7-d954-47c1-8722-a857941c43fb", &ColumnType::Text).unwrap();
values.add_value(&"dc0c8cd7-d954-47c1-8722-a857941c43fb", &ColumnType::Native(NativeType::Text)).unwrap();
values.clone()
}
),
Expand Down
12 changes: 6 additions & 6 deletions scylla-cql/src/deserialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
//! the respective trait for _all_ lifetimes, i.e.:
//!
//! ```rust
//! # use scylla_cql::frame::response::result::ColumnType;
//! # use scylla_cql::frame::response::result::{NativeType, ColumnType};
//! # use scylla_cql::deserialize::{DeserializationError, FrameSlice, TypeCheckError};
//! # use scylla_cql::deserialize::value::DeserializeValue;
//! use thiserror::Error;
Expand All @@ -101,7 +101,7 @@
//! }
//! impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for MyVec {
//! fn type_check(typ: &ColumnType) -> Result<(), TypeCheckError> {
//! if let ColumnType::Blob = typ {
//! if let ColumnType::Native(NativeType::Blob) = typ {
//! return Ok(());
//! }
//! Err(TypeCheckError::new(MyDeserError::ExpectedBytes))
Expand All @@ -128,7 +128,7 @@
//! For example:
//!
//! ```rust
//! # use scylla_cql::frame::response::result::ColumnType;
//! # use scylla_cql::frame::response::result::{NativeType, ColumnType};
//! # use scylla_cql::deserialize::{DeserializationError, FrameSlice, TypeCheckError};
//! # use scylla_cql::deserialize::value::DeserializeValue;
//! use thiserror::Error;
Expand All @@ -145,7 +145,7 @@
//! 'frame: 'a,
//! {
//! fn type_check(typ: &ColumnType) -> Result<(), TypeCheckError> {
//! if let ColumnType::Blob = typ {
//! if let ColumnType::Native(NativeType::Blob) = typ {
//! return Ok(());
//! }
//! Err(TypeCheckError::new(MyDeserError::ExpectedBytes))
Expand Down Expand Up @@ -179,7 +179,7 @@
//! Example:
//!
//! ```rust
//! # use scylla_cql::frame::response::result::ColumnType;
//! # use scylla_cql::frame::response::result::{NativeType, ColumnType};
//! # use scylla_cql::deserialize::{DeserializationError, FrameSlice, TypeCheckError};
//! # use scylla_cql::deserialize::value::DeserializeValue;
//! # use bytes::Bytes;
Expand All @@ -194,7 +194,7 @@
//! }
//! impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for MyBytes {
//! fn type_check(typ: &ColumnType) -> Result<(), TypeCheckError> {
//! if let ColumnType::Blob = typ {
//! if let ColumnType::Native(NativeType::Blob) = typ {
//! return Ok(());
//! }
//! Err(TypeCheckError::new(MyDeserError::ExpectedBytes))
Expand Down
24 changes: 17 additions & 7 deletions scylla-cql/src/deserialize/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ mod tests {
use std::ops::Deref;

use crate::frame::response::result::{
ColumnSpec, ColumnType, DeserializedMetadataAndRawRows, ResultMetadata,
ColumnSpec, ColumnType, DeserializedMetadataAndRawRows, NativeType, ResultMetadata,
};

use super::super::tests::{serialize_cells, spec, CELL1, CELL2};
Expand Down Expand Up @@ -291,8 +291,10 @@ mod tests {
// `std::sync::LazyLock` is stable since 1.80, so once we bump MSRV enough,
// we will be able to replace `lazy_static` with `LazyLock`.

static SPECS: &[ColumnSpec<'static>] =
&[spec("b1", ColumnType::Blob), spec("b2", ColumnType::Blob)];
static SPECS: &[ColumnSpec<'static>] = &[
spec("b1", ColumnType::Native(NativeType::Blob)),
spec("b2", ColumnType::Native(NativeType::Blob)),
];
lazy_static::lazy_static! {
static ref RAW_DATA: Bytes = serialize_cells([Some(CELL1), Some(CELL2), Some(CELL2), Some(CELL1)]);
}
Expand Down Expand Up @@ -333,8 +335,10 @@ mod tests {

#[test]
fn test_row_iterators_too_few_rows() {
static SPECS: &[ColumnSpec<'static>] =
&[spec("b1", ColumnType::Blob), spec("b2", ColumnType::Blob)];
static SPECS: &[ColumnSpec<'static>] = &[
spec("b1", ColumnType::Native(NativeType::Blob)),
spec("b2", ColumnType::Native(NativeType::Blob)),
];
lazy_static::lazy_static! {
static ref RAW_DATA: Bytes = serialize_cells([Some(CELL1), Some(CELL2)]);
}
Expand Down Expand Up @@ -363,7 +367,10 @@ mod tests {
#[test]
fn test_typed_row_iterator_basic_parse() {
let raw_data = serialize_cells([Some(CELL1), Some(CELL2), Some(CELL2), Some(CELL1)]);
let specs = [spec("b1", ColumnType::Blob), spec("b2", ColumnType::Blob)];
let specs = [
spec("b1", ColumnType::Native(NativeType::Blob)),
spec("b2", ColumnType::Native(NativeType::Blob)),
];
let iter = RawRowIterator::new(2, &specs, FrameSlice::new(&raw_data));
let mut iter = TypedRowIterator::<'_, '_, (&[u8], Vec<u8>)>::new(iter).unwrap();

Expand All @@ -381,7 +388,10 @@ mod tests {
#[test]
fn test_typed_row_iterator_wrong_type() {
let raw_data = Bytes::new();
let specs = [spec("b1", ColumnType::Blob), spec("b2", ColumnType::Blob)];
let specs = [
spec("b1", ColumnType::Native(NativeType::Blob)),
spec("b2", ColumnType::Native(NativeType::Blob)),
];
let iter = RawRowIterator::new(0, &specs, FrameSlice::new(&raw_data));
assert!(TypedRowIterator::<'_, '_, (i32, i64)>::new(iter).is_err());
}
Expand Down
Loading