ClickHouse/src/Processors/Formats/Impl/ArrowBufferedStreams.h

69 lines
1.6 KiB
C++
Raw Normal View History

2020-05-03 18:12:14 +00:00
#pragma once
#include "config_formats.h"
2020-05-04 00:58:10 +00:00
#if USE_ARROW || USE_ORC || USE_PARQUET
2020-05-03 18:12:14 +00:00
#include <arrow/io/interfaces.h>
namespace DB
{
2020-05-05 12:56:54 +00:00
class ReadBuffer;
class SeekableReadBuffer;
class WriteBuffer;
2020-05-03 18:12:14 +00:00
class ArrowBufferedOutputStream : public arrow::io::OutputStream
{
public:
explicit ArrowBufferedOutputStream(WriteBuffer & out_);
2020-05-03 18:12:14 +00:00
// FileInterface
2020-05-05 12:56:54 +00:00
arrow::Status Close() override;
2020-05-03 18:12:14 +00:00
2020-05-05 12:56:54 +00:00
arrow::Status Tell(int64_t * position) const override;
2020-05-03 18:12:14 +00:00
bool closed() const override { return !is_open; }
// Writable
2020-05-05 12:56:54 +00:00
arrow::Status Write(const void * data, int64_t length) override;
2020-05-03 18:12:14 +00:00
private:
WriteBuffer & out;
2020-05-03 18:12:14 +00:00
int64_t total_length = 0;
bool is_open = false;
ARROW_DISALLOW_COPY_AND_ASSIGN(ArrowBufferedOutputStream);
};
class RandomAccessFileFromSeekableReadBuffer : public arrow::io::RandomAccessFile
{
public:
RandomAccessFileFromSeekableReadBuffer(SeekableReadBuffer & in_, off_t file_size_);
arrow::Status GetSize(int64_t * size) override;
arrow::Status Close() override;
arrow::Status Tell(int64_t * position) const override;
bool closed() const override { return !is_open; }
arrow::Status Read(int64_t nbytes, int64_t * bytes_read, void * out) override;
arrow::Status Read(int64_t nbytes, std::shared_ptr<arrow::Buffer> * out) override;
arrow::Status Seek(int64_t position) override;
private:
SeekableReadBuffer & in;
off_t file_size;
bool is_open = false;
ARROW_DISALLOW_COPY_AND_ASSIGN(RandomAccessFileFromSeekableReadBuffer);
};
std::shared_ptr<arrow::io::RandomAccessFile> asArrowFile(ReadBuffer & in);
2020-05-03 18:12:14 +00:00
}
#endif