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

Fix SparseArray validity logic and give DateTimeParts unique code #495

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix SparseArray validity logic
  • Loading branch information
robert3005 committed Jul 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 578560100b7e61125deee093e8fef72e8d0f0012
2 changes: 1 addition & 1 deletion encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use vortex_error::{vortex_bail, VortexResult};

use crate::compute::decode_to_temporal;

impl_encoding!("vortex.datetimeparts", 20u16, DateTimeParts);
impl_encoding!("vortex.datetimeparts", 22u16, DateTimeParts);
Copy link
Contributor

Choose a reason for hiding this comment

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

oh whoops, this actually collides with runendbools

Copy link
Member Author

Choose a reason for hiding this comment

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

lol

Copy link
Member Author

Choose a reason for hiding this comment

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


#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DateTimePartsMetadata {
4 changes: 2 additions & 2 deletions vortex-array/src/array/sparse/flatten.rs
Original file line number Diff line number Diff line change
@@ -49,8 +49,8 @@ fn canonicalize_sparse_bools(
fill_value.try_into()?
};
let mut flat_bools = vec![fill_bool; len];
for idx in indices {
flat_bools[*idx] = values.value(*idx);
for (i, idx) in indices.iter().enumerate() {
flat_bools[*idx] = values.value(i);
validity.set_bit(*idx, true);
}

15 changes: 11 additions & 4 deletions vortex-array/src/array/sparse/mod.rs
Original file line number Diff line number Diff line change
@@ -54,6 +54,13 @@ impl SparseArray {
values.dtype(),
);
}
if indices.len() != values.len() {
vortex_bail!(
"Mismatched indices {} and values {} length",
indices.len(),
values.len()
);
}

Self::try_from_parts(
values.dtype().clone(),
@@ -80,7 +87,7 @@ impl SparseArray {
#[inline]
pub fn values(&self) -> Array {
self.array()
.child(1, self.dtype(), self.indices().len())
.child(1, self.dtype(), self.metadata().indices_len)
.expect("missing child array")
}

@@ -157,10 +164,10 @@ impl ArrayValidity for SparseArray {
// of true, and patch values of false.
Self::try_new_with_offset(
self.indices(),
ConstantArray::new(false, self.len()).into_array(),
ConstantArray::new(true, self.indices().len()).into_array(),
robert3005 marked this conversation as resolved.
Show resolved Hide resolved
self.len(),
self.indices_offset(),
true.into(),
false.into(),
)
} else {
// If the fill_value is non-null, then the validity is based on the validity of the
@@ -171,7 +178,7 @@ impl ArrayValidity for SparseArray {
.with_dyn(|a| a.logical_validity().into_array()),
self.len(),
self.indices_offset(),
true.into(),
false.into(),
)
}
.unwrap();