From d47dd8125b74127a464e0ce1de618bd8ef1df367 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sun, 5 Sep 2021 22:51:53 -0700 Subject: [PATCH] Fix and properly comment early return. --- cpp/src/join/conditional_join.cu | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cpp/src/join/conditional_join.cu b/cpp/src/join/conditional_join.cu index d2049841f80..7425ff16a67 100644 --- a/cpp/src/join/conditional_join.cu +++ b/cpp/src/join/conditional_join.cu @@ -132,16 +132,15 @@ conditional_join(table_view const& left, join_size = size.value(stream); } - // If the output size will be zero, we can return immediately. + // The initial early exit clauses guarantee that we will not reach this point + // unless both the left and right tables are non-empty. Under that + // constraint, neither left nor full joins can return an empty result since + // at minimum we are guaranteed null matches for all non-matching rows. In + // all other cases (inner, left semi, and left anti joins) if we reach this + // point we can safely return an empty result. if (join_size == 0) { - auto join_indices{ - std::make_pair(std::make_unique>(0, stream, mr), - std::make_unique>(0, stream, mr))}; - if (join_type == join_kind::FULL_JOIN) { - auto complement_indices = detail::get_left_join_indices_complement( - join_indices.second, left.num_rows(), right.num_rows(), stream, mr); - return detail::concatenate_vector_pairs(join_indices, complement_indices, stream); - } + return std::make_pair(std::make_unique>(0, stream, mr), + std::make_unique>(0, stream, mr)); } rmm::device_scalar write_index(0, stream);