MCPcopy Create free account
hub / github.com/apache/arrow / ValidateNulls

Method ValidateNulls

cpp/src/arrow/array/validate.cc:554–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552 }
553
554 Status ValidateNulls(const DataType& type) {
555 if (type.storage_id() != Type::NA && data.null_count > 0 &&
556 data.buffers[0] == nullptr) {
557 return Status::Invalid("Array of type ", type.ToString(), " has ", data.null_count,
558 " nulls but no null bitmap");
559 }
560 if (data.null_count > data.length) {
561 return Status::Invalid("Null count exceeds array length");
562 }
563 if (data.null_count < 0 && data.null_count != kUnknownNullCount) {
564 return Status::Invalid("Negative null count");
565 }
566
567 if (full_validation) {
568 if (data.null_count != kUnknownNullCount) {
569 int64_t actual_null_count;
570 if (may_have_validity_bitmap(data.type->id()) && data.buffers[0]) {
571 // Do not call GetNullCount() as it would also set the `null_count` member
572 actual_null_count = data.length - CountSetBits(data.buffers[0]->data(),
573 data.offset, data.length);
574 } else if (data.type->storage_id() == Type::NA) {
575 actual_null_count = data.length;
576 } else {
577 actual_null_count = 0;
578 }
579 if (actual_null_count != data.null_count) {
580 return Status::Invalid("null_count value (", data.null_count,
581 ") doesn't match actual number of nulls in array (",
582 actual_null_count, ")");
583 }
584 }
585 }
586 return Status::OK();
587 }
588
589 Status ValidateFixedWidthBuffers() {
590 if (data.length > 0 && !IsBufferValid(1)) {

Callers

nothing calls this directly

Calls 7

may_have_validity_bitmapFunction · 0.85
InvalidFunction · 0.50
CountSetBitsFunction · 0.50
OKFunction · 0.50
ToStringMethod · 0.45
idMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected