Skip to content

Commit 6277036

Browse files
authored
feat: compact when the buffers are empty or if more than u16::MAX (#5166)
Signed-off-by: Daniel King <[email protected]>
1 parent e885f4e commit 6277036

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

vortex-array/src/arrays/varbinview/compact.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,24 @@ impl VarBinViewArray {
3333
}
3434

3535
fn should_compact(&self) -> bool {
36+
let nbuffers = self.nbuffers();
37+
3638
// If the array is entirely inlined strings, do not attempt to compact.
37-
if self.nbuffers() == 0 {
39+
if nbuffers == 0 {
3840
return false;
3941
}
4042

43+
// These will fail to write, so in most cases we want to compact this.
44+
if nbuffers > u16::MAX as usize {
45+
return true;
46+
}
47+
4148
let bytes_referenced: u64 = self.count_referenced_bytes();
4249
let buffer_total_bytes: u64 = self.buffers.iter().map(|buf| buf.len() as u64).sum();
4350

4451
// If there is any wasted space, we want to repack.
4552
// This is very aggressive.
46-
bytes_referenced < buffer_total_bytes
53+
bytes_referenced < buffer_total_bytes || buffer_total_bytes == 0
4754
}
4855

4956
// count the number of bytes addressed by the views, not including null

0 commit comments

Comments
 (0)