Skip to content

fix(python): read pyarrow files positionally in open_readable - #11074

Open
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:fix/py-arrow-readable
Open

jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:fix/py-arrow-readable

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

vortex.io.ReadAt's docs say pyarrow files work with vx.open_readable, but none do. A pyarrow file has size() and read_at, so it is read as a ReadBytesAt, but pyarrow's read_at takes (nbytes, offset). For the new test's file, a read of 65535 bytes at offset 420089 read 420089 bytes at offset 65535, and vx.open_readable(pa.OSFile(path)) failed with RuntimeError: Python read of 420089..485624 failed: BufferError: read_at(420089, 65535) returned 420089 bytes.

open_readable now wraps a pyarrow file in a ReadBytesAt that passes the arguments in pyarrow's order. It is the only caller of the native open_readable, so readable.rs needs 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 a pa.PythonFile, which pyarrow returns for fsspec filesystems, still reads one at a time. Any pyarrow filesystem's open_input_file returns such a file, so this also covers HadoopFileSystem, for which Vortex has no store; it was not tested against HDFS. pyarrow-stubs types read_at without parameters, so the call carries a ty: ignore.

Tests

The new test reads a file through pa.OSFile, pa.memory_map and LocalFileSystem().open_input_file; it fails on develop. The vortex-python suite, ruff, ty and the docs build and doctests pass.

AI assistance

Written with agentic AI assistance.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant