pitrou commented on code in PR #13144:
URL: https://github.com/apache/arrow/pull/13144#discussion_r876054820
##########
python/pyarrow/io.pxi:
##########
@@ -395,6 +395,38 @@ cdef class NativeFile(_Weakrefable):
return PyObject_to_object(obj)
+ def get_stream(self, file_offset, nbytes):
+ """
+ Returns an input stream that reads a file segment independent of the
+ state of the file.
+
+ Allows reading portions of a random access file as an input stream
+ without interfering with each other.
+
+ Parameters
+ ----------
+ file_offset : int
+ nbytes : int
+
+ Returns
+ -------
+ data : bytes
+ """
+ cdef:
+ shared_ptr[CInputStream] data
+ int64_t c_file_offset
+ int64_t c_nbytes
+
+ c_file_offset = file_offset
+ c_nbytes = nbytes
+
+ handle = self.get_random_access_file()
+
+ data = <shared_ptr[CInputStream]> GetResultValue(
+ handle.get().GetStream(self.read(), c_file_offset, c_nbytes))
Review Comment:
`GetStream` being a static method, you shouldn't call it on an instance.
Also, I'm curious why you're passing `self.read()` here? The goal is _not_ to
read data immediately.
--
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]