mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
More optimal check for intrsecting parts in DefaultCoordinator init
This commit is contained in:
parent
aba7de5091
commit
190d3f04c9
@ -376,17 +376,20 @@ void DefaultCoordinator::initializeReadingState(InitialAllRangesAnnouncement ann
|
|||||||
if (state_initialized)
|
if (state_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
{
|
||||||
|
/// To speedup search for adjacent parts
|
||||||
|
Parts known_parts(all_parts_to_read.begin(), all_parts_to_read.end());
|
||||||
|
|
||||||
for (auto && part : announcement.description)
|
for (auto && part : announcement.description)
|
||||||
{
|
{
|
||||||
auto intersecting_it = std::find_if(
|
auto intersecting_it = known_parts.lower_bound(Part{.description = part, .replicas = {}});
|
||||||
all_parts_to_read.begin(),
|
|
||||||
all_parts_to_read.end(),
|
|
||||||
[&part](const Part & other) { return !other.description.info.isDisjoint(part.info); });
|
|
||||||
|
|
||||||
if (intersecting_it != all_parts_to_read.end())
|
if (intersecting_it != known_parts.end() && !intersecting_it->description.info.isDisjoint(part.info))
|
||||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Intersecting parts found in announcement");
|
throw Exception(ErrorCodes::LOGICAL_ERROR, "Intersecting parts found in announcement");
|
||||||
|
|
||||||
all_parts_to_read.push_back(Part{.description = std::move(part), .replicas = {announcement.replica_num}});
|
all_parts_to_read.push_back(Part{.description = std::move(part), .replicas = {announcement.replica_num}});
|
||||||
|
known_parts.emplace(Part{.description = part, .replicas = {}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ranges::sort(
|
std::ranges::sort(
|
||||||
|
Loading…
Reference in New Issue
Block a user