ClickHouse/src/Storages/HDFS/ReadBufferFromHDFS.h

44 lines
940 B
C++
Raw Normal View History

2018-11-19 08:17:09 +00:00
#pragma once
#include <Common/config.h>
#if USE_HDFS
2018-11-19 08:17:09 +00:00
#include <IO/ReadBuffer.h>
#include <IO/BufferWithOwnMemory.h>
2018-12-27 15:23:37 +00:00
#include <string>
2019-01-17 11:26:29 +00:00
#include <memory>
#include <hdfs/hdfs.h> // Y_IGNORE
#include <common/types.h>
#include <Interpreters/Context.h>
2021-04-04 09:08:09 +00:00
#include <IO/SeekableReadBuffer.h>
2018-11-19 08:17:09 +00:00
namespace DB
{
2021-04-04 09:08:09 +00:00
2019-01-18 10:57:00 +00:00
/** Accepts HDFS path to file and opens it.
2019-01-17 11:26:29 +00:00
* Closes file by himself (thus "owns" a file descriptor).
*/
2021-04-04 09:08:09 +00:00
class ReadBufferFromHDFS : public BufferWithOwnMemory<SeekableReadBuffer>
2019-01-17 11:26:29 +00:00
{
2021-04-20 07:53:55 +00:00
struct ReadBufferFromHDFSImpl;
2021-04-04 09:08:09 +00:00
2019-01-17 11:26:29 +00:00
public:
2021-04-20 07:53:55 +00:00
ReadBufferFromHDFS(const String & hdfs_uri_, const String & hdfs_file_path_,
const Poco::Util::AbstractConfiguration & config_, size_t buf_size_ = DBMS_DEFAULT_BUFFER_SIZE);
2021-04-04 09:08:09 +00:00
2020-03-09 01:03:43 +00:00
~ReadBufferFromHDFS() override;
2018-11-19 08:17:09 +00:00
2019-01-17 11:26:29 +00:00
bool nextImpl() override;
2021-04-04 09:08:09 +00:00
off_t seek(off_t offset_, int whence) override;
off_t getPosition() override;
private:
std::unique_ptr<ReadBufferFromHDFSImpl> impl;
2019-01-17 11:26:29 +00:00
};
2018-11-19 08:17:09 +00:00
}
2021-04-20 07:53:55 +00:00
#endif