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

Method CodegenAddBatchImpl

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

Source from the content-addressed store, hash-verified

1119}
1120
1121Status GroupingAggregatorConfig::CodegenAddBatchImpl(
1122 LlvmCodeGen* codegen, TPrefetchMode::type prefetch_mode) {
1123 llvm::Function* update_tuple_fn;
1124 RETURN_IF_ERROR(CodegenUpdateTuple(codegen, &update_tuple_fn));
1125
1126 llvm::Function* copy_grouping_values_fn;
1127 RETURN_IF_ERROR(CodegenCopyGroupingValues(codegen, &copy_grouping_values_fn));
1128
1129 // Get the cross compiled update row batch function
1130 IRFunction::Type ir_fn = IRFunction::GROUPING_AGG_ADD_BATCH_IMPL;
1131 llvm::Function* add_batch_impl_fn = codegen->GetFunction(ir_fn, true);
1132 DCHECK(add_batch_impl_fn != nullptr);
1133
1134 int replaced;
1135 // Codegen for grouping using hash table
1136
1137 // Replace prefetch_mode with constant so branches can be optimised out.
1138 llvm::Value* prefetch_mode_arg = codegen->GetArgument(add_batch_impl_fn, 3);
1139 prefetch_mode_arg->replaceAllUsesWith(codegen->GetI32Constant(prefetch_mode));
1140
1141 // The codegen'd AddBatchImpl function is only used in Open() with level_ = 0,
1142 // so don't use murmur hash
1143 llvm::Function* hash_fn;
1144 RETURN_IF_ERROR(
1145 HashTableCtx::CodegenHashRow(codegen, false, *hash_table_config_, &hash_fn));
1146
1147 // Codegen HashTable::Equals<true>
1148 llvm::Function* build_equals_fn;
1149 RETURN_IF_ERROR(HashTableCtx::CodegenEquals(
1150 codegen, true, *hash_table_config_, &build_equals_fn));
1151
1152 // Codegen for evaluating input rows
1153 llvm::Function* eval_grouping_expr_fn;
1154 RETURN_IF_ERROR(HashTableCtx::CodegenEvalRow(
1155 codegen, false, *hash_table_config_, &eval_grouping_expr_fn));
1156
1157 // Replace call sites
1158 replaced =
1159 codegen->ReplaceCallSites(add_batch_impl_fn, eval_grouping_expr_fn, "EvalProbeRow");
1160 DCHECK_REPLACE_COUNT(replaced, 1);
1161
1162 replaced = codegen->ReplaceCallSites(add_batch_impl_fn, hash_fn, "HashRow");
1163 DCHECK_REPLACE_COUNT(replaced, 1);
1164
1165 replaced = codegen->ReplaceCallSites(add_batch_impl_fn, build_equals_fn, "Equals");
1166 DCHECK_REPLACE_COUNT(replaced, 1);
1167
1168 replaced = codegen->ReplaceCallSites(add_batch_impl_fn, copy_grouping_values_fn,
1169 "CopyGroupingValues");
1170 DCHECK_REPLACE_COUNT(replaced, 1);
1171
1172 HashTableCtx::HashTableReplacedConstants replaced_constants;
1173 const bool stores_duplicates = false;
1174 RETURN_IF_ERROR(
1175 HashTableCtx::ReplaceHashTableConstants(codegen, *hash_table_config_,
1176 stores_duplicates, 1, add_batch_impl_fn, &replaced_constants));
1177 DCHECK_GE(replaced_constants.stores_nulls, 1);
1178 DCHECK_GE(replaced_constants.finds_some_nulls, 1);

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected