ClickHouse/dbms/src/Storages/MergeTree/ActiveDataPartSet.h

45 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <Storages/MergeTree/MergeTreePartInfo.h>
#include <mutex>
2015-09-29 19:19:54 +00:00
#include <common/DateLUT.h>
#include <Core/Types.h>
#include <map>
namespace DB
{
2017-04-16 15:00:33 +00:00
/** Supports multiple names of active parts of data.
* Repeats part of the MergeTreeData functionality.
* TODO: generalize with MergeTreeData. It is possible to leave this class approximately as is and use it from MergeTreeData.
* Then in MergeTreeData you can make map<String, DataPartPtr> data_parts and all_data_parts.
*/
class ActiveDataPartSet
{
public:
ActiveDataPartSet(MergeTreeDataFormatVersion format_version_) : format_version(format_version_) {}
ActiveDataPartSet(MergeTreeDataFormatVersion format_version_, const Strings & names);
void add(const String & name);
2017-04-16 15:00:33 +00:00
/// If not found, returns an empty string.
String getContainingPart(const String & name) const;
2014-05-26 18:14:52 +00:00
Strings getParts() const; /// In ascending order of the partition_id and block number.
2014-08-08 08:28:13 +00:00
size_t size() const;
private:
MergeTreeDataFormatVersion format_version;
mutable std::mutex mutex;
std::map<MergeTreePartInfo, String> part_info_to_name;
2017-04-16 15:00:33 +00:00
/// Do not block mutex.
void addImpl(const String & name);
String getContainingPartImpl(const MergeTreePartInfo & part_info) const;
};
}