MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ReadNBytes

Method ReadNBytes

tensorflow/core/lib/io/zlib_inputstream.cc:189–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189Status ZlibInputStream::ReadNBytes(int64 bytes_to_read, string* result) {
190 result->clear();
191 // Read as many bytes as possible from cache.
192 bytes_to_read -= ReadBytesFromCache(bytes_to_read, result);
193
194 while (bytes_to_read > 0) {
195 // At this point we can be sure that cache has been emptied.
196 DCHECK_EQ(NumUnreadBytes(), 0);
197
198 // Now that the cache is empty we need to inflate more data.
199
200 // Step 1. Setup output stream.
201 z_stream_def_->stream->next_out = z_stream_def_->output.get();
202 next_unread_byte_ = reinterpret_cast<char*>(z_stream_def_->output.get());
203 z_stream_def_->stream->avail_out = output_buffer_capacity_;
204
205 // Step 2. Try to inflate some input data.
206 TF_RETURN_IF_ERROR(Inflate());
207
208 // Step 3. Read any data produced by inflate. If no progress was made by
209 // inflate, read more compressed data from the input stream.
210 if (NumUnreadBytes() == 0) {
211 TF_RETURN_IF_ERROR(ReadFromStream());
212 } else {
213 bytes_to_read -= ReadBytesFromCache(bytes_to_read, result);
214 }
215 }
216
217 return Status::OK();
218}
219
220int64 ZlibInputStream::Tell() const { return bytes_read_; }
221

Callers 1

ReadFromStreamMethod · 0.45

Calls 2

clearMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected