ClickHouse/dbms/src/IO/createReadBufferFromFileBase.cpp

25 lines
821 B
C++
Raw Normal View History

#include <DB/IO/createReadBufferFromFileBase.h>
#include <DB/IO/ReadBufferFromFile.h>
#include <DB/IO/ReadBufferAIO.h>
#include <DB/Common/ProfileEvents.h>
namespace DB
{
2016-06-25 04:29:09 +00:00
std::unique_ptr<ReadBufferFromFileBase> createReadBufferFromFileBase(const std::string & filename_, size_t estimated_size,
2015-04-13 15:02:39 +00:00
size_t aio_threshold, size_t buffer_size_, int flags_, char * existing_memory_, size_t alignment)
{
2015-04-13 15:02:39 +00:00
if ((aio_threshold == 0) || (estimated_size < aio_threshold))
{
ProfileEvents::increment(ProfileEvents::CreatedReadBufferOrdinary);
2016-06-25 04:29:09 +00:00
return std::make_unique<ReadBufferFromFile>(filename_, buffer_size_, flags_, existing_memory_, alignment);
}
else
{
ProfileEvents::increment(ProfileEvents::CreatedReadBufferAIO);
2016-06-25 04:29:09 +00:00
return std::make_unique<ReadBufferAIO>(filename_, buffer_size_, flags_, existing_memory_);
}
}
}