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

Method CodegenInsertBatch

be/src/exec/partitioned-hash-join-builder.cc:1471–1531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1469}
1470
1471Status PhjBuilderConfig::CodegenInsertBatch(LlvmCodeGen* codegen, llvm::Function* hash_fn,
1472 llvm::Function* murmur_hash_fn, llvm::Function* eval_row_fn,
1473 TPrefetchMode::type prefetch_mode) {
1474 llvm::Function* insert_batch_fn =
1475 codegen->GetFunction(IRFunction::PHJ_INSERT_BATCH, true);
1476 // Context required to generate hash table codegened methods.
1477 llvm::Function* build_equals_fn;
1478 RETURN_IF_ERROR(
1479 HashTableCtx::CodegenEquals(codegen, true, *hash_table_config_, &build_equals_fn));
1480
1481 // Replace the parameter 'prefetch_mode' with constant.
1482 llvm::Value* prefetch_mode_arg = codegen->GetArgument(insert_batch_fn, 1);
1483 DCHECK_GE(prefetch_mode, TPrefetchMode::NONE);
1484 DCHECK_LE(prefetch_mode, TPrefetchMode::HT_BUCKET);
1485 prefetch_mode_arg->replaceAllUsesWith(codegen->GetI32Constant(prefetch_mode));
1486
1487 // Use codegen'd EvalBuildRow() function
1488 int replaced = codegen->ReplaceCallSites(insert_batch_fn, eval_row_fn, "EvalBuildRow");
1489 DCHECK_REPLACE_COUNT(replaced, 1);
1490
1491 // Use codegen'd Equals() function
1492 replaced = codegen->ReplaceCallSites(insert_batch_fn, build_equals_fn, "Equals");
1493 DCHECK_REPLACE_COUNT(replaced, 1);
1494
1495 // Replace hash-table parameters with constants.
1496 HashTableCtx::HashTableReplacedConstants replaced_constants;
1497 const bool stores_duplicates = true;
1498 const int num_build_tuples = input_row_desc_->tuple_descriptors().size();
1499 RETURN_IF_ERROR(HashTableCtx::ReplaceHashTableConstants(codegen, *hash_table_config_,
1500 stores_duplicates, num_build_tuples, insert_batch_fn, &replaced_constants));
1501 DCHECK_GE(replaced_constants.stores_nulls, 1);
1502 DCHECK_EQ(replaced_constants.finds_some_nulls, 0);
1503 DCHECK_GE(replaced_constants.stores_duplicates, 1);
1504 DCHECK_GE(replaced_constants.stores_tuples, 1);
1505 DCHECK_GE(replaced_constants.quadratic_probing, 1);
1506
1507 llvm::Function* insert_batch_fn_level0 = codegen->CloneFunction(insert_batch_fn);
1508
1509 // Use codegen'd hash functions
1510 replaced = codegen->ReplaceCallSites(insert_batch_fn_level0, hash_fn, "HashRow");
1511 DCHECK_REPLACE_COUNT(replaced, 1);
1512 replaced = codegen->ReplaceCallSites(insert_batch_fn, murmur_hash_fn, "HashRow");
1513 DCHECK_REPLACE_COUNT(replaced, 1);
1514
1515 insert_batch_fn = codegen->FinalizeFunction(insert_batch_fn);
1516 if (insert_batch_fn == nullptr) {
1517 return Status(
1518 "PartitionedHashJoinNode::CodegenInsertBatch(): codegen'd "
1519 "InsertBatch() function failed verification, see log");
1520 }
1521 insert_batch_fn_level0 = codegen->FinalizeFunction(insert_batch_fn_level0);
1522 if (insert_batch_fn_level0 == nullptr) {
1523 return Status(
1524 "PartitionedHashJoinNode::CodegenInsertBatch(): codegen'd zero-level "
1525 "InsertBatch() function failed verification, see log");
1526 }
1527
1528 codegen->AddFunctionToJit(insert_batch_fn, &insert_batch_fn_);

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected