1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use arrow2::{array::Array, bitmap::Bitmap};
use sample_std::{Random, Sample};

pub mod array;
pub mod chunk;
pub mod datatypes;
pub mod list;
pub mod primitive;
pub mod struct_;

pub type ArrowSampler = Box<dyn Sample<Output = Box<dyn Array>> + Send + Sync>;

pub(crate) fn generate_validity<V>(null: &Option<V>, g: &mut Random, len: usize) -> Option<Bitmap>
where
    V: Sample<Output = bool>,
{
    null.as_ref().map(|null| {
        Bitmap::from_trusted_len_iter(std::iter::repeat(()).take(len).map(|_| !null.generate(g)))
    })
}