Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Oct 22, 2024
1 parent 82c7e4b commit 276713a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/polars-core/src/frame/group_by/perfect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::Debug;
use std::mem::MaybeUninit;

use num_traits::{FromPrimitive, ToPrimitive};
use polars_utils::idx_vec::IdxVec;
Expand Down Expand Up @@ -113,13 +114,14 @@ where
} else {
let mut groups = Vec::with_capacity(len);
let mut first = Vec::with_capacity(len);
let first_out = first.spare_capacity_mut();
groups.resize_with(len, || IdxVec::with_capacity(group_capacity));

let mut push_to_group = |cat, row_nr| unsafe {
let buf: &mut IdxVec = groups.get_unchecked_release_mut(cat);
buf.push(row_nr);
if buf.len() == 1 {
*first.get_unchecked_release_mut(cat) = row_nr;
*first_out.get_unchecked_release_mut(cat) = MaybeUninit::new(row_nr);
}
};

Expand Down

0 comments on commit 276713a

Please sign in to comment.