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

Function CompareFuzzBatches

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

Source from the content-addressed store, hash-verified

2758}
2759
2760Status CompareFuzzBatches(const RecordBatchWithMetadata& left,
2761 const RecordBatchWithMetadata& right) {
2762 if ((left.custom_metadata != nullptr) != (right.custom_metadata != nullptr) ||
2763 (left.custom_metadata && !left.custom_metadata->Equals(*right.custom_metadata))) {
2764 std::stringstream ss;
2765 auto print_metadata = [&](const RecordBatchWithMetadata& batch) {
2766 if (batch.custom_metadata) {
2767 ss << batch.custom_metadata->ToString();
2768 } else {
2769 ss << "nullptr";
2770 }
2771 };
2772 ss << "Custom metadata unequal: left = ";
2773 print_metadata(left);
2774 ss << "\nright = ";
2775 print_metadata(right);
2776 return Status::Invalid(ss.str());
2777 }
2778
2779 bool ok = true;
2780 if ((left.batch != nullptr) != (right.batch != nullptr)) {
2781 ok = false;
2782 } else if (left.batch) {
2783 ok &= left.batch->Equals(*right.batch, EqualOptions{}.nans_equal(true));
2784 }
2785 if (ok) {
2786 return Status::OK();
2787 }
2788 std::stringstream ss;
2789 PrettyPrintOptions options{};
2790 options.show_field_metadata = true;
2791 options.show_schema_metadata = true;
2792 auto print_batch = [&](const RecordBatchWithMetadata& batch) {
2793 if (batch.batch) {
2794 ss << "\n";
2795 ARROW_UNUSED(PrettyPrint(*batch.batch, options, &ss));
2796 } else {
2797 ss << "nullptr";
2798 }
2799 };
2800 ss << "Batches unequal: left = ";
2801 print_batch(left);
2802 ss << "\nright = ";
2803 print_batch(right);
2804 return Status::Invalid(ss.str());
2805}
2806
2807Status CompareFuzzBatches(const std::vector<RecordBatchWithMetadata>& left,
2808 const std::vector<RecordBatchWithMetadata>& right) {

Callers 1

FuzzIpcFileFunction · 0.85

Calls 7

strMethod · 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