2022-02-24 12:23:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_set>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Manages set of active temporary paths that should not be cleaned by background thread.
|
|
|
|
class TemporaryParts : private boost::noncopyable
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
/// To add const qualifier for contains()
|
|
|
|
mutable std::mutex mutex;
|
|
|
|
|
|
|
|
/// NOTE: It is pretty short, so use STL is fine.
|
|
|
|
std::unordered_set<std::string> parts;
|
|
|
|
|
2022-08-10 13:48:56 +00:00
|
|
|
void add(const std::string & basename);
|
|
|
|
void remove(const std::string & basename);
|
|
|
|
|
|
|
|
friend class MergeTreeData;
|
2022-02-24 12:23:26 +00:00
|
|
|
public:
|
|
|
|
/// Returns true if passed part name is active.
|
|
|
|
/// (is the destination for one of active mutation/merge).
|
|
|
|
///
|
|
|
|
/// NOTE: that it accept basename (i.e. dirname), not the path,
|
|
|
|
/// since later requires canonical form.
|
|
|
|
bool contains(const std::string & basename) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|