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

Method build

arrow-data/src/data.rs:2165–2211  ·  view source on GitHub ↗

Creates an `ArrayData`, consuming `self` # Safety By default the underlying buffers are checked to ensure they are valid Arrow data. However, if the [`Self::skip_validation`] flag has been set to true (by the `unsafe` API) this validation is skipped. If the data is not valid, undefined behavior will result.

(self)

Source from the content-addressed store, hash-verified

2163 /// to true (by the `unsafe` API) this validation is skipped. If the data is
2164 /// not valid, undefined behavior will result.
2165 pub fn build(self) -> Result<ArrayData, ArrowError> {
2166 let Self {
2167 data_type,
2168 len,
2169 null_count,
2170 null_bit_buffer,
2171 nulls,
2172 offset,
2173 buffers,
2174 child_data,
2175 align_buffers,
2176 skip_validation,
2177 } = self;
2178
2179 let nulls = nulls
2180 .or_else(|| {
2181 let buffer = null_bit_buffer?;
2182 let buffer = BooleanBuffer::new(buffer, offset, len);
2183 Some(match null_count {
2184 Some(n) => {
2185 // SAFETY: call to `data.validate_data()` below validates the null buffer is valid
2186 unsafe { NullBuffer::new_unchecked(buffer, n) }
2187 }
2188 None => NullBuffer::new(buffer),
2189 })
2190 })
2191 .filter(|b| b.null_count() != 0);
2192
2193 let mut data = ArrayData {
2194 data_type,
2195 len,
2196 offset,
2197 buffers,
2198 child_data,
2199 nulls,
2200 };
2201
2202 if align_buffers {
2203 data.align_buffers();
2204 }
2205
2206 // SAFETY: `skip_validation` is only set to true using `unsafe` APIs
2207 if !skip_validation.get() || cfg!(feature = "force_validate") {
2208 data.validate_data()?;
2209 }
2210 Ok(data)
2211 }
2212
2213 /// Ensure that all buffers are aligned, copying data if necessary
2214 ///

Callers 15

test_structFunction · 0.45
test_dictionary_nullsFunction · 0.45
generate_dictionaryFunction · 0.45
replace_array_nullsFunction · 0.45
test_containsFunction · 0.45
new_uncheckedMethod · 0.45
build_uncheckedMethod · 0.45
test_builderFunction · 0.45
test_null_countFunction · 0.45
test_null_buffer_refFunction · 0.45
test_sliceFunction · 0.45

Calls 5

filterMethod · 0.80
align_buffersMethod · 0.80
validate_dataMethod · 0.80
null_countMethod · 0.45
getMethod · 0.45

Tested by 12

test_structFunction · 0.36
test_dictionary_nullsFunction · 0.36
test_containsFunction · 0.36
test_builderFunction · 0.36
test_null_countFunction · 0.36
test_null_buffer_refFunction · 0.36
test_sliceFunction · 0.36
test_equalityFunction · 0.36
test_slice_memory_sizeFunction · 0.36