From 16f3c117c52d0d4138e7dccc9875483d2f0589c6 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Fri, 13 Oct 2023 14:45:09 +0400 Subject: [PATCH 1/2] Updated dependencies. Signed-off-by: Pavel Kirilin --- Cargo.toml | 5 +++-- python/scyllapy/_internal/__init__.pyi | 2 ++ src/consistencies.rs | 4 ++++ src/load_balancing.rs | 9 +++++---- src/query_results.rs | 9 ++++++--- src/utils.rs | 7 ++++--- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ad6a61d..7252874 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,9 @@ pyo3 = { version = "0.19.2", features = [ ] } pyo3-asyncio = { version = "0.19.0", features = ["tokio-runtime"] } pyo3-log = "0.8.3" -scylla = { version = "0.9.0", features = ["ssl"] } -scylla-cql = "0.0.8" +rustc-hash = "1.1.0" +scylla = { version = "0.10.1", features = ["ssl"] } +scylla-cql = "0.0.9" thiserror = "1.0.48" tokio = { version = "1.32.0", features = ["bytes"] } uuid = { version = "1.4.1", features = ["v4"] } diff --git a/python/scyllapy/_internal/__init__.pyi b/python/scyllapy/_internal/__init__.pyi index 9b1b1f9..7b83dd8 100644 --- a/python/scyllapy/_internal/__init__.pyi +++ b/python/scyllapy/_internal/__init__.pyi @@ -255,6 +255,8 @@ class Consistency: LOCAL_QUORUM: Consistency EACH_QUORUM: Consistency LOCAL_ONE: Consistency + SERIAL: Consistency + LOCAL_SERIAL: Consistency class SerialConsistency: """Serial consistency for query.""" diff --git a/src/consistencies.rs b/src/consistencies.rs index f673027..6a20947 100644 --- a/src/consistencies.rs +++ b/src/consistencies.rs @@ -18,6 +18,8 @@ pub enum ScyllaPyConsistency { LOCAL_QUORUM, EACH_QUORUM, LOCAL_ONE, + SERIAL, + LOCAL_SERIAL, } #[pyclass(name = "SerialConsistency")] @@ -42,6 +44,8 @@ impl From for Consistency { ScyllaPyConsistency::LOCAL_QUORUM => Self::LocalQuorum, ScyllaPyConsistency::EACH_QUORUM => Self::EachQuorum, ScyllaPyConsistency::LOCAL_ONE => Self::LocalOne, + ScyllaPyConsistency::SERIAL => Self::Serial, + ScyllaPyConsistency::LOCAL_SERIAL => Self::LocalSerial, } } } diff --git a/src/load_balancing.rs b/src/load_balancing.rs index 6fd30d0..8f288f1 100644 --- a/src/load_balancing.rs +++ b/src/load_balancing.rs @@ -46,11 +46,12 @@ impl ScyllaPyLoadBalancingPolicy { if let Some(token) = token_aware { policy_builer = policy_builer.token_aware(token); } - if let Some(rack) = prefer_rack { - policy_builer = policy_builer.prefer_rack(rack); - } if let Some(dc) = prefer_datacenter { - policy_builer = policy_builer.prefer_datacenter(dc); + if let Some(rack) = prefer_rack { + policy_builer = policy_builer.prefer_datacenter_and_rack(dc, rack); + } else { + policy_builer = policy_builer.prefer_datacenter(dc); + } } if let Some(shufle) = shuffling_replicas { policy_builer = policy_builer.enable_shuffling_replicas(shufle); diff --git a/src/query_results.rs b/src/query_results.rs index 524a16e..0740bbf 100644 --- a/src/query_results.rs +++ b/src/query_results.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, sync::Arc}; +use std::{collections::HashMap, hash::BuildHasherDefault, sync::Arc}; use futures::StreamExt; use pyo3::{ @@ -40,14 +40,17 @@ impl ScyllaPyQueryResult { &'a self, py: Python<'a>, limit: Option, - ) -> ScyllaPyResult>>> { + ) -> ScyllaPyResult>>> { let Some(rows) = &self.inner.rows else { return Ok(None); }; let specs = &self.inner.col_specs; let mut dumped_rows = Vec::new(); for (row_index, row) in rows.iter().enumerate() { - let mut map = HashMap::new(); + let mut map = HashMap::with_capacity_and_hasher( + specs.len(), + BuildHasherDefault::::default(), + ); for (col_index, column) in row.columns.iter().enumerate() { map.insert( specs[col_index].name.as_str(), diff --git a/src/utils.rs b/src/utils.rs index 7635d22..5b4a960 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, future::Future, str::FromStr}; +use std::{collections::HashMap, future::Future, hash::BuildHasherDefault, str::FromStr}; use chrono::Duration; use pyo3::{ @@ -119,7 +119,7 @@ impl Value for ScyllaPyCQLDTO { ScyllaPyCQLDTO::Map(map) => map .iter() .cloned() - .collect::>() + .collect::>>() .serialize(buf), ScyllaPyCQLDTO::Timestamp(timestamp) => { scylla::frame::value::Timestamp(*timestamp).serialize(buf) @@ -502,7 +502,8 @@ pub fn parse_python_query_params( return Ok(values); } else if params.is_instance_of::() { if allow_dicts { - let dict = params.extract::>()?; + let dict = params + .extract::>>()?; for (name, value) in dict { values.add_named_value(name.to_lowercase().as_str(), &py_to_value(value)?)?; } From ea9b71007e9e5656dfa7a81ca421684892af4275 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Fri, 13 Oct 2023 14:57:41 +0400 Subject: [PATCH 2/2] Version bumped to 1.2.1. Signed-off-by: Pavel Kirilin --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7252874..94637c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scyllapy" -version = "1.2.0" +version = "1.2.1" edition = "2021" [lib]