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

Method Codegen

be/src/exec/union-node.cc:127–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void UnionPlanNode::Codegen(FragmentState* state){
128 DCHECK(state->ShouldCodegen());
129 PlanNode::Codegen(state);
130 if (IsNodeCodegenDisabled()) return;
131 LlvmCodeGen* codegen = state->codegen();
132 DCHECK(codegen != nullptr);
133 std::stringstream codegen_message;
134 Status codegen_status;
135 for (int i = 0; i < child_exprs_lists_.size(); ++i) {
136 if (IsChildPassthrough(i)) continue;
137
138 llvm::Function* tuple_materialize_exprs_fn;
139 codegen_status = Tuple::CodegenMaterializeExprs(codegen, false, *tuple_desc_,
140 child_exprs_lists_[i], true, &tuple_materialize_exprs_fn);
141 if (!codegen_status.ok()) {
142 // Codegen may fail in some corner cases. If this happens, abort codegen for this
143 // and the remaining children.
144 codegen_message << "Codegen failed for child: " << children_[i]->tnode_->node_id;
145 break;
146 }
147
148 // Get a copy of the function. This function will be modified and added to the
149 // vector of functions.
150 llvm::Function* union_materialize_batch_fn =
151 codegen->GetFunction(IRFunction::UNION_MATERIALIZE_BATCH, true);
152 DCHECK(union_materialize_batch_fn != nullptr);
153
154 int replaced = codegen->ReplaceCallSites(union_materialize_batch_fn,
155 tuple_materialize_exprs_fn, Tuple::MATERIALIZE_EXPRS_SYMBOL);
156 DCHECK_REPLACE_COUNT(replaced, 1) << LlvmCodeGen::Print(union_materialize_batch_fn);
157
158 union_materialize_batch_fn = codegen->FinalizeFunction(
159 union_materialize_batch_fn);
160 DCHECK(union_materialize_batch_fn != nullptr);
161
162 // Add the function to Jit and to the vector of codegened functions.
163 codegen->AddFunctionToJit(union_materialize_batch_fn,
164 &(codegend_union_materialize_batch_fns_.data()[i]));
165 }
166 AddCodegenStatus(codegen_status, codegen_message.str());
167 is_codegen_status_added_ = true;
168}
169
170Status UnionNode::Open(RuntimeState* state) {
171 SCOPED_TIMER(runtime_profile_->total_time_counter());

Callers

nothing calls this directly

Calls 10

ReplaceCallSitesMethod · 0.80
FinalizeFunctionMethod · 0.80
ShouldCodegenMethod · 0.45
codegenMethod · 0.45
sizeMethod · 0.45
okMethod · 0.45
GetFunctionMethod · 0.45
AddFunctionToJitMethod · 0.45
dataMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected