ClickHouse/src/IO/ReadBufferFromFileBase.cpp

43 lines
995 B
C++
Raw Normal View History

#include <IO/ReadBufferFromFileBase.h>
#include <IO/Progress.h>
2022-12-11 03:26:07 +00:00
#include <Interpreters/Context.h>
namespace DB
{
ReadBufferFromFileBase::ReadBufferFromFileBase() : BufferWithOwnMemory<SeekableReadBuffer>(0)
{
}
ReadBufferFromFileBase::ReadBufferFromFileBase(
size_t buf_size,
char * existing_memory,
size_t alignment,
std::optional<size_t> file_size_)
: BufferWithOwnMemory<SeekableReadBuffer>(buf_size, existing_memory, alignment)
, file_size(file_size_)
{
}
2020-03-08 21:18:53 +00:00
ReadBufferFromFileBase::~ReadBufferFromFileBase() = default;
2024-07-18 02:54:36 +00:00
std::optional<size_t> ReadBufferFromFileBase::tryGetFileSize()
2022-05-25 14:49:40 +00:00
{
2024-07-18 02:54:36 +00:00
return file_size;
2022-05-25 14:49:40 +00:00
}
2022-12-11 03:26:07 +00:00
void ReadBufferFromFileBase::setProgressCallback(ContextPtr context)
{
auto file_progress_callback = context->getFileProgressCallback();
if (!file_progress_callback)
return;
setProfileCallback([file_progress_callback](const ProfileInfo & progress)
{
file_progress_callback(FileProgress(progress.bytes_read));
2022-12-11 03:26:07 +00:00
});
}
}