| 601 | } |
| 602 | |
| 603 | Status HdfsScanner::CodegenInitTuple( |
| 604 | const HdfsScanPlanNode* node, LlvmCodeGen* codegen, llvm::Function** init_tuple_fn) { |
| 605 | *init_tuple_fn = codegen->GetFunction(IRFunction::HDFS_SCANNER_INIT_TUPLE, true); |
| 606 | DCHECK(*init_tuple_fn != nullptr); |
| 607 | |
| 608 | // Replace all of the constants in InitTuple() to specialize the code. |
| 609 | bool has_template_tuple = !node->partition_key_slots_.empty(); |
| 610 | if (!has_template_tuple) { |
| 611 | has_template_tuple = node->HasVirtualColumnInTemplateTuple(); |
| 612 | } |
| 613 | int replaced = 0; |
| 614 | // If has_template_tuple is true, then we can certainly replace the callsites. |
| 615 | // If has_template_tuple is false, then we should only replace the callsites for |
| 616 | // non-Iceberg tables, as for Iceberg tables we might still create a template |
| 617 | // tuple based on the partitioning in the data files. |
| 618 | if (has_template_tuple || !node->hdfs_table_->IsIcebergTable()) { |
| 619 | replaced = codegen->ReplaceCallSitesWithBoolConst( |
| 620 | *init_tuple_fn, has_template_tuple, "has_template_tuple"); |
| 621 | DCHECK_REPLACE_COUNT(replaced, 1); |
| 622 | } |
| 623 | |
| 624 | const TupleDescriptor* tuple_desc = node->tuple_desc_; |
| 625 | replaced = codegen->ReplaceCallSitesWithValue(*init_tuple_fn, |
| 626 | codegen->GetI32Constant(tuple_desc->byte_size()), "tuple_byte_size"); |
| 627 | DCHECK_REPLACE_COUNT(replaced, 1); |
| 628 | |
| 629 | replaced = codegen->ReplaceCallSitesWithValue(*init_tuple_fn, |
| 630 | codegen->GetI32Constant(tuple_desc->null_bytes_offset()), |
| 631 | "null_bytes_offset"); |
| 632 | DCHECK_REPLACE_COUNT(replaced, 1); |
| 633 | |
| 634 | replaced = codegen->ReplaceCallSitesWithValue(*init_tuple_fn, |
| 635 | codegen->GetI32Constant(tuple_desc->num_null_bytes()), "num_null_bytes"); |
| 636 | DCHECK_REPLACE_COUNT(replaced, 1); |
| 637 | |
| 638 | *init_tuple_fn = codegen->FinalizeFunction(*init_tuple_fn); |
| 639 | if (*init_tuple_fn == nullptr) { |
| 640 | return Status("Failed to finalize codegen'd InitTuple()."); |
| 641 | } |
| 642 | return Status::OK(); |
| 643 | } |
| 644 | |
| 645 | // ; Function Attrs: noinline |
| 646 | // define i1 @EvalRuntimeFilters(%"class.impala::HdfsScanner"* %this, |
nothing calls this directly
no test coverage detected