| 1129 | } |
| 1130 | |
| 1131 | RowVectorPtr HashProbe::getOutput() { |
| 1132 | if (isFinished()) { |
| 1133 | return nullptr; |
| 1134 | } |
| 1135 | checkRunning(); |
| 1136 | |
| 1137 | clearProjectedOutput(); |
| 1138 | if (!input_) { |
| 1139 | if (!hasMoreInput()) { |
| 1140 | if (needLastProbe() && lastProber_) { |
| 1141 | auto output = getBuildSideOutput(); |
| 1142 | if (output != nullptr) { |
| 1143 | return output; |
| 1144 | } |
| 1145 | } |
| 1146 | if (hasMoreSpillData()) { |
| 1147 | prepareForSpillRestore(); |
| 1148 | asyncWaitForHashTable(); |
| 1149 | } else { |
| 1150 | setState(ProbeOperatorState::kFinish); |
| 1151 | resetHashTable(); |
| 1152 | } |
| 1153 | return nullptr; |
| 1154 | } |
| 1155 | return nullptr; |
| 1156 | } |
| 1157 | |
| 1158 | const auto inputSize = input_->size(); |
| 1159 | |
| 1160 | if (replacedWithDynamicFilter_) { |
| 1161 | addRuntimeStat("replacedWithDynamicFilterRows", RuntimeCounter(inputSize)); |
| 1162 | auto output = Operator::fillOutput(inputSize, nullptr); |
| 1163 | input_ = nullptr; |
| 1164 | return output; |
| 1165 | } |
| 1166 | |
| 1167 | const bool isLeftSemiOrAntiJoinNoFilter = !filter_ && |
| 1168 | (isLeftSemiFilterJoin(joinType_) || isLeftSemiProjectJoin(joinType_) || |
| 1169 | isAntiJoin(joinType_)); |
| 1170 | |
| 1171 | const bool emptyBuildSide = (table_->numDistinct() == 0); |
| 1172 | |
| 1173 | // Left semi and anti joins are always cardinality reducing, e.g. for a |
| 1174 | // given row of input they produce zero or 1 row of output. Therefore, if |
| 1175 | // there is no extra filter we can process each batch of input in one go. |
| 1176 | auto outputBatchSize = (isLeftSemiOrAntiJoinNoFilter || emptyBuildSide) |
| 1177 | ? inputSize |
| 1178 | : outputBatchSize_; |
| 1179 | auto mapping = |
| 1180 | initializeRowNumberMapping(outputRowMapping_, outputBatchSize, pool()); |
| 1181 | outputTableRows_.resize(outputBatchSize); |
| 1182 | |
| 1183 | for (;;) { |
| 1184 | int numOut = 0; |
| 1185 | |
| 1186 | if (emptyBuildSide) { |
| 1187 | // When build side is empty, anti and left joins return all probe side |
| 1188 | // rows, including ones with null join keys. |
nothing calls this directly
no test coverage detected