MCPcopy Create free account
hub / github.com/apache/impala / CompressStringToBuffer

Function CompressStringToBuffer

be/src/util/webserver.cc:245–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245Status CompressStringToBuffer(const string& content,
246 vector<uint8_t>& output) {
247 // Declare the compressor
248 scoped_ptr<Codec> compressor;
249 Codec::CodecInfo codec_info(THdfsCompression::GZIP, Z_BEST_SPEED);
250 LOG_AND_RETURN_IF_ERROR(Codec::CreateCompressor(NULL, false, codec_info, &compressor));
251 auto compressor_cleanup = MakeScopeExitTrigger([&compressor]() {
252 compressor->Close();
253 });
254 // Interpret the data in the required form, do not reallocate
255 uint8_t* content_buffer = reinterpret_cast<uint8_t*>(const_cast<char*>(
256 content.data()));
257 // Allocate the necessary space
258 int64_t compressed_length = compressor->MaxOutputLen(content.size(), content_buffer);
259 output.resize(compressed_length);
260 // Transform the space into necessary form
261 uint8_t* compressed_buffer = output.data();
262 LOG_AND_RETURN_IF_ERROR(compressor->ProcessBlock(true, content.size(), content_buffer,
263 &compressed_length, &compressed_buffer));
264 output.resize(compressed_length);
265 return Status::OK();
266}
267
268// Return the address of the remote user from the squeasel request info.
269kudu::Sockaddr GetRemoteAddress(const struct sq_request_info* req) {

Callers 1

SendResponseMethod · 0.85

Calls 8

MakeScopeExitTriggerFunction · 0.85
OKFunction · 0.85
resizeMethod · 0.80
CloseMethod · 0.45
dataMethod · 0.45
MaxOutputLenMethod · 0.45
sizeMethod · 0.45
ProcessBlockMethod · 0.45

Tested by

no test coverage detected