Use adjacent_find to check adjacent parts

This commit is contained in:
Alexander Gololobov 2024-09-17 17:56:44 +02:00
parent 3674c97ebb
commit 574a26c63b

View File

@ -917,18 +917,15 @@ void InOrderCoordinator<mode>::doHandleInitialAllRangesAnnouncement(InitialAllRa
#ifndef NDEBUG
/// Double check that there are no intersecting parts
{
auto part_it = all_parts_to_read.begin();
auto next_part_it = part_it;
if (next_part_it != all_parts_to_read.end())
++next_part_it;
while (next_part_it != all_parts_to_read.end())
auto intersecting_part_it = std::adjacent_find(all_parts_to_read.begin(), all_parts_to_read.end(),
[] (const Part & lhs, const Part & rhs)
{
chassert(part_it->description.info.isDisjoint(next_part_it->description.info),
fmt::format("Parts {} and {} intersect",
part_it->description.info.getPartNameV1(), next_part_it->description.info.getPartNameV1()));
++part_it;
++next_part_it;
}
return !lhs.description.info.isDisjoint(rhs.description.info);
});
if (intersecting_part_it != all_parts_to_read.end())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Parts {} and {} intersect",
intersecting_part_it->description.info.getPartNameV1(), std::next(intersecting_part_it)->description.info.getPartNameV1());
}
#endif