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

Function CompareFuzzBatches

cpp/src/arrow/ipc/reader.cc:2698–2743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2696}
2697
2698Status CompareFuzzBatches(const RecordBatchWithMetadata& left,
2699 const RecordBatchWithMetadata& right) {
2700 if ((left.custom_metadata != nullptr) != (right.custom_metadata != nullptr) ||
2701 (left.custom_metadata && !left.custom_metadata->Equals(*right.custom_metadata))) {
2702 std::stringstream ss;
2703 auto print_metadata = [&](const RecordBatchWithMetadata& batch) {
2704 if (batch.custom_metadata) {
2705 ss << batch.custom_metadata->ToString();
2706 } else {
2707 ss << "nullptr";
2708 }
2709 };
2710 ss << "Custom metadata unequal: left = ";
2711 print_metadata(left);
2712 ss << "\nright = ";
2713 print_metadata(right);
2714 return Status::Invalid(ss.str());
2715 }
2716
2717 bool ok = true;
2718 if ((left.batch != nullptr) != (right.batch != nullptr)) {
2719 ok = false;
2720 } else if (left.batch) {
2721 ok &= left.batch->Equals(*right.batch, EqualOptions{}.nans_equal(true));
2722 }
2723 if (ok) {
2724 return Status::OK();
2725 }
2726 std::stringstream ss;
2727 PrettyPrintOptions options{};
2728 options.show_field_metadata = true;
2729 options.show_schema_metadata = true;
2730 auto print_batch = [&](const RecordBatchWithMetadata& batch) {
2731 if (batch.batch) {
2732 ss << "\n";
2733 ARROW_UNUSED(PrettyPrint(*batch.batch, options, &ss));
2734 } else {
2735 ss << "nullptr";
2736 }
2737 };
2738 ss << "Batches unequal: left = ";
2739 print_batch(left);
2740 ss << "\nright = ";
2741 print_batch(right);
2742 return Status::Invalid(ss.str());
2743}
2744
2745Status CompareFuzzBatches(const std::vector<RecordBatchWithMetadata>& left,
2746 const std::vector<RecordBatchWithMetadata>& right) {

Callers 1

FuzzIpcFileFunction · 0.85

Calls 8

strMethod · 0.80
nans_equalMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
PrettyPrintFunction · 0.50
EqualsMethod · 0.45
ToStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected