Skip to content

Commit

Permalink
Avoid deallocation of vectors of floats
Browse files Browse the repository at this point in the history
  • Loading branch information
pkolaczk committed Aug 15, 2024
1 parent 1ecc0ec commit 826d3b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/scripting/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,11 +81,13 @@ fn to_scylla_value(v: &Value, typ: &ColumnType) -> Result<CqlValue, CassError> {
(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();
Expand Down

0 comments on commit 826d3b1

Please sign in to comment.