2018-11-19 08:17:09 +00:00
|
|
|
#pragma once
|
2018-12-05 13:24:45 +00:00
|
|
|
|
2021-10-27 23:10:39 +00:00
|
|
|
#include <Common/config.h>
|
2019-08-04 00:19:03 +00:00
|
|
|
|
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-10-27 23:10:39 +00:00
|
|
|
#include <hdfs/hdfs.h>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2020-10-30 19:40:16 +00:00
|
|
|
#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-06-03 11:34:47 +00:00
|
|
|
class ReadBufferFromHDFS : public 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-10-15 08:36:26 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & config_,
|
|
|
|
size_t buf_size_ = DBMS_DEFAULT_BUFFER_SIZE,
|
2021-10-20 22:57:43 +00:00
|
|
|
size_t read_until_position_ = 0);
|
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
|