Skip to content

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rius committed Oct 13, 2023
2 parents 848e3f8 + ea9b710 commit 8d31f9d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scyllapy"
version = "1.2.0"
version = "1.2.1"
edition = "2021"

[lib]
Expand All @@ -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"] }
Expand Down
2 changes: 2 additions & 0 deletions python/scyllapy/_internal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 4 additions & 0 deletions src/consistencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub enum ScyllaPyConsistency {
LOCAL_QUORUM,
EACH_QUORUM,
LOCAL_ONE,
SERIAL,
LOCAL_SERIAL,
}

#[pyclass(name = "SerialConsistency")]
Expand All @@ -42,6 +44,8 @@ impl From<ScyllaPyConsistency> 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,
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/load_balancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/query_results.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, hash::BuildHasherDefault, sync::Arc};

use futures::StreamExt;
use pyo3::{
Expand Down Expand Up @@ -40,14 +40,17 @@ impl ScyllaPyQueryResult {
&'a self,
py: Python<'a>,
limit: Option<usize>,
) -> ScyllaPyResult<Option<Vec<HashMap<&'a str, &'a PyAny>>>> {
) -> ScyllaPyResult<Option<Vec<rustc_hash::FxHashMap<&'a str, &'a PyAny>>>> {
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::<rustc_hash::FxHasher>::default(),
);
for (col_index, column) in row.columns.iter().enumerate() {
map.insert(
specs[col_index].name.as_str(),
Expand Down
7 changes: 4 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Value for ScyllaPyCQLDTO {
ScyllaPyCQLDTO::Map(map) => map
.iter()
.cloned()
.collect::<HashMap<_, _>>()
.collect::<HashMap<_, _, BuildHasherDefault<rustc_hash::FxHasher>>>()
.serialize(buf),
ScyllaPyCQLDTO::Timestamp(timestamp) => {
scylla::frame::value::Timestamp(*timestamp).serialize(buf)
Expand Down Expand Up @@ -502,7 +502,8 @@ pub fn parse_python_query_params(
return Ok(values);
} else if params.is_instance_of::<PyDict>() {
if allow_dicts {
let dict = params.extract::<HashMap<&str, &PyAny>>()?;
let dict = params
.extract::<HashMap<&str, &PyAny, BuildHasherDefault<rustc_hash::FxHasher>>>()?;
for (name, value) in dict {
values.add_named_value(name.to_lowercase().as_str(), &py_to_value(value)?)?;
}
Expand Down

0 comments on commit 8d31f9d

Please sign in to comment.