Jefffrey commented on code in PR #9222:
URL: https://github.com/apache/arrow-rs/pull/9222#discussion_r2730779484
##########
arrow-row/src/lib.rs:
##########
@@ -3614,64 +3635,203 @@ mod tests {
StructArray::new(fields, values, Some(nulls))
}
- fn generate_list<F>(len: usize, valid_percent: f64, values: F) -> ListArray
+ fn generate_list<R: RngCore, F>(
+ rng: &mut R,
+ len: usize,
+ valid_percent: f64,
+ values: F,
+ ) -> ListArray
where
- F: FnOnce(usize) -> ArrayRef,
+ F: FnOnce(&mut R, usize) -> ArrayRef,
{
- let mut rng = rng();
let offsets = OffsetBuffer::<i32>::from_lengths((0..len).map(|_|
rng.random_range(0..10)));
let values_len = offsets.last().unwrap().to_usize().unwrap();
- let values = values(values_len);
+ let values = values(rng, values_len);
let nulls = NullBuffer::from_iter((0..len).map(|_|
rng.random_bool(valid_percent)));
let field = Arc::new(Field::new_list_field(values.data_type().clone(),
true));
ListArray::new(field, offsets, values, Some(nulls))
}
- fn generate_column(len: usize) -> ArrayRef {
- let mut rng = rng();
- match rng.random_range(0..18) {
- 0 => Arc::new(generate_primitive_array::<Int32Type>(len, 0.8)),
- 1 => Arc::new(generate_primitive_array::<UInt32Type>(len, 0.8)),
- 2 => Arc::new(generate_primitive_array::<Int64Type>(len, 0.8)),
- 3 => Arc::new(generate_primitive_array::<UInt64Type>(len, 0.8)),
- 4 => Arc::new(generate_primitive_array::<Float32Type>(len, 0.8)),
- 5 => Arc::new(generate_primitive_array::<Float64Type>(len, 0.8)),
- 6 => Arc::new(generate_strings::<i32>(len, 0.8)),
- 7 => Arc::new(generate_dictionary::<Int64Type>(
+ fn generate_nulls(rng: &mut impl RngCore, len: usize) ->
Option<NullBuffer> {
+ Some(NullBuffer::from_iter(
+ (0..len).map(|_| rng.random_bool(0.8)),
+ ))
+ }
+
+ fn change_underline_null_values_for_primitive<T: ArrowPrimitiveType>(
Review Comment:
```suggestion
fn change_underlying_null_values_for_primitive<T: ArrowPrimitiveType>(
```
##########
arrow-row/src/lib.rs:
##########
@@ -3699,120 +3859,206 @@ mod tests {
t.join(",")
}
+ #[derive(Debug, PartialEq)]
+ enum Nulls {
+ /// Keep the generated array as is
+ AsIs,
+
+ /// Replace the null buffer with different null buffer to point to
different positions as null
+ Different,
+
+ /// Remove all nulls
+ None,
+ }
+
#[test]
#[cfg_attr(miri, ignore)]
fn fuzz_test() {
+ let mut rng = StdRng::seed_from_u64(42);
Review Comment:
If we're fuzzing is it better to have differing seeds so we can test more
random states or its better to be deterministic instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]