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

Method WriteCollection

be/src/runtime/raw-value.cc:292–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291template <bool COLLECT_VAR_LEN_VALS>
292void RawValue::WriteCollection(const void* value, Tuple* tuple,
293 const SlotDescriptor* slot_desc, MemPool* pool, vector<StringValue*>* string_values,
294 vector<pair<CollectionValue*, int64_t>>* collection_values) {
295 DCHECK(slot_desc->type().IsCollectionType());
296
297 void* dst = tuple->GetSlot(slot_desc->tuple_offset());
298
299 const CollectionValue* src = reinterpret_cast<const CollectionValue*>(value);
300 CollectionValue* dest = reinterpret_cast<CollectionValue*>(dst);
301 dest->num_tuples = src->num_tuples;
302
303 int64_t byte_size = dest->ByteSize(*slot_desc->children_tuple_descriptor());
304 if (pool != nullptr) {
305 // If 'dest' and 'src' point to the same address, assigning the address of the newly
306 // allocated buffer to 'dest->ptr' will also overwrite 'src->ptr', and the memcpy will
307 // be from the destination to the destination.
308 DCHECK_NE(dest, src);
309 // Note: if this changes to TryAllocate(), SlotDescriptor::CodegenWriteToSlot() will
310 // need to reflect this change as well (the codegen'd Allocate() call is actually
311 // generated in SlotDescriptor::CodegenWriteStringOrCollectionToSlot()).
312 dest->ptr = reinterpret_cast<uint8_t*>(pool->Allocate(byte_size));
313 Ubsan::MemCpy(dest->ptr, src->ptr, byte_size);
314 } else {
315 dest->ptr = src->ptr;
316 }
317
318 // We only need to recurse if this is a deep copy (pool != nullptr) OR if we collect
319 // var-len values.
320 if (pool != nullptr || COLLECT_VAR_LEN_VALS) {
321 WriteCollectionChildren<COLLECT_VAR_LEN_VALS>(*dest, *src, *slot_desc, pool,
322 string_values, collection_values);
323 }
324
325 if (COLLECT_VAR_LEN_VALS) {
326 DCHECK(string_values != nullptr);
327 DCHECK(collection_values != nullptr);
328 collection_values->push_back(std::make_pair(dest, byte_size));
329 }
330}
331
332template <bool COLLECT_VAR_LEN_VALS>
333void RawValue::WriteCollectionChildren(const CollectionValue& dest,

Callers

nothing calls this directly

Calls 8

IsCollectionTypeMethod · 0.80
tuple_offsetMethod · 0.80
push_backMethod · 0.80
typeMethod · 0.45
GetSlotMethod · 0.45
ByteSizeMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected