Skip to content

Commit

Permalink
feat: gc binview when writing ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 27, 2024
1 parent c088edb commit 0bc9eaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/polars-arrow/src/array/binview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ impl<T: ViewType + ?Sized> BinaryViewArrayGeneric<T> {
mutable.freeze().with_validity(self.validity)
}

pub fn is_sliced(&self) -> bool {
self.views.as_ptr() != self.views.storage_ptr()
}

pub fn maybe_gc(self) -> Self {
const GC_MINIMUM_SAVINGS: usize = 16 * 1024; // At least 16 KiB.

Expand Down
7 changes: 6 additions & 1 deletion crates/polars-arrow/src/io/ipc/write/serialize/binview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ pub(super) fn write_binview<T: ViewType + ?Sized>(
is_little_endian: bool,
compression: Option<Compression>,
) {
let array = if array.is_sliced() {
array.clone().maybe_gc()
} else {
array.clone()
};
write_bitmap(
array.validity(),
array::Array::len(array),
array::Array::len(&array),
buffers,
arrow_data,
offset,
Expand Down

0 comments on commit 0bc9eaf

Please sign in to comment.