| 1052 | } |
| 1053 | |
| 1054 | void KrpcDataStreamSenderConfig::Codegen(FragmentState* state) { |
| 1055 | LlvmCodeGen* codegen = state->codegen(); |
| 1056 | DCHECK(codegen != nullptr); |
| 1057 | const string sender_name = PartitionTypeName() + " Sender"; |
| 1058 | if (partition_type_ != TPartitionType::HASH_PARTITIONED) { |
| 1059 | const string& msg = Substitute("not $0", |
| 1060 | partition_type_ == TPartitionType::KUDU ? "supported" : "needed"); |
| 1061 | codegen_status_msgs_.emplace_back( |
| 1062 | FragmentState::GenerateCodegenMsg(false, msg, sender_name)); |
| 1063 | return; |
| 1064 | } |
| 1065 | |
| 1066 | llvm::Function* hash_row_fn; |
| 1067 | Status codegen_status = CodegenHashRow(codegen, &hash_row_fn); |
| 1068 | if (codegen_status.ok()) { |
| 1069 | llvm::Function* hash_and_add_rows_fn = |
| 1070 | codegen->GetFunction(IRFunction::KRPC_DSS_HASH_AND_ADD_ROWS, true); |
| 1071 | DCHECK(hash_and_add_rows_fn != nullptr); |
| 1072 | |
| 1073 | int num_replaced; |
| 1074 | // Replace GetNumChannels() with a constant. |
| 1075 | num_replaced = codegen->ReplaceCallSitesWithValue(hash_and_add_rows_fn, |
| 1076 | codegen->GetI32Constant(num_channels_), "GetNumChannels"); |
| 1077 | DCHECK_EQ(num_replaced, 1); |
| 1078 | |
| 1079 | num_replaced = codegen->ReplaceCallSitesWithValue(hash_and_add_rows_fn, |
| 1080 | codegen->GetI32Constant(input_row_desc_->num_tuples_no_inline()), |
| 1081 | "num_tuples_no_inline"); |
| 1082 | DCHECK_EQ(num_replaced, 1); |
| 1083 | |
| 1084 | // Replace HashRow() with the handcrafted IR function. |
| 1085 | num_replaced = codegen->ReplaceCallSites(hash_and_add_rows_fn, |
| 1086 | hash_row_fn, KrpcDataStreamSender::HASH_ROW_SYMBOL); |
| 1087 | DCHECK_EQ(num_replaced, 1); |
| 1088 | |
| 1089 | hash_and_add_rows_fn = codegen->FinalizeFunction(hash_and_add_rows_fn); |
| 1090 | if (hash_and_add_rows_fn == nullptr) { |
| 1091 | codegen_status = |
| 1092 | Status("Codegen'd HashAndAddRows() failed verification. See log"); |
| 1093 | } else { |
| 1094 | codegen->AddFunctionToJit(hash_and_add_rows_fn, &hash_and_add_rows_fn_); |
| 1095 | } |
| 1096 | } |
| 1097 | AddCodegenStatus(codegen_status, sender_name); |
| 1098 | } |
| 1099 | |
| 1100 | uint64_t KrpcDataStreamSender::HashRow(TupleRow* row, uint64_t seed) { |
| 1101 | uint64_t hash_val = seed; |
nothing calls this directly
no test coverage detected