2018-11-19 08:17:09 +00:00
|
|
|
#pragma once
|
2018-12-05 13:24:45 +00:00
|
|
|
|
2019-08-04 00:19:03 +00:00
|
|
|
#include <Common/config.h>
|
|
|
|
|
2018-12-05 13:24:45 +00:00
|
|
|
#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>
|
2021-04-03 12:02:29 +00:00
|
|
|
#include <hdfs/hdfs.h> // Y_IGNORE
|
2020-10-30 19:40:16 +00:00
|
|
|
#include <common/types.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2021-04-04 09:08:09 +00:00
|
|
|
#include <IO/SeekableReadBuffer.h>
|
2020-10-30 19:40:16 +00:00
|
|
|
|
|
|
|
|
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_,
|
2021-04-20 21:40:01 +00:00
|
|
|
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
|
|
|
|
2018-12-05 13:24:45 +00:00
|
|
|
#endif
|