| 174 | } |
| 175 | |
| 176 | Status RowBatch::FromProtobuf(const RowDescriptor* row_desc, |
| 177 | const RowBatchHeaderPB& header, const kudu::Slice& input_tuple_offsets, |
| 178 | const kudu::Slice& input_tuple_data, MemTracker* mem_tracker, |
| 179 | BufferPool::ClientHandle* client, unique_ptr<RowBatch>* row_batch_ptr) { |
| 180 | unique_ptr<RowBatch> row_batch(new RowBatch(row_desc, header, mem_tracker)); |
| 181 | |
| 182 | DCHECK(client != nullptr); |
| 183 | row_batch->tuple_ptrs_info_.reset(new BufferInfo()); |
| 184 | row_batch->tuple_ptrs_info_->client = client; |
| 185 | BufferPool::BufferHandle* tuple_ptrs_buffer = &(row_batch->tuple_ptrs_info_->buffer); |
| 186 | RETURN_IF_ERROR( |
| 187 | row_batch->AllocateBuffer(client, row_batch->tuple_ptrs_size_, tuple_ptrs_buffer)); |
| 188 | row_batch->tuple_ptrs_ = reinterpret_cast<Tuple**>(tuple_ptrs_buffer->data()); |
| 189 | |
| 190 | const int64_t uncompressed_size = header.uncompressed_size(); |
| 191 | BufferPool::BufferHandle tuple_data_buffer; |
| 192 | RETURN_IF_ERROR( |
| 193 | row_batch->AllocateBuffer(client, uncompressed_size, &tuple_data_buffer)); |
| 194 | uint8_t* tuple_data = tuple_data_buffer.data(); |
| 195 | row_batch->AddBuffer(client, move(tuple_data_buffer), FlushMode::NO_FLUSH_RESOURCES); |
| 196 | |
| 197 | row_batch->num_rows_ = header.num_rows(); |
| 198 | row_batch->capacity_ = header.num_rows(); |
| 199 | const CompressionTypePB& compression_type = header.compression_type(); |
| 200 | DCHECK(compression_type == CompressionTypePB::NONE || |
| 201 | compression_type == CompressionTypePB::LZ4) |
| 202 | << "Unexpected compression type: " << compression_type; |
| 203 | row_batch->Deserialize(input_tuple_offsets, input_tuple_data, uncompressed_size, |
| 204 | compression_type == CompressionTypePB::LZ4, tuple_data); |
| 205 | *row_batch_ptr = std::move(row_batch); |
| 206 | return Status::OK(); |
| 207 | } |
| 208 | |
| 209 | RowBatch::~RowBatch() { |
| 210 | tuple_data_pool_.FreeAll(); |
nothing calls this directly
no test coverage detected