2022-01-05 11:51:50 +00:00
|
|
|
#include "PartMetadataManagerOrdinary.h"
|
|
|
|
|
|
|
|
#include <IO/ReadBufferFromFileBase.h>
|
2022-05-29 07:28:02 +00:00
|
|
|
#include <Compression/CompressedReadBufferFromFile.h>
|
2022-01-05 11:51:50 +00:00
|
|
|
#include <Disks/IDisk.h>
|
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-04-22 16:58:09 +00:00
|
|
|
static std::unique_ptr<ReadBufferFromFileBase> openForReading(const DataPartStoragePtr & data_part_storage, const String & path)
|
2022-01-05 11:51:50 +00:00
|
|
|
{
|
2022-04-22 16:58:09 +00:00
|
|
|
size_t file_size = data_part_storage->getFileSize(path);
|
|
|
|
return data_part_storage->readFile(path, ReadSettings().adjustBufferSize(file_size), file_size, std::nullopt);
|
2022-01-05 11:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PartMetadataManagerOrdinary::PartMetadataManagerOrdinary(const IMergeTreeDataPart * part_) : IPartMetadataManager(part_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-29 07:28:02 +00:00
|
|
|
std::unique_ptr<ReadBuffer> PartMetadataManagerOrdinary::read(const String & file_name) const
|
2022-01-05 11:51:50 +00:00
|
|
|
{
|
2022-08-28 02:19:14 +00:00
|
|
|
auto res = openForReading(part->data_part_storage, file_name);
|
2022-05-29 07:28:02 +00:00
|
|
|
|
2022-08-28 02:19:14 +00:00
|
|
|
if (isCompressedFromFileName(file_name))
|
|
|
|
return std::make_unique<CompressedReadBufferFromFile>(std::move(res));
|
|
|
|
|
|
|
|
return res;
|
2022-01-05 11:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PartMetadataManagerOrdinary::exists(const String & file_name) const
|
|
|
|
{
|
2022-04-22 16:58:09 +00:00
|
|
|
return part->data_part_storage->exists(file_name);
|
2022-01-05 11:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|