github-actions[bot] commented on code in PR #16166: URL: https://github.com/apache/doris/pull/16166#discussion_r1089717648
########## be/src/vec/exec/join/process_hash_table_probe_impl.h: ########## @@ -208,123 +207,180 @@ Status ProcessHashTableProbe<JoinOpType>::do_process(HashTableType& hash_table_c bool all_match_one = true; int last_probe_index = probe_index; + size_t probe_size = 0; + auto& probe_row_match_iter = hash_table_ctx.probe_row_match_iter; { SCOPED_TIMER(_search_hashtable_timer); - while (probe_index < probe_rows) { - if constexpr (ignore_null && need_null_map_for_probe) { - if ((*null_map)[probe_index]) { - if constexpr (probe_all) { - _items_counts[probe_index++] = (uint32_t)1; - // only full outer / left outer need insert the data of right table - if (LIKELY(current_offset < _build_block_rows.size())) { - _build_block_offsets[current_offset] = -1; - _build_block_rows[current_offset] = -1; - } else { - _build_block_offsets.emplace_back(-1); - _build_block_rows.emplace_back(-1); - } - ++current_offset; + if constexpr (!is_right_semi_anti_join) { + if (probe_row_match_iter.ok()) { + for (; probe_row_match_iter.ok(); ++probe_row_match_iter) { + if (LIKELY(current_offset < _build_block_rows.size())) { + _build_block_offsets[current_offset] = probe_row_match_iter->block_offset; + _build_block_rows[current_offset] = probe_row_match_iter->row_num; } else { - _items_counts[probe_index++] = (uint32_t)0; + _build_block_offsets.emplace_back(probe_row_match_iter->block_offset); + _build_block_rows.emplace_back(probe_row_match_iter->row_num); } - all_match_one = false; - continue; - } - } - int last_offset = current_offset; - auto find_result = - !need_null_map_for_probe - ? key_getter.find_key(hash_table_ctx.hash_table, probe_index, *_arena) - : (*null_map)[probe_index] - ? decltype(key_getter.find_key(hash_table_ctx.hash_table, probe_index, - *_arena)) {nullptr, false} - : key_getter.find_key(hash_table_ctx.hash_table, probe_index, *_arena); - if (probe_index + PREFETCH_STEP < probe_rows) - key_getter.template prefetch<true>(hash_table_ctx.hash_table, - probe_index + PREFETCH_STEP, *_arena); - - if constexpr (JoinOpType == TJoinOp::LEFT_ANTI_JOIN || - JoinOpType == TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN) { - if (is_mark_join) { - ++current_offset; - assert_cast<doris::vectorized::ColumnVector<UInt8>&>(*mcol[mcol.size() - 1]) - .get_data() - .template push_back(!find_result.is_found()); - } else { - if (!find_result.is_found()) { - ++current_offset; + if (++current_offset >= _batch_size) { + break; } } - } else if constexpr (JoinOpType == TJoinOp::LEFT_SEMI_JOIN) { - if (is_mark_join) { - ++current_offset; - assert_cast<doris::vectorized::ColumnVector<UInt8>&>(*mcol[mcol.size() - 1]) - .get_data() - .template push_back(find_result.is_found()); - } else { - if (find_result.is_found()) { - ++current_offset; - } + all_match_one &= (current_offset == 1); + _items_counts[probe_index] = current_offset; + if (!probe_row_match_iter.ok()) { + ++probe_index; } - } else { - DCHECK(!is_mark_join); - if (find_result.is_found()) { - auto& mapped = find_result.get_mapped(); - // TODO: Iterators are currently considered to be a heavy operation and have a certain impact on performance. - // We should rethink whether to use this iterator mode in the future. Now just opt the one row case - if (mapped.get_row_count() == 1) { - if constexpr (std::is_same_v<Mapped, RowRefListWithFlag>) { - mapped.visited = true; - } + probe_size = 1; + } + } - if constexpr (!is_right_semi_anti_join) { + if (current_offset < _batch_size) { + bool more_matches_for_current_probe_row = false; + while (probe_index < probe_rows) { + if constexpr (ignore_null && need_null_map_for_probe) { + if ((*null_map)[probe_index]) { + if constexpr (probe_all) { + _items_counts[probe_index++] = (uint32_t)1; + // only full outer / left outer need insert the data of right table if (LIKELY(current_offset < _build_block_rows.size())) { - _build_block_offsets[current_offset] = mapped.block_offset; - _build_block_rows[current_offset] = mapped.row_num; + _build_block_offsets[current_offset] = -1; + _build_block_rows[current_offset] = -1; } else { - _build_block_offsets.emplace_back(mapped.block_offset); - _build_block_rows.emplace_back(mapped.row_num); + _build_block_offsets.emplace_back(-1); + _build_block_rows.emplace_back(-1); + } + ++current_offset; + } else { + _items_counts[probe_index++] = (uint32_t)0; + } + all_match_one = false; + if constexpr (probe_all) { + if (current_offset >= _batch_size) { + break; } + } + continue; + } + } + int last_offset = current_offset; + auto find_result = !need_null_map_for_probe + ? key_getter.find_key(hash_table_ctx.hash_table, + probe_index, *_arena) + : (*null_map)[probe_index] + ? decltype(key_getter.find_key(hash_table_ctx.hash_table, + probe_index, + *_arena)) {nullptr, false} + : key_getter.find_key(hash_table_ctx.hash_table, + probe_index, *_arena); + if (probe_index + PREFETCH_STEP < probe_rows) Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (probe_index + PREFETCH_STEP < probe_rows) { ``` be/src/vec/exec/join/process_hash_table_probe_impl.h:276: ```diff - probe_index + PREFETCH_STEP, *_arena); + probe_index + PREFETCH_STEP, *_arena); + } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org