#pragma once #include #include #include namespace DB { class IVolume; using VolumePtr = std::shared_ptr; class DataPartStorageOnDisk final : public IDataPartStorage { public: DataPartStorageOnDisk(VolumePtr volume_, std::string root_path_, std::string part_dir_); std::unique_ptr readFile( const std::string & path, const ReadSettings & settings, std::optional read_hint, std::optional file_size) const override; bool exists() const override; bool exists(const std::string & path) const override; bool isDirectory(const std::string & path) const override; Poco::Timestamp getLastModified() const override; size_t getFileSize(const std::string & path) const override; UInt32 getRefCount(const String & path) const override; DataPartStorageIteratorPtr iterate() const override; DataPartStorageIteratorPtr iterateDirectory(const std::string & path) const override; void remove( bool can_remove_shared_data, const NameSet & names_not_to_remove, const MergeTreeDataPartChecksums & checksums, std::list 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; } std::string getFullPath() const override; std::string getFullRootPath() const override; std::string getFullRelativePath() const override; UInt64 calculateTotalSizeOnDisk() const override; bool isStoredOnRemoteDisk() const override; bool supportZeroCopyReplication() const override; bool supportParallelWrite() const override; bool isBroken() const override; std::string getDiskPathForLogs() const override; void writeChecksums(const MergeTreeDataPartChecksums & checksums, const WriteSettings & settings) const override; void writeColumns(const NamesAndTypesList & columns, const WriteSettings & settings) const override; void writeVersionMetadata(const VersionMetadata & version, bool fsync_part_dir) const override; void appendCSNToVersionMetadata(const VersionMetadata & version, VersionMetadata::WhichCSN which_csn) const override; void appendRemovalTIDToVersionMetadata(const VersionMetadata & version, bool clear) const override; void writeDeleteOnDestroyMarker(Poco::Logger * log) const override; void removeDeleteOnDestroyMarker() const override; void removeVersionMetadata() const override; void loadVersionMetadata(VersionMetadata & version, Poco::Logger * log) const override; void checkConsistency(const MergeTreeDataPartChecksums & checksums) const override; ReservationPtr reserve(UInt64 bytes) const override; ReservationPtr tryReserve(UInt64 bytes) const override; String getUniqueId() const override; bool shallParticipateInMerges(const IStoragePolicy &) const override; size_t getVolumeIndex(const IStoragePolicy &) const override; 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, bool make_source_readonly, std::function save_metadata_callback, bool copy_instead_of_hardlink) const override; DataPartStoragePtr clone( const std::string & to, const std::string & dir_path, Poco::Logger * log) const override; void rename(const String & new_relative_path, Poco::Logger * log, bool remove_new_dir_if_exists, bool fsync_part_dir) override; std::string getName() const override; std::string getDiskType() const override; DisksSet::const_iterator isStoredOnDisk(const DisksSet & disks) const override; DataPartStoragePtr getProjection(const std::string & name) const override; DiskPtr getDisk() const; private: VolumePtr volume; std::string root_path; std::string part_dir; void clearDirectory( const std::string & dir, bool can_remove_shared_data, const NameSet & names_not_to_remove, const MergeTreeDataPartChecksums & checksums, const std::unordered_set & skip_directories, Poco::Logger * log, bool is_projection) const; }; class DataPartStorageBuilderOnDisk final : public IDataPartStorageBuilder { public: DataPartStorageBuilderOnDisk(VolumePtr volume_, std::string root_path_, std::string part_dir_); void setRelativePath(const std::string & path) override; bool exists() const override; bool exists(const std::string & path) const override; void createDirectories() override; void createProjection(const std::string & name) override; std::string getRelativePath() const override { return part_dir; } std::string getFullPath() const override; std::string getFullRelativePath() const override; std::unique_ptr readFile( const std::string & path, const ReadSettings & settings, std::optional read_hint, std::optional file_size) const override; std::unique_ptr writeFile( const String & path, size_t buf_size, const WriteSettings & settings) override; void removeFile(const String & path) override; void removeRecursive() override; 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; ReservationPtr reserve(UInt64 bytes) override; DataPartStorageBuilderPtr getProjection(const std::string & name) const override; DataPartStoragePtr getStorage() const override; private: VolumePtr volume; std::string root_path; std::string part_dir; }; }