hash_join.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/hashing.hpp>
21 #include <cudf/types.hpp>
23 #include <cudf/utilities/export.hpp>
25 
26 #include <rmm/cuda_stream_view.hpp>
27 #include <rmm/device_uvector.hpp>
28 
29 #include <optional>
30 #include <utility>
31 
32 namespace CUDF_EXPORT cudf {
33 
40 // forward declaration
41 namespace hashing::detail {
45 template <typename T>
47 } // namespace hashing::detail
48 
49 namespace detail {
53 template <typename T>
54 class hash_join;
55 } // namespace detail
56 
65 enum class nullable_join : bool { YES, NO };
66 
74 class hash_join {
75  public:
78 
79  hash_join() = delete;
80  ~hash_join();
81  hash_join(hash_join const&) = delete;
82  hash_join(hash_join&&) = delete;
83  hash_join& operator=(hash_join const&) = delete;
84  hash_join& operator=(hash_join&&) = delete;
85 
97  null_equality compare_nulls,
99 
108  null_equality compare_nulls,
110 
129  [[nodiscard]] std::pair<std::unique_ptr<rmm::device_uvector<size_type>>,
130  std::unique_ptr<rmm::device_uvector<size_type>>>
132  std::optional<std::size_t> output_size = {},
135 
154  [[nodiscard]] std::pair<std::unique_ptr<rmm::device_uvector<size_type>>,
155  std::unique_ptr<rmm::device_uvector<size_type>>>
157  std::optional<std::size_t> output_size = {},
160 
179  [[nodiscard]] std::pair<std::unique_ptr<rmm::device_uvector<size_type>>,
180  std::unique_ptr<rmm::device_uvector<size_type>>>
182  std::optional<std::size_t> output_size = {},
185 
199  [[nodiscard]] std::size_t inner_join_size(
200  cudf::table_view const& probe, rmm::cuda_stream_view stream = cudf::get_default_stream()) const;
201 
215  [[nodiscard]] std::size_t left_join_size(
216  cudf::table_view const& probe, rmm::cuda_stream_view stream = cudf::get_default_stream()) const;
217 
233  [[nodiscard]] std::size_t full_join_size(
234  cudf::table_view const& probe,
237 
238  private:
239  std::unique_ptr<impl_type const> _impl;
240 };
241  // end of group
243 
244 } // namespace CUDF_EXPORT cudf
Forward declaration for our hash join.
Definition: hash_join.hpp:54
Hash join that builds hash table in creation and probes results in subsequent *_join member functions...
Definition: hash_join.hpp:74
std::pair< std::unique_ptr< rmm::device_uvector< size_type > >, std::unique_ptr< rmm::device_uvector< size_type > > > left_join(cudf::table_view const &probe, std::optional< std::size_t > output_size={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref()) const
hash_join(cudf::table_view const &build, nullable_join has_nulls, null_equality compare_nulls, rmm::cuda_stream_view stream=cudf::get_default_stream())
Construct a hash join object for subsequent probe calls.
typename cudf::detail::hash_join< cudf::hashing::detail::MurmurHash3_x86_32< cudf::hash_value_type > > impl_type
Implementation type.
Definition: hash_join.hpp:77
std::size_t left_join_size(cudf::table_view const &probe, rmm::cuda_stream_view stream=cudf::get_default_stream()) const
std::size_t inner_join_size(cudf::table_view const &probe, rmm::cuda_stream_view stream=cudf::get_default_stream()) const
hash_join(cudf::table_view const &build, null_equality compare_nulls, rmm::cuda_stream_view stream=cudf::get_default_stream())
Construct a hash join object for subsequent probe calls.
std::pair< std::unique_ptr< rmm::device_uvector< size_type > >, std::unique_ptr< rmm::device_uvector< size_type > > > inner_join(cudf::table_view const &probe, std::optional< std::size_t > output_size={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref()) const
std::pair< std::unique_ptr< rmm::device_uvector< size_type > >, std::unique_ptr< rmm::device_uvector< size_type > > > full_join(cudf::table_view const &probe, std::optional< std::size_t > output_size={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref()) const
std::size_t full_join_size(cudf::table_view const &probe, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref()) const
Forward declaration for our Murmur Hash 3 implementation.
Definition: hash_join.hpp:46
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:200
nullable_join
The enum class to specify if any of the input join tables (build table and any later probe table) has...
Definition: hash_join.hpp:65
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
null_equality
Enum to consider two nulls as equal or unequal.
Definition: types.hpp:151
cuDF interfaces
Definition: host_udf.hpp:37
bool has_nulls(table_view const &view)
Returns True if the table has nulls in any of its columns.
Class definitions for (mutable)_table_view
Type declarations for libcudf.