Skip to content

Commit

Permalink
don't reallocate categorical maps made from the same local source
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 28, 2022
1 parent ebeffde commit 164749b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions polars/polars-core/src/chunked_array/categorical/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ impl CategoricalChunked {
Arc::new(new_rev)
}
(Some(RevMapping::Local(arr_l)), Some(RevMapping::Local(arr_r))) => {
// they are from the same source, just clone
if std::ptr::eq(arr_l, arr_r) {
return self.categorical_map.clone().unwrap()
}

let arr = arrow::compute::concatenate::concatenate(&[arr_l, arr_r]).unwrap();
let arr = arr.as_any().downcast_ref::<Utf8Array<i64>>().unwrap().clone();

Expand Down

0 comments on commit 164749b

Please sign in to comment.