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
[C++] Create InputStream that is an isolated reader of a segment of a RandomAccessFile #22573
Comments
Wes McKinney / @wesm:
|
Antoine Pitrou / @pitrou: |
Wes McKinney / @wesm: Suppose you have a file that's 100MB and contains 10 10MB chunks. And you have different threads that do buffered processing of each chunk. If you naively pass |
Zherui Cao / @czxrrr: |
Wes McKinney / @wesm: /// \brief Reads a segment of a RandomAccessFile in a thread-safe manner
class FileSegmentReader : public InputStream {
public:
FileSegmentReader(std::shared_ptr<RandomAccessFile> file, int64_t offset, int64_t length) ...
...
private:
std::shared_ptr<RandomAccessFile> file_;
int64_t position_;
int64_t file_offset_;
int64_t total_length_;
} |
Antoine Pitrou / @pitrou: |
Deepak Majeti / @majetideepak: |
Wes McKinney / @wesm: |
Zherui Cao / @czxrrr: |
Wes McKinney / @wesm: |
If different threads wants to do buffered reads over different portions of a file (and they are unable to create their own separate file handles), they may clobber each other. I would propose creating an object that keeps the RandomAccessFile internally and implements the InputStream API in a way that is safe from other threads changing the file position
Reporter: Wes McKinney / @wesm
Assignee: Wes McKinney / @wesm
Related issues:
PRs and other links:
Note: This issue was originally created as ARROW-6180. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: