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

Function PrintDiff

cpp/src/arrow/compare.cc:1063–1104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1061Status PrintDiff(const Array& left, const Array& right, std::ostream* os);
1062
1063Status PrintDiff(const Array& left, const Array& right, int64_t left_offset,
1064 int64_t left_length, int64_t right_offset, int64_t right_length,
1065 std::ostream* os) {
1066 if (os == nullptr) {
1067 return Status::OK();
1068 }
1069
1070 if (!left.type()->Equals(right.type())) {
1071 *os << "# Array types differed: " << *left.type() << " vs " << *right.type()
1072 << std::endl;
1073 return Status::OK();
1074 }
1075
1076 if (left.type()->id() == Type::DICTIONARY) {
1077 *os << "# Dictionary arrays differed" << std::endl;
1078
1079 const auto& left_dict = checked_cast<const DictionaryArray&>(left);
1080 const auto& right_dict = checked_cast<const DictionaryArray&>(right);
1081
1082 *os << "## dictionary diff";
1083 auto pos = os->tellp();
1084 RETURN_NOT_OK(PrintDiff(*left_dict.dictionary(), *right_dict.dictionary(), os));
1085 if (os->tellp() == pos) {
1086 *os << std::endl;
1087 }
1088
1089 *os << "## indices diff";
1090 pos = os->tellp();
1091 RETURN_NOT_OK(PrintDiff(*left_dict.indices(), *right_dict.indices(), os));
1092 if (os->tellp() == pos) {
1093 *os << std::endl;
1094 }
1095 return Status::OK();
1096 }
1097
1098 const auto left_slice = left.Slice(left_offset, left_length);
1099 const auto right_slice = right.Slice(right_offset, right_length);
1100 ARROW_ASSIGN_OR_RAISE(auto edits,
1101 Diff(*left_slice, *right_slice, default_memory_pool()));
1102 ARROW_ASSIGN_OR_RAISE(auto formatter, MakeUnifiedDiffFormatter(*left.type(), os));
1103 return formatter(*edits, *left_slice, *right_slice);
1104}
1105
1106Status PrintDiff(const Array& left, const Array& right, std::ostream* os) {
1107 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