MCPcopy Create free account
hub / github.com/apache/datafusion / zero_array

Function zero_array

benchmarks/src/bin/gen_wide_data.rs:108–127  ·  view source on GitHub ↗

Build a zero-filled array of the given datatype. Used for the suffix-renamed padding columns. Zero-filled rather than all-null so the parquet reader can't shortcut on null-array statistics — the wide-schema slowdown reproduces ~35 % wider with zeros than with nulls.

(dt: &DataType, n: usize)

Source from the content-addressed store, hash-verified

106/// wide-schema slowdown reproduces ~35 % wider with zeros than with
107/// nulls.
108fn zero_array(dt: &DataType, n: usize) -> ArrayRef {
109 match dt {
110 DataType::Int32 => {
111 Arc::new(Int32Array::from_iter_values(std::iter::repeat_n(0i32, n)))
112 }
113 DataType::Int64 => {
114 Arc::new(Int64Array::from_iter_values(std::iter::repeat_n(0i64, n)))
115 }
116 DataType::Float64 => Arc::new(Float64Array::from_iter_values(
117 std::iter::repeat_n(0.0f64, n),
118 )),
119 DataType::Date32 => {
120 Arc::new(Date32Array::from_iter_values(std::iter::repeat_n(0i32, n)))
121 }
122 DataType::Utf8 => {
123 Arc::new(StringArray::from_iter_values(std::iter::repeat_n("", n)))
124 }
125 _ => panic!("zero_array: unsupported datatype {dt:?}"),
126 }
127}
128
129/// Eight-column base schema. All fields nullable so the schema is
130/// uniform across base and zero-filled replicated copies.

Callers 1

widen_batchFunction · 0.85

Calls 1

newFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…