ClickHouse/src/Storages/HDFS/ReadBufferFromHDFS.h

55 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>
2021-04-04 09:08:09 +00:00
#include <IO/SeekableReadBuffer.h>
#include <IO/WithFileName.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).
*/
2022-04-26 12:57:02 +00:00
class ReadBufferFromHDFS : public SeekableReadBuffer, public WithFileName, public WithFileSize
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-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;
2022-04-26 12:57:02 +00:00
std::optional<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;
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