Skip to content

Commit

Permalink
Merge pull request #242 from Altinity/backports/22.8.15/optimization_…
Browse files Browse the repository at this point in the history
…parquet_reader

Backport upstream ClickHouse#45478
  • Loading branch information
arthurpassos committed Mar 24, 2023
2 parents 0b958ed + 217b88e commit 94ae067
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/arrow
7 changes: 7 additions & 0 deletions src/Processors/Formats/Impl/ArrowBufferedStreams.cpp
Expand Up @@ -11,6 +11,7 @@
#include <IO/copyData.h>
#include <IO/PeekableReadBuffer.h>
#include <arrow/buffer.h>
#include <arrow/util/future.h>
#include <arrow/io/memory.h>
#include <arrow/result.h>
#include <Core/Settings.h>
Expand Down Expand Up @@ -95,6 +96,12 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> RandomAccessFileFromSeekableReadBu
return buffer;
}

arrow::Future<std::shared_ptr<arrow::Buffer>> RandomAccessFileFromSeekableReadBuffer::ReadAsync(const arrow::io::IOContext &, int64_t position, int64_t nbytes)
{
/// Just a stub to to avoid using internal arrow thread pool
return arrow::Future<std::shared_ptr<arrow::Buffer>>::MakeFinished(ReadAt(position, nbytes));
}

arrow::Status RandomAccessFileFromSeekableReadBuffer::Seek(int64_t position)
{
seekable_in.seek(position, SEEK_SET);
Expand Down
5 changes: 5 additions & 0 deletions src/Processors/Formats/Impl/ArrowBufferedStreams.h
Expand Up @@ -62,6 +62,11 @@ class RandomAccessFileFromSeekableReadBuffer : public arrow::io::RandomAccessFil

arrow::Result<std::shared_ptr<arrow::Buffer>> Read(int64_t nbytes) override;

/// Override async reading to avoid using internal arrow thread pool.
/// In our code we don't use async reading, so implementation is sync,
/// we just call ReadAt and return future with ready value.
arrow::Future<std::shared_ptr<arrow::Buffer>> ReadAsync(const arrow::io::IOContext&, int64_t position, int64_t nbytes) override;

arrow::Status Seek(int64_t position) override;

private:
Expand Down

0 comments on commit 94ae067

Please sign in to comment.