mapleFU commented on code in PR #43409:
URL: https://github.com/apache/arrow/pull/43409#discussion_r1691039593


##########
cpp/src/arrow/io/buffered.cc:
##########
@@ -434,6 +434,32 @@ class BufferedInputStream::Impl : public BufferedBase {
     return std::shared_ptr<Buffer>(std::move(buffer));
   }
 
+  Status Advance(int64_t nbytes) {
+    if (nbytes < 0) {
+      return Status::Invalid("Bytes to advance must be non-negative. 
Received:", nbytes);
+    }
+    if (nbytes == 0) {
+      return Status::OK();
+    }
+
+    if (nbytes < bytes_buffered_) {
+      ConsumeBuffer(nbytes);
+      return Status::OK();
+    }
+
+    // Invalidate buffered data, as with a Seek or large Read
+    int64_t remain_skip_bytes = nbytes - bytes_buffered_;
+    RewindBuffer();
+    // TODO(mwish): Considering using raw_->Advance if available,
+    // currently we don't have a way to know if the underlying stream supports 
fast
+    // skipping. So we just read and discard the data.

Review Comment:
   Maybe some code like:
   
   ```
     /// \brief Return true if InputStream is capable of zero copy Buffer reads
     ///
     /// Zero copy reads imply the use of Buffer-returning Read() overloads.
     virtual bool supports_zero_copy() const;
   ```
   
   Would help, a `supports_fast_advance` like 
https://github.com/ClickHouse/ClickHouse/blob/1b2fd51e090214deb340a76833bab7b4985eecfc/src/Disks/IO/ReadBufferFromRemoteFSGather.h#L19
 might work



-- 
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]

Reply via email to