| 256 | } |
| 257 | |
| 258 | bool MergeJoin::findEndOfMatch( |
| 259 | Match& match, |
| 260 | const RowVectorPtr& input, |
| 261 | const std::vector<column_index_t>& keys) { |
| 262 | if (match.complete) { |
| 263 | return true; |
| 264 | } |
| 265 | |
| 266 | auto prevInput = match.inputs.back(); |
| 267 | auto prevIndex = prevInput->size() - 1; |
| 268 | |
| 269 | auto numInput = input->size(); |
| 270 | |
| 271 | vector_size_t endIndex = 0; |
| 272 | while (endIndex < numInput && |
| 273 | compare(keys, input, endIndex, keys, prevInput, prevIndex) == 0) { |
| 274 | ++endIndex; |
| 275 | } |
| 276 | |
| 277 | if (endIndex == numInput) { |
| 278 | // Inputs are kept past getting a new batch of inputs. LazyVectors |
| 279 | // must be loaded before advancing to the next batch. |
| 280 | loadColumns(input, *operatorCtx_->execCtx()); |
| 281 | match.inputs.push_back(input); |
| 282 | match.endIndex = endIndex; |
| 283 | return false; |
| 284 | } |
| 285 | |
| 286 | if (endIndex > 0) { |
| 287 | // Match ends here, no need to pre-load lazies. |
| 288 | match.inputs.push_back(input); |
| 289 | match.endIndex = endIndex; |
| 290 | } |
| 291 | match.complete = true; |
| 292 | return true; |
| 293 | } |
| 294 | |
| 295 | namespace { |
| 296 | void copyRow( |