| 33 | namespace impala { |
| 34 | |
| 35 | Status RuntimeProfile::Compress(vector<uint8_t>* out) const { |
| 36 | Status status; |
| 37 | TRuntimeProfileTree thrift_object; |
| 38 | const_cast<RuntimeProfile*>(this)->ToThrift(&thrift_object); |
| 39 | ThriftSerializer serializer(true); |
| 40 | vector<uint8_t> serialized_buffer; |
| 41 | RETURN_IF_ERROR(serializer.SerializeToVector(&thrift_object, &serialized_buffer)); |
| 42 | |
| 43 | // Compress the serialized thrift string. This uses string keys and is very |
| 44 | // easy to compress. |
| 45 | scoped_ptr<Codec> compressor; |
| 46 | Codec::CodecInfo codec_info(THdfsCompression::DEFAULT); |
| 47 | RETURN_IF_ERROR(Codec::CreateCompressor(NULL, false, codec_info, &compressor)); |
| 48 | const auto close_compressor = |
| 49 | MakeScopeExitTrigger([&compressor]() { compressor->Close(); }); |
| 50 | |
| 51 | int64_t max_compressed_size = compressor->MaxOutputLen(serialized_buffer.size()); |
| 52 | DCHECK_GT(max_compressed_size, 0); |
| 53 | out->resize(max_compressed_size); |
| 54 | int64_t result_len = out->size(); |
| 55 | uint8_t* compressed_buffer_ptr = out->data(); |
| 56 | RETURN_IF_ERROR(compressor->ProcessBlock(true, serialized_buffer.size(), |
| 57 | serialized_buffer.data(), &result_len, &compressed_buffer_ptr)); |
| 58 | out->resize(result_len); |
| 59 | return Status::OK(); |
| 60 | } |
| 61 | |
| 62 | Status RuntimeProfile::SerializeToArchiveString(string* out) const { |
| 63 | stringstream ss; |
nothing calls this directly
no test coverage detected