Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better iterators for VarBin/VarBinView that don't always copy #221

Merged
merged 8 commits into from
Apr 12, 2024

Conversation

robert3005
Copy link
Member

@robert3005 robert3005 commented Apr 9, 2024

No description provided.

@robert3005 robert3005 enabled auto-merge (squash) April 10, 2024 16:50
vortex-array/src/array/varbin/builder.rs Show resolved Hide resolved
let mut offsets: Vec<K> = Vec::with_capacity(vec.len() + 1);
let mut values: Vec<u8> = Vec::new();
offsets.push(K::zero());
let mut builder = VarBinBuilder::<K>::with_capacity(vec.len());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you considered summing the lengths of the strings and pre-allocating the bytes array in VarBinBuilder? (in the Vec case, at least)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmmmmmmmmmmm, we actually did the summing to fgure out K

vortex-array/src/array/varbin/mod.rs Show resolved Hide resolved

pub fn finish(&self, dtype: &DType) -> StatsSet {
StatsSet::from(HashMap::from([
(Stat::Min, varbin_scalar(self.min.to_vec(), dtype)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if empty, then we'll push e.g., &[0xFF] to min, but we probably just shouldn't set it? or should set something that more explicitly indicates that it's empty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, before we ignored nulls so I missed it when I added proper handling

self.views.push(BinaryView {
_ref: Ref::new(
vbytes.len() as u32,
vbytes[0..4].try_into().unwrap(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number 4 should probably be a named constant in the BinaryView namespace, no?

self.nulls.append_null();
}

pub fn finish(&mut self, dtype: DType) -> VarBinViewArray {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as other builder, should this just take self

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a comment by @gatesn before that we need to have our own validdity builder since arrow methods require &mut

vortex-array/src/array/varbinview/mod.rs Show resolved Hide resolved
@robert3005 robert3005 merged commit e7bd331 into develop Apr 12, 2024
2 checks passed
@robert3005 robert3005 deleted the rk/varbin branch April 12, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants