Codegen for WriteTuple(above) for writing out single nullable string slot and evaluating a = conjunct. The signature matches WriteTuple() except for the first this* argument. define i1 @WriteCompleteTuple(%"class.impala::HdfsScanner"* %this, %"class.impala::MemPool"* %pool, %"struct.impala::FieldLocation"* %fields, %"class.impala::Tuple"* %tuple, %"class.impala::TupleRow"* %t
| 345 | // ret i1 false |
| 346 | // } |
| 347 | Status HdfsScanner::CodegenWriteCompleteTuple(const HdfsScanPlanNode* node, |
| 348 | FragmentState* state, llvm::Function** write_complete_tuple_fn) { |
| 349 | const vector<ScalarExpr*>& conjuncts = node->conjuncts_; |
| 350 | LlvmCodeGen* codegen = state->codegen(); |
| 351 | *write_complete_tuple_fn = NULL; |
| 352 | |
| 353 | // Cast away const-ness. The codegen only sets the cached typed llvm struct. |
| 354 | TupleDescriptor* tuple_desc = const_cast<TupleDescriptor*>(node->tuple_desc_); |
| 355 | vector<llvm::Function*> slot_fns; |
| 356 | for (int i = 0; i < node->materialized_slots_.size(); ++i) { |
| 357 | llvm::Function* fn = nullptr; |
| 358 | SlotDescriptor* slot_desc = node->materialized_slots_[i]; |
| 359 | |
| 360 | // If the type is CHAR, WriteSlot for this slot cannot be codegen'd. To keep codegen |
| 361 | // for other things, we call the interpreted code for this slot from the codegen'd |
| 362 | // code instead of failing codegen. See IMPALA-9747. |
| 363 | if (TextConverter::SupportsCodegenWriteSlot(slot_desc->type())) { |
| 364 | RETURN_IF_ERROR(TextConverter::CodegenWriteSlot(codegen, tuple_desc, slot_desc, |
| 365 | &fn, node->hdfs_table_->null_column_value().data(), |
| 366 | node->hdfs_table_->null_column_value().size(), true, |
| 367 | state->query_options().strict_mode)); |
| 368 | if (i >= LlvmCodeGen::CODEGEN_INLINE_EXPRS_THRESHOLD) codegen->SetNoInline(fn); |
| 369 | } |
| 370 | slot_fns.push_back(fn); |
| 371 | } |
| 372 | |
| 373 | // Compute order to materialize slots. BE assumes that conjuncts should |
| 374 | // be evaluated in the order specified (optimization is already done by FE) |
| 375 | vector<int> materialize_order; |
| 376 | node->ComputeSlotMaterializationOrder(state->desc_tbl(), &materialize_order); |
| 377 | |
| 378 | // Get types to construct matching function signature to WriteCompleteTuple |
| 379 | llvm::PointerType* uint8_ptr_type = codegen->i8_ptr_type(); |
| 380 | |
| 381 | llvm::PointerType* field_loc_ptr_type = codegen->GetStructPtrType<FieldLocation>(); |
| 382 | llvm::PointerType* tuple_opaque_ptr_type = codegen->GetStructPtrType<Tuple>(); |
| 383 | llvm::PointerType* tuple_row_ptr_type = codegen->GetStructPtrType<TupleRow>(); |
| 384 | llvm::PointerType* mem_pool_ptr_type = codegen->GetStructPtrType<MemPool>(); |
| 385 | llvm::PointerType* hdfs_scanner_ptr_type = codegen->GetStructPtrType<HdfsScanner>(); |
| 386 | |
| 387 | // Generate the typed llvm struct for the output tuple |
| 388 | llvm::StructType* tuple_type = tuple_desc->GetLlvmStruct(codegen); |
| 389 | if (tuple_type == NULL) return Status("Could not generate tuple struct."); |
| 390 | llvm::PointerType* tuple_ptr_type = llvm::PointerType::get(tuple_type, 0); |
| 391 | |
| 392 | // Initialize the function prototype. This needs to match |
| 393 | // HdfsScanner::WriteCompleteTuple's signature identically. |
| 394 | LlvmCodeGen::FnPrototype prototype( |
| 395 | codegen, "WriteCompleteTuple", codegen->bool_type()); |
| 396 | prototype.AddArgument(LlvmCodeGen::NamedVariable("this", hdfs_scanner_ptr_type)); |
| 397 | prototype.AddArgument(LlvmCodeGen::NamedVariable("pool", mem_pool_ptr_type)); |
| 398 | prototype.AddArgument(LlvmCodeGen::NamedVariable("fields", field_loc_ptr_type)); |
| 399 | prototype.AddArgument(LlvmCodeGen::NamedVariable("tuple", tuple_opaque_ptr_type)); |
| 400 | prototype.AddArgument(LlvmCodeGen::NamedVariable("tuple_row", tuple_row_ptr_type)); |
| 401 | prototype.AddArgument(LlvmCodeGen::NamedVariable("template", tuple_opaque_ptr_type)); |
| 402 | prototype.AddArgument(LlvmCodeGen::NamedVariable("error_fields", uint8_ptr_type)); |
| 403 | prototype.AddArgument(LlvmCodeGen::NamedVariable("error_in_row", uint8_ptr_type)); |
| 404 |
nothing calls this directly
no test coverage detected