Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
[sort] add shrink_to_fit after all truncates
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li committed Aug 4, 2021
1 parent 1c94af4 commit 22d58cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compute/sort/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn sort_boolean<I: Index>(
// un-efficient; there are much more performant ways of sorting nulls above, anyways.
if let Some(limit) = limit {
values.truncate(limit);
values.shrink_to_fit();
}

PrimitiveArray::<I>::from_data(I::DATA_TYPE, values.into(), None)
Expand Down
2 changes: 2 additions & 0 deletions src/compute/sort/primitive/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ where
};
// values are sorted, we can now truncate the remaining.
buffer.truncate(limit);
buffer.shrink_to_fit();

(buffer.into(), new_validity.into())
}
Expand Down Expand Up @@ -154,6 +155,7 @@ where

sort_values(&mut buffer.as_mut_slice(), cmp, options.descending, limit);
buffer.truncate(limit);
buffer.shrink_to_fit();

(buffer.into(), None)
};
Expand Down

0 comments on commit 22d58cf

Please sign in to comment.