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

Function PrintDiff

cpp/src/arrow/compare.cc:1075–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1073Status PrintDiff(const Array& left, const Array& right, std::ostream* os);
1074
1075Status PrintDiff(const Array& left, const Array& right, int64_t left_offset,
1076 int64_t left_length, int64_t right_offset, int64_t right_length,
1077 std::ostream* os) {
1078 if (os == nullptr) {
1079 return Status::OK();
1080 }
1081
1082 if (!left.type()->Equals(right.type())) {
1083 *os << "# Array types differed: " << *left.type() << " vs " << *right.type()
1084 << std::endl;
1085 return Status::OK();
1086 }
1087
1088 if (left.type()->id() == Type::DICTIONARY) {
1089 *os << "# Dictionary arrays differed" << std::endl;
1090
1091 const auto& left_dict = checked_cast<const DictionaryArray&>(left);
1092 const auto& right_dict = checked_cast<const DictionaryArray&>(right);
1093
1094 *os << "## dictionary diff";
1095 auto pos = os->tellp();
1096 RETURN_NOT_OK(PrintDiff(*left_dict.dictionary(), *right_dict.dictionary(), os));
1097 if (os->tellp() == pos) {
1098 *os << std::endl;
1099 }
1100
1101 *os << "## indices diff";
1102 pos = os->tellp();
1103 RETURN_NOT_OK(PrintDiff(*left_dict.indices(), *right_dict.indices(), os));
1104 if (os->tellp() == pos) {
1105 *os << std::endl;
1106 }
1107 return Status::OK();
1108 }
1109
1110 const auto left_slice = left.Slice(left_offset, left_length);
1111 const auto right_slice = right.Slice(right_offset, right_length);
1112 ARROW_ASSIGN_OR_RAISE(auto edits,
1113 Diff(*left_slice, *right_slice, default_memory_pool()));
1114 ARROW_ASSIGN_OR_RAISE(auto formatter, MakeUnifiedDiffFormatter(*left.type(), os));
1115 return formatter(*edits, *left_slice, *right_slice);
1116}
1117
1118Status PrintDiff(const Array& left, const Array& right, std::ostream* os) {
1119 return PrintDiff(left, right, 0, left.length(), 0, right.length(), os);

Callers 2

ArrayRangeEqualsFunction · 0.85
ArrayEqualsFunction · 0.85

Calls 8

indicesMethod · 0.80
OKFunction · 0.70
EqualsMethod · 0.45
typeMethod · 0.45
idMethod · 0.45
dictionaryMethod · 0.45
SliceMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected