From 826d3b166a7b8d86ce27e547020c6d2e3034cc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ko=C5=82aczkowski?= Date: Thu, 15 Aug 2024 08:56:03 +0200 Subject: [PATCH] Avoid deallocation of vectors of floats --- Cargo.lock | 6 +++--- src/scripting/bind.rs | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc0e889..00dfcbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1800,7 +1800,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scylla" version = "0.13.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#9a19bbd38c5ab7d4726c8c88cb7aed2468a1f2a6" dependencies = [ "arc-swap", "async-trait", @@ -1832,7 +1832,7 @@ dependencies = [ [[package]] name = "scylla-cql" version = "0.2.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#9a19bbd38c5ab7d4726c8c88cb7aed2468a1f2a6" dependencies = [ "async-trait", "byteorder", @@ -1848,7 +1848,7 @@ dependencies = [ [[package]] name = "scylla-macros" version = "0.5.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#9a19bbd38c5ab7d4726c8c88cb7aed2468a1f2a6" dependencies = [ "darling", "proc-macro2", diff --git a/src/scripting/bind.rs b/src/scripting/bind.rs index 99d640a..f8ee078 100644 --- a/src/scripting/bind.rs +++ b/src/scripting/bind.rs @@ -3,7 +3,7 @@ use crate::scripting::cass_error::{CassError, CassErrorKind}; use crate::scripting::cql_types::Uuid; use rune::{Any, ToValue, Value}; -use scylla::_macro_internal::ColumnType; +use scylla::_macro_internal::{ColumnType, DropOptimizedVec}; use scylla::frame::response::result::{ColumnSpec, CqlValue}; use scylla::frame::value::CqlTimeuuid; use std::net::IpAddr; @@ -81,11 +81,13 @@ fn to_scylla_value(v: &Value, typ: &ColumnType) -> Result { (Value::Vec(v), ColumnType::Vector(elt, _dim)) => { let v = v.borrow_ref().unwrap(); let mut elements = Vec::with_capacity(v.len()); + let mut must_drop = false; for elem in v.iter() { let elem = to_scylla_value(elem, elt)?; + must_drop |= !matches!(elem, CqlValue::Float(_)); elements.push(elem); } - Ok(CqlValue::Vector(elements)) + Ok(CqlValue::Vector(DropOptimizedVec::new(elements, must_drop))) } (Value::Vec(v), ColumnType::Set(elt)) => { let v = v.borrow_ref().unwrap();