apache / arrow

Apache Arrow is the universal columnar format and multi-language toolbox for fast data interchange and in-memory analytics
https://arrow.apache.org/
Apache License 2.0
14.55k stars 3.54k forks source link

[C++] IO: InputStream::Advance will always read from Stream #43408

Open mapleFU opened 3 months ago

mapleFU commented 3 months ago

Describe the enhancement requested

class ARROW_EXPORT InputStream : virtual public FileInterface, virtual public Readable {
 public:
  /// \brief Advance or skip stream indicated number of bytes
  /// \param[in] nbytes the number to move forward
  /// \return Status
  Status Advance(int64_t nbytes);
Status InputStream::Advance(int64_t nbytes) { return Read(nbytes).status(); }

Advance is always call read, since it's not a virtual function

Component(s)

C++

mapleFU commented 3 months ago

Besides, the interface Advance even doesn't gurantee the nbytes are exactly skipped... Because Read may read less than expected..