MCPcopy Create free account
hub / github.com/apache/arrow-rs / build_input_array

Function build_input_array

arrow-array/src/array/run_array.rs:828–867  ·  view source on GitHub ↗
(size: usize)

Source from the content-addressed store, hash-verified

826 use crate::{Int16Array, Int32Array, StringArray};
827
828 fn build_input_array(size: usize) -> Vec<Option<i32>> {
829 // The input array is created by shuffling and repeating
830 // the seed values random number of times.
831 let mut seed: Vec<Option<i32>> = vec![
832 None,
833 None,
834 None,
835 Some(1),
836 Some(2),
837 Some(3),
838 Some(4),
839 Some(5),
840 Some(6),
841 Some(7),
842 Some(8),
843 Some(9),
844 ];
845 let mut result: Vec<Option<i32>> = Vec::with_capacity(size);
846 let mut ix = 0;
847 let mut rng = rng();
848 // run length can go up to 8. Cap the max run length for smaller arrays to size / 2.
849 let max_run_length = 8_usize.min(1_usize.max(size / 2));
850 while result.len() < size {
851 // shuffle the seed array if all the values are iterated.
852 if ix == 0 {
853 seed.shuffle(&mut rng);
854 }
855 // repeat the items between 1 and 8 times. Cap the length for smaller sized arrays
856 let num = max_run_length.min(rng.random_range(1..=max_run_length));
857 for _ in 0..num {
858 result.push(seed[ix]);
859 }
860 ix += 1;
861 if ix == seed.len() {
862 ix = 0
863 }
864 }
865 result.resize(size, None);
866 result
867 }
868
869 // Asserts that `logical_array[logical_indices[*]] == physical_array[physical_indices[*]]`
870 fn compare_logical_and_physical_indices(

Callers 3

test_ree_array_accessorFunction · 0.70

Calls 4

maxMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45
resizeMethod · 0.45

Tested by 3

test_ree_array_accessorFunction · 0.56