Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility of declaring RandomAccessFile::GetStream as a virtual function? #41616

Open
yukkit opened this issue May 10, 2024 · 0 comments
Open
Labels
Component: C++ Type: usage Issue is a user question

Comments

@yukkit
Copy link

yukkit commented May 10, 2024

Describe the usage question you have. Please include as many useful details as possible.

Hello,

I would like to propose an enhancement for the Arrow project.
Specifically, I would like to discuss the possibility of declaring the method RandomAccessFile::GetStream as a virtual function.

Currently, the method can be found at

static Result<std::shared_ptr<InputStream>> GetStream(
std::shared_ptr<RandomAccessFile> file, int64_t file_offset, int64_t nbytes);

I suggest declaring this method as a virtual function and providing the implementation

Result<std::shared_ptr<InputStream>> RandomAccessFile::GetStream(
std::shared_ptr<RandomAccessFile> file, int64_t file_offset, int64_t nbytes) {
if (file_offset < 0) {
return Status::Invalid("file_offset should be a positive value, got: ", file_offset);
}
if (nbytes < 0) {
return Status::Invalid("nbytes should be a positive value, got: ", nbytes);
}
return std::make_shared<FileSegmentReader>(std::move(file), file_offset, nbytes);
}
as the default implementation.
This would allow users to override the GetStream method by inheriting from the RandomAccessFile class and providing their own implementation to return a custom InputStream.

We are currently using Arrow C++ in our project, and it would greatly benefit us if we could receive our own implementation of InputStream from the GetStream method.

Component(s)

C++

@yukkit yukkit added the Type: usage Issue is a user question label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: C++ Type: usage Issue is a user question
Projects
None yet
Development

No branches or pull requests

1 participant