ClickHouse/src/Storages/MergeTree/DataPartStorageOnDisk.h

156 lines
5.0 KiB
C++
Raw Normal View History

2022-04-05 19:12:48 +00:00
#pragma once
#include <Storages/MergeTree/IDataPartStorage.h>
#include <memory>
#include <string>
namespace DB
{
class IVolume;
using VolumePtr = std::shared_ptr<IVolume>;
class DataPartStorageOnDisk final : public IDataPartStorage
{
public:
2022-04-12 18:59:49 +00:00
DataPartStorageOnDisk(VolumePtr volume_, std::string root_path_, std::string part_dir_);
2022-04-05 19:12:48 +00:00
std::unique_ptr<ReadBufferFromFileBase> readFile(
const std::string & path,
const ReadSettings & settings,
std::optional<size_t> read_hint,
std::optional<size_t> file_size) const override;
bool exists() const override;
2022-04-19 19:34:41 +00:00
bool exists(const std::string & path) const override;
2022-04-05 19:12:48 +00:00
2022-04-08 18:56:08 +00:00
Poco::Timestamp getLastModified() const override;
2022-04-05 19:12:48 +00:00
size_t getFileSize(const std::string & path) const override;
2022-04-21 19:19:13 +00:00
UInt32 getRefCount(const String & path) const override;
2022-04-05 19:12:48 +00:00
2022-04-21 19:19:13 +00:00
DataPartStorageIteratorPtr iterate() const override;
DataPartStorageIteratorPtr iterateDirectory(const std::string & path) const override;
2022-04-05 19:12:48 +00:00
2022-04-19 19:34:41 +00:00
void remove(
bool keep_shared_data,
const MergeTreeDataPartChecksums & checksums,
std::list<ProjectionChecksums> projections,
Poco::Logger * log) const override;
void setRelativePath(const std::string & path) override;
std::string getRelativePathForPrefix(Poco::Logger * log, const String & prefix, bool detached) const override;
std::string getRelativePath() const override { return part_dir; }
2022-04-07 11:58:38 +00:00
std::string getFullPath() const override;
2022-04-19 19:34:41 +00:00
std::string getFullRootPath() const override;
2022-04-12 18:59:49 +00:00
std::string getFullRelativePath() const override;
2022-04-05 19:12:48 +00:00
UInt64 calculateTotalSizeOnDisk() const override;
2022-04-07 17:44:49 +00:00
bool isStoredOnRemoteDisk() const override;
2022-04-08 18:56:08 +00:00
bool supportZeroCopyReplication() const override;
2022-04-19 19:34:41 +00:00
bool isBroken() const override;
std::string getDiskPathForLogs() const override;
2022-04-07 17:44:49 +00:00
2022-04-21 19:19:13 +00:00
void writeChecksums(const MergeTreeDataPartChecksums & checksums) const override;
void writeColumns(const NamesAndTypesList & columns) const override;
2022-04-08 18:56:08 +00:00
void writeDeleteOnDestroyMarker(Poco::Logger * log) const override;
2022-04-05 19:12:48 +00:00
2022-04-19 19:34:41 +00:00
void checkConsistency(const MergeTreeDataPartChecksums & checksums) const override;
ReservationPtr reserve(UInt64 bytes) override;
String getUniqueId() const override;
2022-04-07 17:44:49 +00:00
bool shallParticipateInMerges(const IStoragePolicy &) const override;
2022-04-07 11:58:38 +00:00
2022-04-19 19:34:41 +00:00
void backup(
TemporaryFilesOnDisks & temp_dirs,
const MergeTreeDataPartChecksums & checksums,
const NameSet & files_without_checksums,
BackupEntries & backup_entries) const override;
DataPartStoragePtr freeze(
const std::string & to,
const std::string & dir_path,
std::function<void(const DiskPtr &)> save_metadata_callback) const override;
DataPartStoragePtr clone(
const std::string & to,
const std::string & dir_path,
Poco::Logger * log) const override;
2022-04-07 11:58:38 +00:00
void rename(const String & new_relative_path, Poco::Logger * log, bool remove_new_dir_if_exists, bool fsync) override;
2022-04-05 19:12:48 +00:00
std::string getName() const override;
2022-04-21 19:19:13 +00:00
std::string getDiskType() const override;
2022-04-05 19:12:48 +00:00
DataPartStoragePtr getProjection(const std::string & name) const override;
2022-04-21 19:19:13 +00:00
DiskPtr getDisk() const;
2022-04-05 19:12:48 +00:00
private:
VolumePtr volume;
std::string root_path;
2022-04-12 18:59:49 +00:00
std::string part_dir;
2022-04-19 19:34:41 +00:00
void clearDirectory(
const std::string & dir,
bool keep_shared_data,
const MergeTreeDataPartChecksums & checksums,
const std::unordered_set<String> & skip_directories,
Poco::Logger * log,
bool is_projection) const;
2022-04-12 18:59:49 +00:00
};
class DataPartStorageBuilderOnDisk final : public IDataPartStorageBuilder
{
2022-04-21 19:19:13 +00:00
public:
2022-04-12 18:59:49 +00:00
DataPartStorageBuilderOnDisk(VolumePtr volume_, std::string root_path_, std::string part_dir_);
2022-04-19 19:34:41 +00:00
void setRelativePath(const std::string & path) override;
2022-04-12 18:59:49 +00:00
bool exists() const override;
bool exists(const std::string & path) const override;
void createDirectories() override;
2022-04-21 19:19:13 +00:00
void createProjection(const std::string & name) override;
2022-04-12 18:59:49 +00:00
2022-04-19 19:34:41 +00:00
std::string getRelativePath() const override { return part_dir; }
2022-04-12 18:59:49 +00:00
std::string getFullPath() const override;
2022-04-21 19:19:13 +00:00
std::string getFullRelativePath() const override;
2022-04-12 18:59:49 +00:00
std::unique_ptr<ReadBufferFromFileBase> readFile(
const std::string & path,
const ReadSettings & settings,
std::optional<size_t> read_hint,
std::optional<size_t> file_size) const override;
std::unique_ptr<WriteBufferFromFileBase> writeFile(
const String & path,
size_t buf_size) override;
void removeFile(const String & path) override;
void removeRecursive() override;
2022-04-21 19:19:13 +00:00
void removeSharedRecursive(bool keep_in_remote_fs) override;
SyncGuardPtr getDirectorySyncGuard() const override;
void createHardLinkFrom(const IDataPartStorage & source, const std::string & from, const std::string & to) const override;
2022-04-12 18:59:49 +00:00
ReservationPtr reserve(UInt64 bytes) override;
DataPartStorageBuilderPtr getProjection(const std::string & name) const override;
2022-04-19 19:34:41 +00:00
DataPartStoragePtr getStorage() const override;
2022-04-12 18:59:49 +00:00
private:
VolumePtr volume;
std::string root_path;
std::string part_dir;
2022-04-05 19:12:48 +00:00
};
}