Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 0 additions & 129 deletions cpp/include/cudf/detail/join/distinct_filtered_join.cuh

This file was deleted.

59 changes: 41 additions & 18 deletions cpp/include/cudf/detail/join/filtered_join.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cudf/join/join.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/span.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
Expand Down Expand Up @@ -37,10 +38,10 @@ using cudf::detail::row::lhs_index_type;
using cudf::detail::row::rhs_index_type;

/**
* @brief Base class providing common functionality for filtered join operations.
* @brief Implementation of filtered join using set hash tables.
*
* This abstract class implements the core components needed for hash-based semi
* and anti join operations.
* Implements hash-based semi and anti joins using set semantics, where duplicate
* keys are not stored in the hash table.
*/
class filtered_join {
public:
Expand Down Expand Up @@ -121,7 +122,7 @@ class filtered_join {
};

/**
* @brief Constructor for filtered_join base class
* @brief Constructor for filtered_join
*
* Initializes the hash table with the right table and prepares it for join operations.
*
Expand All @@ -138,27 +139,50 @@ class filtered_join {
cuda::mr::any_resource<cuda::mr::device_accessible> mr);

/**
* Virtual semi join function overridden in derived classes
* @brief Returns indices of left table rows that have matching keys in the right table
*/
virtual std::unique_ptr<rmm::device_uvector<cudf::size_type>> semi_join(
cudf::table_view const& left,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) = 0;
std::unique_ptr<rmm::device_uvector<cudf::size_type>> semi_join(
cudf::table_view const& left, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr);

/**
* Virtual anti join function overridden in derived classes
* @brief Returns indices of left table rows that do not have matching keys in the right table
*/
virtual std::unique_ptr<rmm::device_uvector<cudf::size_type>> anti_join(
std::unique_ptr<rmm::device_uvector<cudf::size_type>> anti_join(
cudf::table_view const& left, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr);

private:
std::unique_ptr<rmm::device_uvector<cudf::size_type>> semi_anti_join(
cudf::table_view const& left,
join_kind kind,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) = 0;
rmm::device_async_resource_ref mr);

/**
* Virtual abstract base class destructor
*/
virtual ~filtered_join() = default;
// Queries the hash table for every left row and writes the matches to contains_map.
template <int32_t CGSize, typename Iterator, typename Ref>
void query_right_table(cudf::table_view const& left,
Iterator left_iter,
Ref query_ref,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream);

void query_right_table_primitive(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream);

void query_right_table_flat(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream);

void query_right_table_nested(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream);

protected:
enum class row_operator_mode : uint8_t { PRIMITIVE, FLAT, NESTED };

// Key type used in the hash table
Expand Down Expand Up @@ -196,7 +220,6 @@ class filtered_join {
void insert_right_table_flat(rmm::cuda_stream_view stream);
void insert_right_table_nested(rmm::cuda_stream_view stream);

private:
/**
* @brief Calculates the required storage size for the hash table
*
Expand Down
26 changes: 7 additions & 19 deletions cpp/src/join/filtered_join/filtered_join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "join/join_common_utils.hpp"

#include <cudf/detail/cuco_helpers.hpp>
#include <cudf/detail/join/distinct_filtered_join.cuh>
#include <cudf/detail/join/filtered_join.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
Expand Down Expand Up @@ -110,20 +109,9 @@ filtered_join::filtered_join(cudf::table_view const& right,
_nulls_equal{compare_nulls},
_preprocessed_right{cudf::detail::row::equality::preprocessed_table::create(_right, stream)}
{
cudf::scoped_range range{"filtered_join::filtered_join"};
if (_right.num_rows() == 0) return;
_bucket_storage.initialize(empty_sentinel_key, stream);
}

distinct_filtered_join::distinct_filtered_join(
cudf::table_view const& right,
cudf::null_equality compare_nulls,
double load_factor,
rmm::cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr)
: filtered_join(right, compare_nulls, load_factor, stream, std::move(mr))
{
cudf::scoped_range range{"distinct_filtered_join::distinct_filtered_join"};
if (_right.num_rows() == 0) return;
if (_right_mode == row_operator_mode::PRIMITIVE) {
insert_right_table_primitive(stream);
} else if (_right_mode == row_operator_mode::NESTED) {
Expand All @@ -133,16 +121,16 @@ distinct_filtered_join::distinct_filtered_join(
}
}

std::unique_ptr<rmm::device_uvector<cudf::size_type>> distinct_filtered_join::semi_anti_join(
std::unique_ptr<rmm::device_uvector<cudf::size_type>> filtered_join::semi_anti_join(
cudf::table_view const& left,
join_kind kind,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
cudf::scoped_range range{"distinct_filtered_join::semi_anti_join"};
cudf::scoped_range range{"filtered_join::semi_anti_join"};

auto const preprocessed_left = [&left, stream] {
cudf::scoped_range range{"distinct_filtered_join::semi_anti_join::preprocessed_left"};
cudf::scoped_range range{"filtered_join::semi_anti_join::preprocessed_left"};
return cudf::detail::row::equality::preprocessed_table::create(left, stream);
}();

Expand All @@ -167,7 +155,7 @@ std::unique_ptr<rmm::device_uvector<cudf::size_type>> distinct_filtered_join::se
return std::make_unique<rmm::device_uvector<size_type>>(std::move(gather_map));
}

std::unique_ptr<rmm::device_uvector<cudf::size_type>> distinct_filtered_join::semi_join(
std::unique_ptr<rmm::device_uvector<cudf::size_type>> filtered_join::semi_join(
cudf::table_view const& left, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr)
{
// Early return for empty right or left table
Expand All @@ -178,7 +166,7 @@ std::unique_ptr<rmm::device_uvector<cudf::size_type>> distinct_filtered_join::se
return semi_anti_join(left, join_kind::LEFT_SEMI_JOIN, stream, mr);
}

std::unique_ptr<rmm::device_uvector<cudf::size_type>> distinct_filtered_join::anti_join(
std::unique_ptr<rmm::device_uvector<cudf::size_type>> filtered_join::anti_join(
cudf::table_view const& left, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr)
{
// Early return for empty left table
Expand Down Expand Up @@ -206,7 +194,7 @@ filtered_join::filtered_join(cudf::table_view const& build,
double load_factor,
rmm::cuda_stream_view stream,
cuda::mr::any_resource<cuda::mr::device_accessible> mr)
: _impl{std::make_unique<cudf::detail::distinct_filtered_join>(
: _impl{std::make_unique<cudf::detail::filtered_join>(
build, compare_nulls, load_factor, stream, std::move(mr))}
{
}
Expand Down
15 changes: 7 additions & 8 deletions cpp/src/join/filtered_join/filtered_join_common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#pragma once

#include <cudf/detail/join/distinct_filtered_join.cuh>
#include <cudf/detail/join/filtered_join.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/table/table_view.hpp>
Expand Down Expand Up @@ -59,7 +58,7 @@ void filtered_join::insert_right_table(Iterator right_iter,
Ref const& insert_ref,
rmm::cuda_stream_view stream)
{
cudf::scoped_range range{"distinct_filtered_join::insert_right_table"};
cudf::scoped_range range{"filtered_join::insert_right_table"};
// Insert valid rows from the right table into the hash table.
auto const grid_size = cuco::detail::grid_size(_right.num_rows(), CGSize);
auto const bitmask_buffer_and_ptr = make_filtered_join_row_bitmask(_right, _nulls_equal, stream);
Expand All @@ -84,13 +83,13 @@ void filtered_join::insert_right_table(Iterator right_iter,
}

template <int32_t CGSize, typename Iterator, typename Ref>
void distinct_filtered_join::query_right_table(cudf::table_view const& left,
Iterator left_iter,
Ref query_ref,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream)
void filtered_join::query_right_table(cudf::table_view const& left,
Iterator left_iter,
Ref query_ref,
cudf::device_span<bool> contains_map,
rmm::cuda_stream_view stream)
{
cudf::scoped_range range{"distinct_filtered_join::query_right_table"};
cudf::scoped_range range{"filtered_join::query_right_table"};
auto const grid_size = cuco::detail::grid_size(left.num_rows(), CGSize);
auto const bitmask_buffer_and_ptr = make_filtered_join_row_bitmask(left, _nulls_equal, stream);
if (bitmask_buffer_and_ptr.second != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/join/filtered_join/filtered_join_flat.cu
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void filtered_join::insert_right_table_flat(rmm::cuda_stream_view stream)
iter, set_ref.rebind_operators(cuco::insert), stream);
}

void distinct_filtered_join::query_right_table_flat(
void filtered_join::query_right_table_flat(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/join/filtered_join/filtered_join_nested_query.cu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace cudf::detail {

void distinct_filtered_join::query_right_table_nested(
void filtered_join::query_right_table_nested(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/join/filtered_join/filtered_join_primitive.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void filtered_join::insert_right_table_primitive(rmm::cuda_stream_view stream)
iter, set_ref.rebind_operators(cuco::insert), stream);
}

void distinct_filtered_join::query_right_table_primitive(
void filtered_join::query_right_table_primitive(
cudf::table_view const& left,
std::shared_ptr<cudf::detail::row::equality::preprocessed_table> const& preprocessed_left,
cudf::device_span<bool> contains_map,
Expand Down
Loading