Skip to content

Commit cc4737e

Browse files
chore[fuzzer]: fixup idx selection scalar_at (#5154)
I think this would get stuck in a loop Signed-off-by: Joe Isaacs <[email protected]>
1 parent cee7469 commit cc4737e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fuzz/src/array/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(crate) use cast::*;
2121
pub(crate) use compare::*;
2222
pub(crate) use fill_null::*;
2323
pub(crate) use filter::*;
24+
use itertools::Itertools;
2425
use libfuzzer_sys::arbitrary::Error::EmptyChoose;
2526
use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured};
2627
pub(crate) use mask::*;
@@ -331,14 +332,14 @@ impl<'a> Arbitrary<'a> for FuzzArrayAction {
331332
}
332333

333334
let num_indices = u.int_in_range(1..=5.min(current_array.len()))?;
334-
let mut indices = HashSet::with_capacity(num_indices);
335-
336-
while indices.len() < num_indices {
337-
let idx = u.choose_index(current_array.len())?;
338-
indices.insert(idx);
339-
}
340-
341-
let indices_vec: Vec<usize> = indices.into_iter().collect();
335+
let indices_vec = (0..num_indices)
336+
.map(|_| {
337+
u.choose_index(current_array.len())
338+
.ok()
339+
.vortex_expect("cannot pick")
340+
})
341+
.unique()
342+
.collect::<Vec<_>>();
342343

343344
// Compute expected scalars using the baseline implementation
344345
let expected_scalars: Vec<Scalar> = indices_vec

0 commit comments

Comments
 (0)