diff options
author | 2017-10-18 11:58:24 -0700 | |
---|---|---|
committer | 2017-10-18 12:09:48 -0700 | |
commit | f5ea388e48a38b935ebd36442f756c8974b7ce3f (patch) | |
tree | 701ee4039719113d837355c6c0091185bc4ed001 /tensorflow/core/lib/io/zlib_inputstream.cc | |
parent | f5d3bf42b892ecfbde2ce9eb45f00b76473c824a (diff) |
Implement ZlibInputStream::Tell() by keeping track of the number of bytes
consumed by the reader.
PiperOrigin-RevId: 172634455
Diffstat (limited to 'tensorflow/core/lib/io/zlib_inputstream.cc')
-rw-r--r-- | tensorflow/core/lib/io/zlib_inputstream.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tensorflow/core/lib/io/zlib_inputstream.cc b/tensorflow/core/lib/io/zlib_inputstream.cc index 4999d5cc90..984fbc2810 100644 --- a/tensorflow/core/lib/io/zlib_inputstream.cc +++ b/tensorflow/core/lib/io/zlib_inputstream.cc @@ -32,7 +32,8 @@ ZlibInputStream::ZlibInputStream( z_stream_input_(new Bytef[input_buffer_capacity_]), z_stream_output_(new Bytef[output_buffer_capacity_]), zlib_options_(zlib_options), - z_stream_(new z_stream) { + z_stream_(new z_stream), + bytes_read_(0) { InitZlibBuffer(); } @@ -45,6 +46,7 @@ ZlibInputStream::~ZlibInputStream() { Status ZlibInputStream::Reset() { TF_RETURN_IF_ERROR(input_stream_->Reset()); InitZlibBuffer(); + bytes_read_ = 0; return Status::OK(); } @@ -127,6 +129,7 @@ size_t ZlibInputStream::ReadBytesFromCache(size_t bytes_to_read, result->append(next_unread_byte_, can_read_bytes); next_unread_byte_ += can_read_bytes; } + bytes_read_ += can_read_bytes; return can_read_bytes; } @@ -170,8 +173,7 @@ Status ZlibInputStream::ReadNBytes(int64 bytes_to_read, string* result) { return Status::OK(); } -// TODO(srbs): Implement this. -int64 ZlibInputStream::Tell() const { return -1; } +int64 ZlibInputStream::Tell() const { return bytes_read_; } Status ZlibInputStream::Inflate() { int error = inflate(z_stream_.get(), zlib_options_.flush_mode); |