dictionary.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/types.hpp>
9 
10 #include <cuda/std/limits>
11 
12 #ifndef __CUDACC_RTC__
13 #include <cuda_runtime.h>
14 #endif
15 
21 namespace CUDF_EXPORT cudf {
38 template <typename IndexType>
40  using value_type = IndexType;
41 
42  dictionary_wrapper() = default;
43  ~dictionary_wrapper() = default;
46 
53 
60 
66  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
67 
73  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
74 
80  CUDF_HOST_DEVICE [[nodiscard]] inline value_type value() const { return _value; }
81 
87  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
88  {
89  return cuda::std::numeric_limits<value_type>::max();
90  }
91 
97  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
98  {
99  return cuda::std::numeric_limits<value_type>::min();
100  }
101 
107  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
108  {
109  return cuda::std::numeric_limits<value_type>::lowest();
110  }
111 
112  private:
113  value_type _value;
114 };
115 
116 // comparison operators
125 template <typename Integer>
127  dictionary_wrapper<Integer> const& rhs)
128 {
129  return lhs.value() == rhs.value();
130 }
131 
140 template <typename Integer>
142  dictionary_wrapper<Integer> const& rhs)
143 {
144  return lhs.value() != rhs.value();
145 }
146 
155 template <typename Integer>
157  dictionary_wrapper<Integer> const& rhs)
158 {
159  return lhs.value() <= rhs.value();
160 }
161 
170 template <typename Integer>
172  dictionary_wrapper<Integer> const& rhs)
173 {
174  return lhs.value() >= rhs.value();
175 }
176 
185 template <typename Integer>
186 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
187  dictionary_wrapper<Integer> const& rhs)
188 {
189  return lhs.value() < rhs.value();
190 }
191 
200 template <typename Integer>
202  dictionary_wrapper<Integer> const& rhs)
203 {
204  return lhs.value() > rhs.value();
205 }
206 
208  // end of group
210 } // namespace CUDF_EXPORT cudf
CUDF_HOST_DEVICE bool operator==(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Wqual to operator for dictionary_wrapper.
Definition: dictionary.hpp:126
CUDF_HOST_DEVICE bool operator!=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Not equal to operator for dictionary_wrapper.
Definition: dictionary.hpp:141
CUDF_HOST_DEVICE bool operator>=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than or equal to operator for dictionary_wrapper.
Definition: dictionary.hpp:171
constexpr CUDF_HOST_DEVICE bool operator<(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Less than operator for dictionary_wrapper.
Definition: dictionary.hpp:186
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:201
CUDF_HOST_DEVICE bool operator<=(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Less than or equal to operator for dictionary_wrapper.
Definition: dictionary.hpp:156
cuDF interfaces
Definition: host_udf.hpp:26
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:39
dictionary_wrapper & operator=(dictionary_wrapper &&)=default
Move assignment operator.
constexpr CUDF_HOST_DEVICE dictionary_wrapper(value_type v)
Construct dictionary_wrapper from a value.
Definition: dictionary.hpp:66
dictionary_wrapper(dictionary_wrapper &&)=default
Move constructor.
dictionary_wrapper(dictionary_wrapper const &)=default
Copy constructor.
IndexType value_type
The underlying type of the dictionary.
Definition: dictionary.hpp:40
dictionary_wrapper & operator=(dictionary_wrapper const &)=default
Copy assignment operator.
static constexpr CUDF_HOST_DEVICE value_type lowest_value()
Returns the lowest value of the value type.
Definition: dictionary.hpp:107
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:97
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:87
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:80
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21