#include "WithFileSize.h" #include #include #include #include namespace DB { template static std::optional getFileSize(T & in) { if (auto * with_file_size = dynamic_cast(&in)) { return with_file_size->getFileSize(); } return std::nullopt; } std::optional getFileSizeFromReadBuffer(ReadBuffer & in) { if (auto * delegate = dynamic_cast(&in)) { return getFileSize(delegate->getWrappedReadBuffer()); } else if (auto * compressed = dynamic_cast(&in)) { return getFileSize(compressed->getWrappedReadBuffer()); } return getFileSize(in); } bool isBufferWithFileSize(const ReadBuffer & in) { if (const auto * delegate = dynamic_cast(&in)) { return delegate->isWithFileSize(); } else if (const auto * compressed = dynamic_cast(&in)) { return isBufferWithFileSize(compressed->getWrappedReadBuffer()); } return dynamic_cast(&in) != nullptr; } }