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

Method WriteBlock

tensorflow/core/lib/io/table_builder.cc:165–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void TableBuilder::WriteBlock(BlockBuilder* block, BlockHandle* handle) {
166 // File format contains a sequence of blocks where each block has:
167 // block_data: uint8[n]
168 // type: uint8
169 // crc: uint32
170 assert(ok());
171 Rep* r = rep_;
172 StringPiece raw = block->Finish();
173
174 StringPiece block_contents;
175 CompressionType type = r->options.compression;
176 // TODO(postrelease): Support more compression options: zlib?
177 switch (type) {
178 case kNoCompression:
179 block_contents = raw;
180 break;
181
182 case kSnappyCompression: {
183 string* compressed = &r->compressed_output;
184 if (port::Snappy_Compress(raw.data(), raw.size(), compressed) &&
185 compressed->size() < raw.size() - (raw.size() / 8u)) {
186 block_contents = *compressed;
187 } else {
188 // Snappy not supported, or compressed less than 12.5%, so just
189 // store uncompressed form
190 block_contents = raw;
191 type = kNoCompression;
192 }
193 break;
194 }
195 }
196 WriteRawBlock(block_contents, type, handle);
197 r->compressed_output.clear();
198 block->Reset();
199}
200
201void TableBuilder::WriteRawBlock(const StringPiece& block_contents,
202 CompressionType type, BlockHandle* handle) {

Callers

nothing calls this directly

Calls 6

Snappy_CompressFunction · 0.50
FinishMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected