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

Method CodegenLoadAnyVal

be/src/runtime/descriptors.cc:738–809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738void SlotDescriptor::CodegenLoadAnyVal(CodegenAnyVal* any_val, llvm::Value* raw_val_ptr) {
739 DCHECK(raw_val_ptr->getType()->isPointerTy());
740 llvm::Type* raw_val_type = raw_val_ptr->getType()->getPointerElementType();
741 LlvmCodeGen* const codegen = any_val->codegen();
742 LlvmBuilder* const builder = any_val->builder();
743 const ColumnType& type = any_val->type();
744 DCHECK_EQ(raw_val_type, codegen->GetSlotType(type))
745 << endl
746 << LlvmCodeGen::Print(raw_val_ptr) << endl
747 << type << " => " << LlvmCodeGen::Print(
748 codegen->GetSlotType(type));
749 switch (type.type) {
750 case TYPE_STRING:
751 case TYPE_VARCHAR: {
752 // Convert StringValue to StringVal
753 llvm::Function* str_ptr_fn = codegen->GetFunction(
754 IRFunction::STRING_VALUE_PTR, false);
755 llvm::Function* str_len_fn = codegen->GetFunction(
756 IRFunction::STRING_VALUE_LEN, false);
757
758 llvm::Value* ptr = builder->CreateCall(str_ptr_fn,
759 llvm::ArrayRef<llvm::Value*>({raw_val_ptr}), "ptr");
760 llvm::Value* len = builder->CreateCall(str_len_fn,
761 llvm::ArrayRef<llvm::Value*>({raw_val_ptr}), "len");
762
763 any_val->SetPtr(ptr);
764 any_val->SetLen(len);
765 break;
766 }
767 case TYPE_CHAR:
768 case TYPE_FIXED_UDA_INTERMEDIATE: {
769 // Convert fixed-size slot to StringVal.
770 any_val->SetPtr(builder->CreateBitCast(raw_val_ptr, codegen->ptr_type()));
771 any_val->SetLen(codegen->GetI32Constant(type.len));
772 break;
773 }
774 case TYPE_TIMESTAMP: {
775 // Convert TimestampValue to TimestampVal
776 // TimestampValue has type
777 // { boost::posix_time::time_duration, boost::gregorian::date }
778 // = { {{{i64}}}, {{i32}} }
779
780 llvm::Value* ts_value = builder->CreateLoad(raw_val_ptr, "ts_value");
781 // Extract time_of_day i64 from boost::posix_time::time_duration.
782 uint32_t time_of_day_idxs[] = {0, 0, 0, 0};
783 llvm::Value* time_of_day =
784 builder->CreateExtractValue(ts_value, time_of_day_idxs, "time_of_day");
785 DCHECK(time_of_day->getType()->isIntegerTy(64));
786 any_val->SetTimeOfDay(time_of_day);
787 // Extract i32 from boost::gregorian::date
788 uint32_t date_idxs[] = {1, 0, 0};
789 llvm::Value* date = builder->CreateExtractValue(ts_value, date_idxs, "date");
790 DCHECK(date->getType()->isIntegerTy(32));
791 any_val->SetDate(date);
792 break;
793 }
794 case TYPE_BOOLEAN:
795 case TYPE_TINYINT:

Callers

nothing calls this directly

Calls 15

GetSlotTypeMethod · 0.80
CreateCallMethod · 0.80
ptr_typeMethod · 0.80
GetI32ConstantMethod · 0.80
SetTimeOfDayMethod · 0.80
SetDateMethod · 0.80
SetValMethod · 0.80
getTypeMethod · 0.65
codegenMethod · 0.45
builderMethod · 0.45
typeMethod · 0.45
GetFunctionMethod · 0.45

Tested by

no test coverage detected