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

Method CodegenAddBatchStreamingImpl

be/src/exec/grouping-aggregator.cc:1195–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1193}
1194
1195Status GroupingAggregatorConfig::CodegenAddBatchStreamingImpl(
1196 LlvmCodeGen* codegen, TPrefetchMode::type prefetch_mode) {
1197 DCHECK(is_streaming_preagg_);
1198
1199 IRFunction::Type ir_fn = IRFunction::GROUPING_AGG_ADD_BATCH_STREAMING_IMPL;
1200 llvm::Function* add_batch_streaming_impl_fn = codegen->GetFunction(ir_fn, true);
1201 DCHECK(add_batch_streaming_impl_fn != nullptr);
1202
1203 // Make agg_idx arg constant.
1204 llvm::Value* agg_idx_arg = codegen->GetArgument(add_batch_streaming_impl_fn, 2);
1205 agg_idx_arg->replaceAllUsesWith(codegen->GetI32Constant(agg_idx_));
1206
1207 // Make needs_serialize arg constant so dead code can be optimised out.
1208 llvm::Value* needs_serialize_arg = codegen->GetArgument(add_batch_streaming_impl_fn, 3);
1209 needs_serialize_arg->replaceAllUsesWith(codegen->GetBoolConstant(needs_serialize_));
1210
1211 // Replace prefetch_mode with constant so branches can be optimised out.
1212 llvm::Value* prefetch_mode_arg = codegen->GetArgument(add_batch_streaming_impl_fn, 4);
1213 prefetch_mode_arg->replaceAllUsesWith(codegen->GetI32Constant(prefetch_mode));
1214
1215 llvm::Function* update_tuple_fn;
1216 RETURN_IF_ERROR(CodegenUpdateTuple(codegen, &update_tuple_fn));
1217
1218 llvm::Function* copy_grouping_values_fn;
1219 RETURN_IF_ERROR(CodegenCopyGroupingValues(codegen, &copy_grouping_values_fn));
1220
1221 // We only use the top-level hash function for streaming aggregations.
1222 llvm::Function* hash_fn;
1223 RETURN_IF_ERROR(
1224 HashTableCtx::CodegenHashRow(codegen, false, *hash_table_config_, &hash_fn));
1225
1226 // Codegen HashTable::Equals
1227 llvm::Function* equals_fn;
1228 RETURN_IF_ERROR(
1229 HashTableCtx::CodegenEquals(codegen, true, *hash_table_config_, &equals_fn));
1230
1231 // Codegen for evaluating input rows
1232 llvm::Function* eval_grouping_expr_fn;
1233 RETURN_IF_ERROR(HashTableCtx::CodegenEvalRow(
1234 codegen, false, *hash_table_config_, &eval_grouping_expr_fn));
1235
1236 // Replace call sites
1237 int replaced = codegen->ReplaceCallSites(
1238 add_batch_streaming_impl_fn, update_tuple_fn, "UpdateTuple");
1239 DCHECK_REPLACE_COUNT(replaced, 2);
1240
1241 replaced = codegen->ReplaceCallSites(
1242 add_batch_streaming_impl_fn, eval_grouping_expr_fn, "EvalProbeRow");
1243 DCHECK_REPLACE_COUNT(replaced, 1);
1244
1245 replaced = codegen->ReplaceCallSites(add_batch_streaming_impl_fn, hash_fn, "HashRow");
1246 DCHECK_REPLACE_COUNT(replaced, 1);
1247
1248 replaced = codegen->ReplaceCallSites(add_batch_streaming_impl_fn, equals_fn, "Equals");
1249 DCHECK_REPLACE_COUNT(replaced, 1);
1250
1251 replaced = codegen->ReplaceCallSites(add_batch_streaming_impl_fn,
1252 copy_grouping_values_fn, "CopyGroupingValues");

Callers

nothing calls this directly

Calls 9

OKFunction · 0.85
GetArgumentMethod · 0.80
GetI32ConstantMethod · 0.80
GetBoolConstantMethod · 0.80
ReplaceCallSitesMethod · 0.80
FinalizeFunctionMethod · 0.80
StatusClass · 0.70
GetFunctionMethod · 0.45
AddFunctionToJitMethod · 0.45

Tested by

no test coverage detected