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

Method get_valid_child_data

arrow-data/src/data.rs:1270–1293  ·  view source on GitHub ↗

Ensures that `child_data[i]` has the expected type, calls `validate()` on it, and returns a reference to that child_data

(
        &self,
        i: usize,
        expected_type: &DataType,
    )

Source from the content-addressed store, hash-verified

1268 /// Ensures that `child_data[i]` has the expected type, calls
1269 /// `validate()` on it, and returns a reference to that child_data
1270 fn get_valid_child_data(
1271 &self,
1272 i: usize,
1273 expected_type: &DataType,
1274 ) -> Result<&ArrayData, ArrowError> {
1275 let values_data = self.child_data.get(i).ok_or_else(|| {
1276 ArrowError::InvalidArgumentError(format!(
1277 "{} did not have enough child arrays. Expected at least {} but had only {}",
1278 self.data_type,
1279 i + 1,
1280 self.child_data.len()
1281 ))
1282 })?;
1283
1284 if expected_type != &values_data.data_type {
1285 return Err(ArrowError::InvalidArgumentError(format!(
1286 "Child type mismatch for {}. Expected {} but child data had {}",
1287 self.data_type, expected_type, values_data.data_type
1288 )));
1289 }
1290
1291 values_data.validate()?;
1292 Ok(values_data)
1293 }
1294
1295 /// Validate that the data contained within this [`ArrayData`] is valid
1296 ///

Callers 2

validate_child_dataMethod · 0.80

Calls 2

getMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected