This commit is contained in:
Alexander Gololobov 2024-09-16 15:25:37 +02:00 committed by GitHub
commit 19cbdcf7e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -869,8 +869,7 @@ void InOrderCoordinator<mode>::doHandleInitialAllRangesAnnouncement(InitialAllRa
/// To get rid of duplicates /// To get rid of duplicates
for (auto && part: announcement.description) for (auto && part: announcement.description)
{ {
auto the_same_it = std::find_if(all_parts_to_read.begin(), all_parts_to_read.end(), auto the_same_it = all_parts_to_read.find(Part{.description = part, .replicas = {}});
[&part] (const Part & other) { return other.description.info == part.info; });
/// We have the same part - add the info about presence on the corresponding replica to it /// We have the same part - add the info about presence on the corresponding replica to it
if (the_same_it != all_parts_to_read.end()) if (the_same_it != all_parts_to_read.end())
@ -882,12 +881,28 @@ void InOrderCoordinator<mode>::doHandleInitialAllRangesAnnouncement(InitialAllRa
if (state_initialized) if (state_initialized)
continue; continue;
auto covering_or_the_same_it = std::find_if(all_parts_to_read.begin(), all_parts_to_read.end(), /// Look for the first part >= current
[&part] (const Part & other) { return other.description.info.contains(part.info) || part.info.contains(other.description.info); }); auto covering_it = all_parts_to_read.lower_bound(Part{.description = part, .replicas = {}});
/// It is covering part or we have covering - skip it if (covering_it != all_parts_to_read.end())
if (covering_or_the_same_it != all_parts_to_read.end()) {
continue; /// Checks if other part covers this one or this one covers the other
auto is_covered_or_covering = [&part] (const Part & other)
{
return other.description.info.contains(part.info) || part.info.contains(other.description.info);
};
if (is_covered_or_covering(*covering_it))
continue;
/// Also look at the previous part, it could be covering the current one
if (covering_it != all_parts_to_read.begin())
{
--covering_it;
if (is_covered_or_covering(*covering_it))
continue;
}
}
new_rows_to_read += part.rows; new_rows_to_read += part.rows;