ClickHouse/src/Storages/MergeTree/DropPartsRanges.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.4 KiB
C++
Raw Normal View History

2021-07-05 19:58:36 +00:00
#pragma once
2021-07-06 10:58:53 +00:00
#include <unordered_map>
2021-07-05 19:58:36 +00:00
#include <Storages/MergeTree/MergeTreePartInfo.h>
#include <Storages/MergeTree/MergeTreeDataFormatVersion.h>
#include <Storages/MergeTree/ReplicatedMergeTreeLogEntry.h>
namespace DB
{
2021-07-06 10:58:53 +00:00
/// All drop ranges in ReplicatedQueue.
/// Used to postpone execution of entries affected by DROP RANGE
2021-07-05 19:58:36 +00:00
class DropPartsRanges
{
private:
MergeTreeDataFormatVersion format_version;
2021-07-06 10:58:53 +00:00
/// znode_name -> drop_range
std::unordered_map<std::string, MergeTreePartInfo> drop_ranges;
2021-07-05 19:58:36 +00:00
public:
explicit DropPartsRanges(MergeTreeDataFormatVersion format_version_)
: format_version(format_version_)
{}
2023-01-31 12:37:56 +00:00
/// Entry is affected by DROP_PART and must be postponed
bool isAffectedByDropPart(const ReplicatedMergeTreeLogEntry & entry, std::string & postpone_reason) const;
2021-07-06 10:58:53 +00:00
2023-01-31 12:37:56 +00:00
/// Part is affected by DROP_PART and must be postponed
bool isAffectedByDropPart(const std::string & new_part_name, std::string & postpone_reason) const;
2021-07-05 19:58:36 +00:00
2021-07-06 10:58:53 +00:00
/// Already has equal DROP_RANGE. Don't need to assign new one
2023-01-31 12:37:56 +00:00
bool hasDropPart(const MergeTreePartInfo & new_drop_range_info, MergeTreePartInfo * out_drop_range_info = nullptr) const;
2021-07-05 19:58:36 +00:00
2021-07-06 10:58:53 +00:00
/// Add DROP_RANGE to map
2023-01-31 12:37:56 +00:00
void addDropPart(const ReplicatedMergeTreeLogEntryPtr & entry);
2021-07-05 19:58:36 +00:00
2021-07-06 10:58:53 +00:00
/// Remove DROP_RANGE from map
2023-01-31 12:37:56 +00:00
void removeDropPart(const ReplicatedMergeTreeLogEntryPtr & entry);
2021-07-05 19:58:36 +00:00
};
}