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

Function CodegenReadingStringOrCollectionVal

be/src/exprs/slot-ref.cc:281–304  ·  view source on GitHub ↗

Codegens reading the members of a StringVal or a CollectionVal from the slot pointed to by 'val_ptr'. Returns the resulting values in '*ptr' and '*len'.

Source from the content-addressed store, hash-verified

279// Codegens reading the members of a StringVal or a CollectionVal from the slot pointed to
280// by 'val_ptr'. Returns the resulting values in '*ptr' and '*len'.
281void CodegenReadingStringOrCollectionVal(LlvmCodeGen* codegen, LlvmBuilder* builder,
282 const ColumnType& type, llvm::Value* val_ptr, llvm::Value** ptr, llvm::Value** len) {
283 if (type.IsVarLenStringType()) {
284 llvm::Function* str_ptr_fn = codegen->GetFunction(
285 IRFunction::STRING_VALUE_PTR, false);
286 llvm::Function* str_len_fn = codegen->GetFunction(
287 IRFunction::STRING_VALUE_LEN, false);
288
289 *ptr = builder->CreateCall(str_ptr_fn,
290 llvm::ArrayRef<llvm::Value*>({val_ptr}), "ptr");
291 *len = builder->CreateCall(str_len_fn,
292 llvm::ArrayRef<llvm::Value*>({val_ptr}), "len");
293 } else if (type.IsCollectionType()) {
294 llvm::Value* ptr_ptr = builder->CreateStructGEP(nullptr, val_ptr, 0, "ptr_ptr");
295 *ptr = builder->CreateLoad(ptr_ptr, "ptr");
296 llvm::Value* len_ptr = builder->CreateStructGEP(nullptr, val_ptr, 1, "len_ptr");
297 *len = builder->CreateLoad(len_ptr, "len");
298 } else {
299 DCHECK(type.type == TYPE_CHAR || type.type == TYPE_FIXED_UDA_INTERMEDIATE);
300 // ptr and len are the slot and its fixed length.
301 *ptr = builder->CreateBitCast(val_ptr, codegen->ptr_type());
302 *len = codegen->GetI32Constant(type.len);
303 }
304}
305
306void CodegenReadingTimestamp(LlvmCodeGen* codegen, LlvmBuilder* builder,
307 llvm::Value* val_ptr, llvm::Value** time_of_day, llvm::Value** date) {

Callers 1

CodegenReadSlotMethod · 0.85

Calls 6

IsVarLenStringTypeMethod · 0.80
CreateCallMethod · 0.80
IsCollectionTypeMethod · 0.80
ptr_typeMethod · 0.80
GetI32ConstantMethod · 0.80
GetFunctionMethod · 0.45

Tested by

no test coverage detected