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

Method Inflate

tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc:76–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76Status SnappyInputBuffer::Inflate() {
77 // Read length of compressed block.
78 uint32 compressed_block_length;
79 TF_RETURN_IF_ERROR(ReadCompressedBlockLength(&compressed_block_length));
80
81 // If the entire block is not in cache do a read from file.
82 if (avail_in_ < compressed_block_length) {
83 TF_RETURN_IF_ERROR(ReadFromFile());
84 if (avail_in_ < compressed_block_length) {
85 if (compressed_block_length > input_buffer_capacity_) {
86 return errors::ResourceExhausted(
87 "Input buffer(size: ", input_buffer_capacity_,
88 " bytes) too small. Should be larger ", "than ",
89 compressed_block_length, " bytes.");
90 } else {
91 return errors::DataLoss(
92 strings::StrCat("Failed to read ", compressed_block_length,
93 " bytes from file. Possible data corruption."));
94 }
95 }
96 }
97
98 size_t uncompressed_length;
99 if (!port::Snappy_GetUncompressedLength(next_in_, compressed_block_length,
100 &uncompressed_length)) {
101 return errors::DataLoss("Parsing error in Snappy_GetUncompressedLength");
102 }
103
104 // Output buffer must have been cleared before uncompressing more input.
105 DCHECK_EQ(avail_out_, 0);
106
107 // Output buffer must be large enough to fit the uncompressed block.
108 DCHECK_GE(output_buffer_capacity_, uncompressed_length);
109 next_out_ = output_buffer_.get();
110
111 bool status = port::Snappy_Uncompress(next_in_, compressed_block_length,
112 output_buffer_.get());
113 if (!status) {
114 return errors::DataLoss("Snappy_Uncompress failed");
115 }
116 next_in_ += compressed_block_length;
117 avail_in_ -= compressed_block_length;
118 avail_out_ += uncompressed_length;
119 return Status::OK();
120}
121
122Status SnappyInputBuffer::ReadCompressedBlockLength(uint32* length) {
123 *length = 0;

Callers

nothing calls this directly

Calls 5

ResourceExhaustedFunction · 0.85
StrCatFunction · 0.50
Snappy_UncompressFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected