dictionary.hpp
查看此文件的文档。
1 /*
2  * 版权所有 (c) 2020-2024, NVIDIA CORPORATION.
3  *
4  * 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
5  * 除非符合许可证的规定,否则您不得使用此文件。
6  * 您可以获取许可证的副本,地址为:
7  *
8  * https://apache.ac.cn/licenses/LICENSE-2.0
9  *
10  * 除非适用法律要求或书面同意,否则根据许可证分发的软件
11  * 按“原样”提供,不附带任何明示或暗示的保证或条件。
12  * 请参阅许可证,了解特定语言的权限和限制。
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/types.hpp>
20 
21 #include <cuda_runtime.h>
22 
23 #include <limits>
24 
30 namespace CUDF_EXPORT cudf {
48 template <typename IndexType>
50  using value_type = IndexType;
51 
52  dictionary_wrapper() = default;
53  ~dictionary_wrapper() = default;
56 
63 
70 
76  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
77 
83  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
84 
90  CUDF_HOST_DEVICE [[nodiscard]] inline value_type value() const { return _value; }
91 
97  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
98  {
99  return std::numeric_limits<value_type>::max();
100  }
101 
107  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
108  {
109  return std::numeric_limits<value_type>::min();
110  }
111 
117  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
118  {
119  return std::numeric_limits<value_type>::lowest();
120  }
121 
122  private
123  value_type _value;
124 };
125 
126 // comparison operators
135 template <typename Integer>
137  dictionary_wrapper<Integer> const& rhs)
138 {
139  return lhs.value() == rhs.value();
140 }
141 
150 template <typename Integer>
152  dictionary_wrapper<Integer> const& rhs)
153 {
154  return lhs.value() != rhs.value();
155 }
156 
165 template <typename Integer>
167  dictionary_wrapper<Integer> const& rhs)
168 {
169  return lhs.value() <= rhs.value();
170 }
171 
180 template <typename Integer>
182  dictionary_wrapper<Integer> const& rhs)
183 {
184  return lhs.value() >= rhs.value();
185 }
186 
195 template <typename Integer>
196 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
197  dictionary_wrapper<Integer> const& rhs)
198 {
199  return lhs.value() < rhs.value();
200 }
201 
210 template <typename Integer>
212  dictionary_wrapper<Integer> const& rhs)
213 {
214  return lhs.value() > rhs.value();
215 }
216 
218  // end of group
220 } // namespace CUDF_EXPORT cudf
CUDF_HOST_DEVICE bool operator==(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的相等运算符。
CUDF_HOST_DEVICE bool operator!=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的不等运算符。
CUDF_HOST_DEVICE bool operator>=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的大于等于运算符。
constexpr CUDF_HOST_DEVICE bool operator<(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的小于运算符。
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的大于运算符。
CUDF_HOST_DEVICE bool operator<=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
dictionary_wrapper 的小于等于运算符。
cuDF 接口
定义: host_udf.hpp:37
用于字典类型列中索引的强类型包装器。
dictionary_wrapper & operator=(dictionary_wrapper &&)=default
移动赋值运算符。
constexpr CUDF_HOST_DEVICE dictionary_wrapper(value_type v)
从值构造 dictionary_wrapper。
dictionary_wrapper(dictionary_wrapper &&)=default
移动构造函数。
dictionary_wrapper(dictionary_wrapper const &)=default
复制构造函数。
IndexType value_type
字典的底层类型。
dictionary_wrapper & operator=(dictionary_wrapper const &)=default
复制赋值运算符。
static constexpr CUDF_HOST_DEVICE value_type lowest_value()
返回值类型的最低值。
static constexpr CUDF_HOST_DEVICE value_type min_value()
返回值类型的最小值。
static constexpr CUDF_HOST_DEVICE value_type max_value()
返回值类型的最大值。
CUDF_HOST_DEVICE value_type value() const
简单访问器。
libcudf 的类型声明。
#define CUDF_HOST_DEVICE
指示函数或方法可在主机和设备上使用。
定义: types.hpp:32