Skip to content

Conversation

@lyang24
Copy link
Contributor

@lyang24 lyang24 commented Jan 27, 2026

Which issue does this PR close?

small optimization

Rationale for this change

key insight is the byte clone is cheap just a ref count compare to vec clone is a alloc + memcopy.

before

let mut result = Vec::new();          // alloc #1
result.extend_from_slice(prefix);
result.extend_from_slice(suffix);

let data = Bytes::from(result.clone()); // alloc #2 + memcpy
item.set_from_bytes(data);
self.previous_value = result;          // keep Vec

after

let mut result = Vec::with_capacity(prefix_len + suffix.len()); // alloc #1
result.extend_from_slice(&self.previous_value[..prefix_len]);
result.extend_from_slice(suffix);

let data = Bytes::from(result);       // no alloc, takes Vec buffer
item.set_from_bytes(data.clone());    // cheap refcount bump
self.previous_value = data;           // move, no alloc

What changes are included in this PR?

previous_value type changed to Bytes
preallocate result vec capacity.

Are these changes tested?

the existing test should pass

Are there any user-facing changes?

no

@github-actions github-actions bot added the parquet Changes to the parquet crate label Jan 27, 2026
@lyang24 lyang24 force-pushed the reduce_decoder_clone branch from 9816f38 to 2ac0261 Compare January 27, 2026 19:58
@lyang24 lyang24 force-pushed the reduce_decoder_clone branch from 2ac0261 to 0719229 Compare January 27, 2026 19:59
@lyang24 lyang24 marked this pull request as ready for review January 27, 2026 21:09
@lyang24 lyang24 changed the title reduce clone in delta byte array decoder parquet: reduce clone in delta byte array decoder Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant