JingsongLi commented on code in PR #8406:
URL: https://github.com/apache/paimon/pull/8406#discussion_r3510235022
##########
paimon-python/pypaimon/common/file_io.py:
##########
@@ -48,6 +48,35 @@ def pread(stream, length: int, offset: int) -> bytes:
return os.pread(stream.fileno(), length, offset)
+def read_file_range(file_io, path, offset, length):
+ """Read a byte range from a file. Thread-safe."""
+ stream = file_io.new_input_stream(path)
+ try:
+ if supports_pread(stream):
+ return pread(stream, length, offset)
Review Comment:
This breaks valid `BlobDescriptor.length == -1` descriptors.
`OffsetInputStream` treats `-1` as “read to EOF”, but this path passes `-1`
into `read_at`/`os.pread`, which raises (for example, local FileIO hits
`OSError: [Errno 22] Invalid argument`). Please special-case negative lengths
by seeking to `offset` and reading to EOF, or compute the remaining file size
before using `pread`, and add coverage for `BlobDescriptor(..., length=-1)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]