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_)
{}
2021-07-06 10:58:53 +00:00
/// Entry is affected by DROP_RANGE and must be postponed
2021-07-05 19:58:36 +00:00
bool isAffectedByDropRange(const ReplicatedMergeTreeLogEntry & entry, std::string & postpone_reason) const;
2021-07-06 10:58:53 +00:00
/// Part is affected by DROP_RANGE and must be postponed
2021-07-06 08:36:39 +00:00
bool isAffectedByDropRange(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
2022-04-12 12:14:26 +00:00
bool hasDropRange(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
void addDropRange(const ReplicatedMergeTreeLogEntryPtr & entry);
2021-07-05 19:58:36 +00:00
2021-07-06 10:58:53 +00:00
/// Remove DROP_RANGE from map
void removeDropRange(const ReplicatedMergeTreeLogEntryPtr & entry);
2021-07-05 19:58:36 +00:00
};
}