Skip to content

Commit e25e75f

Browse files
committed
fix[dict]: min_max must not be null
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 16d179b commit e25e75f

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

fuzz/fuzz_targets/file_io.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ fuzz_target!(|fuzz: FuzzFileAction| -> Corpus {
100100
assert_eq!(
101101
expected_array.len(),
102102
output_array.len(),
103-
"Length was not preserved."
103+
"Length was not preserved expected {} actual {}.",
104+
expected_array.len(),
105+
output_array.len()
104106
);
105107
assert_eq!(
106108
expected_array.dtype(),
107109
output_array.dtype(),
108-
"DTypes aren't preserved expected {}, actual {}",
110+
"DTypes aren't preserved expected {}, actual {}.",
109111
expected_array.dtype(),
110112
output_array.dtype()
111113
);

vortex-array/src/expr/exprs/get_item/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl VTable for GetItem {
8080
}
8181

8282
fn fmt_data(&self, instance: &Self::Instance, f: &mut Formatter<'_>) -> std::fmt::Result {
83-
write!(f, "\"{}\"", instance.inner().as_ref())
83+
write!(f, "\"{}\"", instance)
8484
}
8585

8686
fn return_dtype(&self, expr: &ExpressionView<Self>, scope: &DType) -> VortexResult<DType> {

vortex-array/src/mask_future.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ impl MaskFuture {
6868
let inner = self.inner.clone();
6969
Self::new(range.len(), async move { Ok(inner.await?.slice(range)) })
7070
}
71+
72+
pub fn inspect(
73+
self,
74+
f: impl FnOnce(&SharedVortexResult<Mask>) + 'static + Send + Sync,
75+
) -> Self {
76+
let len = self.len;
77+
78+
Self {
79+
inner: self.inner
80+
.inspect(f)
81+
.inspect(move |r| {
82+
if let Ok(mask) = r
83+
&& mask.len() != len {
84+
vortex_panic!("MaskFuture created with future that returned mask of incorrect length (expected {}, got {})", len, mask.len());
85+
}
86+
})
87+
.boxed()
88+
.shared(),
89+
len,
90+
}
91+
}
7192
}
7293

7394
impl Future for MaskFuture {

vortex-layout/src/layouts/dict/reader.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ impl LayoutReader for DictReader {
174174
let mask = mask.await?;
175175

176176
// Short-circuit when the values are all true/false.
177-
if let Some(MinMaxResult { min, max }) = min_max(&values)? {
178-
if !max.as_bool().value().unwrap_or(true) {
177+
if values.all_valid()
178+
&& let Some(MinMaxResult { min, max }) = min_max(&values)?
179+
{
180+
if max.as_bool().value().vortex_expect("non null") == false {
179181
// All values are false
180182
return Ok(Mask::AllFalse(mask.len()));
181183
}
182-
if min.as_bool().value().unwrap_or(false) {
184+
if min.as_bool().value().vortex_expect("not null") == true {
183185
// All values are true, but we still need to respect codes validity
184186
return Ok(mask.bitand(&codes.validity_mask()));
185187
}

0 commit comments

Comments
 (0)