74 result.primary_objective_name_different_ =
79 const absl::flat_hash_set<int64_t> first_elements =
81 const absl::flat_hash_set<int64_t> second_elements =
86 for (int64_t element :
IntersectSets(first_elements, second_elements)) {
87 absl::StatusOr<absl::string_view> first_name =
90 absl::StatusOr<absl::string_view> second_name =
94 CHECK_OK(second_name);
95 if (*first_name != *second_name) {
107 [&result, &first, &second]<
typename AttrType>(AttrType attr) {
111 const absl::flat_hash_set<Key> first_non_defaults =
113 const absl::flat_hash_set<Key> second_non_defaults =
158 if (difference.
Empty()) {
159 return "No difference";
161 std::vector<std::string> lines;
162 if (difference.model_name_different_) {
163 lines.push_back(
"model name disagrees:");
164 lines.push_back(absl::StrCat(
" first_name: \"",
166 lines.push_back(absl::StrCat(
" second_name: \"",
169 if (difference.primary_objective_name_different_) {
170 lines.push_back(
"primary objective name disagrees:");
171 lines.push_back(absl::StrCat(
" first_name: \"",
174 lines.push_back(absl::StrCat(
" second_name: \"",
180 if (!el_diff.
Empty()) {
181 lines.push_back(absl::StrCat(e,
":"));
184 lines.push_back(
" element ids in first but not second:");
187 absl::StrCat(
" ", ElementDebugString(first, e,
id)));
191 lines.push_back(
" element ids in second but not first:");
194 absl::StrCat(
" ", ElementDebugString(second, e,
id)));
199 lines.push_back(
" element ids with disagreeing names:");
201 absl::StatusOr<absl::string_view> first_name =
203 absl::StatusOr<absl::string_view> second_name =
205 CHECK_OK(first_name);
206 CHECK_OK(second_name);
207 lines.push_back(absl::StrCat(
208 " id: ",
id,
" first_name: \"", absl::CEscape(*first_name),
209 "\" second_name: \"", absl::CEscape(*second_name),
"\""));
213 lines.push_back(
" next_id does not agree:");
214 lines.push_back(absl::StrCat(
" first: ", first.
NextElementId(e)));
215 lines.push_back(absl::StrCat(
" second: ", second.
NextElementId(e)));
221 [&lines, &difference, &first, &second]<
typename AttrType>(AttrType attr) {
223 auto attr_value_str = [attr](
const Elemental& elemental,
227 return std::string(
"__missing__");
231 if (!attr_diff.Empty()) {
232 lines.push_back(absl::StrCat(
"For attribute ", attr,
233 " errors on the following keys:"));
235 lines.push_back(absl::StrCat(
237 " (name in first: ", KeyDebugString(first, attr, key),
238 ") value in first: ", attr_value_str(first, key),
239 " (name in second: ", KeyDebugString(second, attr, key),
240 ") value in second: ", attr_value_str(second, key)));
244 return absl::StrJoin(lines,
"\n");