ClickHouse/src/Storages/HDFS/ReadBufferFromHDFS.h

58 lines
1.3 KiB
C++
Raw Normal View History

2018-11-19 08:17:09 +00:00
#pragma once
2021-10-27 23:10:39 +00:00
#include <Common/config.h>
#if USE_HDFS
2018-11-19 08:17:09 +00:00
#include <IO/ReadBuffer.h>
#include <IO/BufferWithOwnMemory.h>
2022-04-13 08:06:19 +00:00
#include <IO/AsynchronousReader.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>
#include <Interpreters/Context.h>
#include <IO/ReadBufferFromFileBase.h>
2018-11-19 08:17:09 +00:00
namespace DB
{
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).
*/
class ReadBufferFromHDFS : public ReadBufferFromFileBase
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:
ReadBufferFromHDFS(
const String & hdfs_uri_,
const String & hdfs_file_path_,
const Poco::Util::AbstractConfiguration & config_,
const ReadSettings & read_settings_,
2022-09-01 14:46:46 +00:00
size_t read_until_position_ = 0,
bool use_external_buffer = false);
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;
2022-05-25 14:49:40 +00:00
size_t getFileSize() override;
2021-10-31 19:53:24 +00:00
2022-02-16 10:27:23 +00:00
size_t getFileOffsetOfBufferEnd() const override;
2022-06-06 04:58:22 +00:00
IAsynchronousReader::Result readInto(char * data, size_t size, size_t offset, size_t ignore) override;
2022-04-13 08:06:19 +00:00
String getFileName() const override;
2021-04-04 09:08:09 +00:00
private:
std::unique_ptr<ReadBufferFromHDFSImpl> impl;
2022-09-01 14:46:46 +00:00
bool use_external_buffer;
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