Repository navigation
fix(python): read pyarrow files positionally in open_readable - #11074
Open
jackylee-ch wants to merge 1 commit into
Open
jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
A pyarrow file has size() and read_at(), so open_readable read it as a ReadBytesAt, but pyarrow's read_at takes (nbytes, offset): every read asked for the wrong range, and opening any pyarrow file failed, although the vortex.io.ReadAt docs say pyarrow files are accepted. Wrap pyarrow files in a ReadBytesAt that passes the arguments in pyarrow's order. Signed-off-by: jackylee-ch <qcsd2011@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vortex.io.ReadAt's docs say pyarrow files work withvx.open_readable, but none do. A pyarrow file hassize()andread_at, so it is read as aReadBytesAt, but pyarrow'sread_attakes(nbytes, offset). For the new test's file, a read of 65535 bytes at offset 420089 read 420089 bytes at offset 65535, andvx.open_readable(pa.OSFile(path))failed withRuntimeError: Python read of 420089..485624 failed: BufferError: read_at(420089, 65535) returned 420089 bytes.open_readablenow wraps a pyarrow file in aReadBytesAtthat passes the arguments in pyarrow's order. It is the only caller of the nativeopen_readable, soreadable.rsneeds no pyarrow-specific mode. Reads through the wrapper are positional: an OS file or in-memory buffer serves several reads at once, with the GIL released while pyarrow reads, while apa.PythonFile, which pyarrow returns for fsspec filesystems, still reads one at a time. Any pyarrow filesystem'sopen_input_filereturns such a file, so this also coversHadoopFileSystem, for which Vortex has no store; it was not tested against HDFS. pyarrow-stubs typesread_atwithout parameters, so the call carries aty: ignore.Tests
The new test reads a file through
pa.OSFile,pa.memory_mapandLocalFileSystem().open_input_file; it fails ondevelop. The vortex-python suite, ruff, ty and the docs build and doctests pass.AI assistance
Written with agentic AI assistance.