2014-01-15 14:53:20 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/IO/CompressedReadBufferBase.h>
|
2015-03-31 11:16:34 +00:00
|
|
|
|
#include <DB/IO/ReadBufferFromFileBase.h>
|
|
|
|
|
|
2016-10-25 06:49:24 +00:00
|
|
|
|
#include <time.h>
|
2015-03-31 11:16:34 +00:00
|
|
|
|
#include <memory>
|
2014-01-15 14:53:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
|
|
2014-01-15 14:53:20 +00:00
|
|
|
|
/// В отличие от CompressedReadBuffer, умеет делать seek.
|
|
|
|
|
class CompressedReadBufferFromFile : public CompressedReadBufferBase, public BufferWithOwnMemory<ReadBuffer>
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
/** В любой момент выполняется одно из двух:
|
|
|
|
|
* a) size_compressed = 0
|
|
|
|
|
* b)
|
|
|
|
|
* - working_buffer содержит целиком один блок.
|
|
|
|
|
* - file_in смотрит в конец этого блока.
|
|
|
|
|
* - size_compressed содержит сжатый размер этого блока.
|
|
|
|
|
*/
|
2015-03-31 11:16:34 +00:00
|
|
|
|
std::unique_ptr<ReadBufferFromFileBase> p_file_in;
|
|
|
|
|
ReadBufferFromFileBase & file_in;
|
2014-03-26 00:17:31 +00:00
|
|
|
|
size_t size_compressed = 0;
|
2014-01-15 14:53:20 +00:00
|
|
|
|
|
2016-10-25 06:49:24 +00:00
|
|
|
|
bool nextImpl() override;
|
2014-01-15 14:53:20 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2015-07-08 17:59:44 +00:00
|
|
|
|
CompressedReadBufferFromFile(
|
2016-10-25 06:49:24 +00:00
|
|
|
|
const std::string & path, size_t estimated_size, size_t aio_threshold, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE);
|
2014-01-15 14:53:20 +00:00
|
|
|
|
|
2016-10-25 06:49:24 +00:00
|
|
|
|
void seek(size_t offset_in_compressed_file, size_t offset_in_decompressed_block);
|
2014-01-15 14:53:20 +00:00
|
|
|
|
|
2016-10-25 06:49:24 +00:00
|
|
|
|
size_t readBig(char * to, size_t n) override;
|
2015-12-13 04:52:13 +00:00
|
|
|
|
|
|
|
|
|
void setProfileCallback(const ReadBufferFromFileBase::ProfileCallback & profile_callback_, clockid_t clock_type_ = CLOCK_MONOTONIC_COARSE)
|
|
|
|
|
{
|
|
|
|
|
file_in.setProfileCallback(profile_callback_, clock_type_);
|
|
|
|
|
}
|
2014-01-15 14:53:20 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|