#pragma once #include "config.h" #if USE_HDFS #include #include #include #include #include #include #include #include #include #include namespace DB { class IAsynchronousReader; class AsynchronousReadBufferFromHDFS : public BufferWithOwnMemory, public WithFileName, public WithFileSize { public: AsynchronousReadBufferFromHDFS( IAsynchronousReader & reader_, const ReadSettings & settings_, std::shared_ptr impl_); ~AsynchronousReadBufferFromHDFS() override; off_t seek(off_t offset_, int whence) override; void prefetch(Priority priority) override; size_t getFileSize() override; String getFileName() const override; off_t getPosition() override; size_t getFileOffsetOfBufferEnd() const override; private: bool nextImpl() override; void finalize(); bool hasPendingDataToRead(); std::future asyncReadInto(char * data, size_t size, Priority priority); IAsynchronousReader & reader; Priority base_priority; std::shared_ptr impl; std::future prefetch_future; Memory<> prefetch_buffer; size_t file_offset_of_buffer_end = 0; std::optional read_until_position; bool use_prefetch; LoggerPtr log; /// Metrics to profile prefetch Stopwatch interval_watch; Int64 sum_interval{0}; Int64 sum_duration{0}; Int64 sum_wait{0}; Int64 next_times{0}; Int64 seek_times{0}; }; } #endif