Skip to content

Commit

Permalink
fix memcpy of multiple chunks; closes 1396
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 20, 2021
1 parent 3019876 commit 1fb9e74
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions polars/polars-core/src/chunked_array/ops/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ where

let mut offset = 0;
ca.downcast_iter().for_each(|arr| {
let values = arr.values();
let len = arr.len();
(vals_slice[offset..len]).copy_from_slice(values);
let values = arr.values().as_slice();
let len = values.len();
(vals_slice[offset..offset + len]).copy_from_slice(values);
offset += len;
});
vals
Expand Down
2 changes: 2 additions & 0 deletions polars/polars-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub mod prelude;
pub mod serde;
pub mod series;
pub mod testing;
#[cfg(test)]
mod tests;
pub(crate) mod vector_hasher;

#[cfg(feature = "dtype-categorical")]
Expand Down
17 changes: 17 additions & 0 deletions polars/polars-core/src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::prelude::*;

#[test]
fn test_initial_empty_sort() -> Result<()> {
// https://github.com/pola-rs/polars/issues/1396
let data = vec![1.3; 42];
let mut series = Series::new("data", Vec::<f64>::new());
let series2 = Series::new("data2", data.clone());
let series3 = Series::new("data3", data);
let df = DataFrame::new(vec![series2, series3])?;

for column in df.get_columns().iter() {
series.append(column)?;
}
series.f64()?.sort(false);
Ok(())
}

0 comments on commit 1fb9e74

Please sign in to comment.