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

Method validate_values

arrow-data/src/data.rs:1429–1488  ·  view source on GitHub ↗

Validates the values stored within this [`ArrayData`] are valid without recursing into child [`ArrayData`] Does not (yet) check 1. Union type_ids are valid see [#85](https://github.com/apache/arrow-rs/issues/85)

(&self)

Source from the content-addressed store, hash-verified

1427 /// Does not (yet) check
1428 /// 1. Union type_ids are valid see [#85](https://github.com/apache/arrow-rs/issues/85)
1429 pub fn validate_values(&self) -> Result<(), ArrowError> {
1430 match &self.data_type {
1431 DataType::Utf8 => self.validate_utf8::<i32>(),
1432 DataType::LargeUtf8 => self.validate_utf8::<i64>(),
1433 DataType::Binary => self.validate_offsets_full::<i32>(self.buffers[1].len()),
1434 DataType::LargeBinary => self.validate_offsets_full::<i64>(self.buffers[1].len()),
1435 DataType::BinaryView => {
1436 let views = self.typed_buffer::<u128>(0, self.len)?;
1437 validate_binary_view(views, &self.buffers[1..])
1438 }
1439 DataType::Utf8View => {
1440 let views = self.typed_buffer::<u128>(0, self.len)?;
1441 validate_string_view(views, &self.buffers[1..])
1442 }
1443 DataType::List(_) | DataType::Map(_, _) => {
1444 let child = &self.child_data[0];
1445 self.validate_offsets_full::<i32>(child.len)
1446 }
1447 DataType::LargeList(_) => {
1448 let child = &self.child_data[0];
1449 self.validate_offsets_full::<i64>(child.len)
1450 }
1451 DataType::Union(_, _) => {
1452 // Validate Union Array as part of implementing new Union semantics
1453 // See comments in `ArrayData::validate()`
1454 // https://github.com/apache/arrow-rs/issues/85
1455 //
1456 // TODO file follow on ticket for full union validation
1457 Ok(())
1458 }
1459 DataType::Dictionary(key_type, _value_type) => {
1460 let dictionary_length: i64 = self.child_data[0].len.try_into().unwrap();
1461 let max_value = dictionary_length - 1;
1462 match key_type.as_ref() {
1463 DataType::UInt8 => self.check_bounds::<u8>(max_value),
1464 DataType::UInt16 => self.check_bounds::<u16>(max_value),
1465 DataType::UInt32 => self.check_bounds::<u32>(max_value),
1466 DataType::UInt64 => self.check_bounds::<u64>(max_value),
1467 DataType::Int8 => self.check_bounds::<i8>(max_value),
1468 DataType::Int16 => self.check_bounds::<i16>(max_value),
1469 DataType::Int32 => self.check_bounds::<i32>(max_value),
1470 DataType::Int64 => self.check_bounds::<i64>(max_value),
1471 _ => unreachable!(),
1472 }
1473 }
1474 DataType::RunEndEncoded(run_ends, _values) => {
1475 let run_ends_data = self.child_data()[0].clone();
1476 match run_ends.data_type() {
1477 DataType::Int16 => run_ends_data.check_run_ends::<i16>(),
1478 DataType::Int32 => run_ends_data.check_run_ends::<i32>(),
1479 DataType::Int64 => run_ends_data.check_run_ends::<i64>(),
1480 _ => unreachable!(),
1481 }
1482 }
1483 _ => {
1484 // No extra validation check required for other types
1485 Ok(())
1486 }

Callers 3

validate_utf8_arrayFunction · 0.80
test_sliced_array_childFunction · 0.80
validate_dataMethod · 0.80

Calls 7

validate_binary_viewFunction · 0.85
validate_string_viewFunction · 0.85
child_dataMethod · 0.80
lenMethod · 0.45
as_refMethod · 0.45
cloneMethod · 0.45
data_typeMethod · 0.45

Tested by 1

test_sliced_array_childFunction · 0.64