Skip to content

Commit ade8b6a

Browse files
authored
IO Fuzzer uses single threaded reader and writer (#4119)
Signed-off-by: Robert Kruszewski <[email protected]>
1 parent f1a58a4 commit ade8b6a

File tree

1 file changed

+51
-59
lines changed

1 file changed

+51
-59
lines changed

fuzz/fuzz_targets/file_io.rs

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -50,71 +50,63 @@ fuzz_target!(|fuzz: FuzzFileAction| -> Corpus {
5050
.vortex_unwrap()
5151
};
5252

53-
let runtime = tokio::runtime::Builder::new_current_thread()
54-
.enable_all()
55-
.build()
53+
let full_buff = VortexWriteOptions::default()
54+
.write_blocking(ByteBufferMut::empty(), array_data.to_array_stream())
5655
.vortex_unwrap();
5756

58-
runtime.block_on(async move {
59-
let full_buff = VortexWriteOptions::default()
60-
.write(ByteBufferMut::empty(), array_data.to_array_stream())
61-
.await
62-
.vortex_unwrap();
57+
let mut output = VortexOpenOptions::in_memory()
58+
.open(full_buff)
59+
.vortex_unwrap()
60+
.scan()
61+
.vortex_unwrap()
62+
.with_projection(projection_expr.unwrap_or_else(|| root()))
63+
.with_some_filter(filter_expr)
64+
.into_array_iter()
65+
.vortex_unwrap()
66+
.try_collect::<_, Vec<_>, _>()
67+
.vortex_unwrap();
6368

64-
let mut output = VortexOpenOptions::in_memory()
65-
.open(full_buff)
66-
.vortex_unwrap()
67-
.scan()
68-
.vortex_unwrap()
69-
.with_projection(projection_expr.unwrap_or_else(|| root()))
70-
.with_some_filter(filter_expr)
71-
.into_array_iter_multithread()
69+
let output_array = match output.len() {
70+
0 => Canonical::empty(expected_array.dtype()).into_array(),
71+
1 => output.pop().vortex_expect("one output"),
72+
_ => ChunkedArray::from_iter(output).into_array(),
73+
};
74+
75+
assert_eq!(
76+
expected_array.len(),
77+
output_array.len(),
78+
"Length was not preserved."
79+
);
80+
assert_eq!(
81+
expected_array.dtype(),
82+
output_array.dtype(),
83+
"DTypes aren't preserved expected {}, actual {}",
84+
expected_array.dtype(),
85+
output_array.dtype()
86+
);
87+
88+
if matches!(
89+
expected_array.dtype(),
90+
DType::Struct(_, _) | DType::List(_, _)
91+
) {
92+
compare_struct(expected_array, output_array);
93+
} else {
94+
let bool_result = compare(&expected_array, &output_array, Operator::Eq)
7295
.vortex_unwrap()
73-
.try_collect::<_, Vec<_>, _>()
96+
.to_bool()
7497
.vortex_unwrap();
75-
76-
let output_array = match output.len() {
77-
0 => Canonical::empty(expected_array.dtype()).into_array(),
78-
1 => output.pop().vortex_expect("one output"),
79-
_ => ChunkedArray::from_iter(output).into_array(),
80-
};
81-
82-
assert_eq!(
83-
expected_array.len(),
84-
output_array.len(),
85-
"Length was not preserved."
86-
);
87-
assert_eq!(
88-
expected_array.dtype(),
89-
output_array.dtype(),
90-
"DTypes aren't preserved expected {}, actual {}",
91-
expected_array.dtype(),
92-
output_array.dtype()
93-
);
94-
95-
if matches!(
96-
expected_array.dtype(),
97-
DType::Struct(_, _) | DType::List(_, _)
98-
) {
99-
compare_struct(expected_array, output_array);
100-
} else {
101-
let bool_result = compare(&expected_array, &output_array, Operator::Eq)
102-
.vortex_unwrap()
103-
.to_bool()
104-
.vortex_unwrap();
105-
let true_count = bool_result.boolean_buffer().count_set_bits();
106-
if true_count != expected_array.len()
107-
&& (bool_result.all_valid().vortex_unwrap()
108-
|| expected_array.all_valid().vortex_unwrap())
109-
{
110-
vortex_panic!(
111-
"Failed to match original array {}with{}",
112-
expected_array.display_tree(),
113-
output_array.display_tree()
114-
);
115-
}
98+
let true_count = bool_result.boolean_buffer().count_set_bits();
99+
if true_count != expected_array.len()
100+
&& (bool_result.all_valid().vortex_unwrap()
101+
|| expected_array.all_valid().vortex_unwrap())
102+
{
103+
vortex_panic!(
104+
"Failed to match original array {}with{}",
105+
expected_array.display_tree(),
106+
output_array.display_tree()
107+
);
116108
}
117-
});
109+
}
118110

119111
Corpus::Keep
120112
});

0 commit comments

Comments
 (0)