Skip to content

Commit e1ca0dd

Browse files
committed
fix: use reserve instead of resize
1 parent f628197 commit e1ca0dd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/cbq/core/block.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ impl ColumnarBlock {
432432
}
433433

434434
/// Decompress all columns back to native representation
435+
///
436+
/// Note: `resize` can be only be used with `copy_decode` if passing
437+
/// as `&mut [T]`. Passing a resized `&mut Vec<T>` will lead to an
438+
/// append operation, not an overwrite. If passing `&mut Vec<T>`, the
439+
/// `Vec` will be resized automatically by `copy_decode`.
435440
pub fn decompress_columns(&mut self) -> Result<()> {
436441
// decompress sequence lengths
437442
{
@@ -450,7 +455,7 @@ impl ColumnarBlock {
450455

451456
// decompress npos
452457
if !self.z_npos.is_empty() {
453-
self.ef_bytes.resize(self.len_nef, 0);
458+
self.ef_bytes.reserve(self.len_nef);
454459
copy_decode(self.z_npos.as_slice(), &mut self.ef_bytes)?;
455460

456461
let ef = EliasFano::deserialize_from(self.ef_bytes.as_slice())?;

0 commit comments

Comments
 (0)