ClickHouse/src/IO/SeekAvoidingReadBuffer.h

32 lines
824 B
C++
Raw Normal View History

2020-07-13 00:24:49 +00:00
#pragma once
#include <IO/ReadBufferFromFileBase.h>
namespace DB
{
2020-07-13 04:15:37 +00:00
/// `SeekAvoidingReadBuffer` prefers sequential reads over seeks within specified window.
/// It is useful in network and spinning disk storage media when seek is relatively expensive
/// operation.
/// See also: `merge_tree_min_rows_for_seek`.
2020-07-13 00:24:49 +00:00
class SeekAvoidingReadBuffer : public ReadBufferFromFileBase
{
std::unique_ptr<ReadBufferFromFileBase> nested;
2020-07-13 04:15:37 +00:00
UInt64 min_bytes_for_seek; /// Minimum positive seek offset which shall be executed using seek operation.
2020-07-13 00:24:49 +00:00
public:
SeekAvoidingReadBuffer(std::unique_ptr<ReadBufferFromFileBase> nested_, UInt64 min_bytes_for_seek_);
std::string getFileName() const override;
off_t getPosition() override;
off_t seek(off_t off, int whence) override;
bool nextImpl() override;
};
}