dictionary.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
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 {
39 template <typename IndexType>
41  using value_type = IndexType;
42 
43  dictionary_wrapper() = default;
44  ~dictionary_wrapper() = default;
47 
54 
61 
67  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
68 
74  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
75 
81  CUDF_HOST_DEVICE [[nodiscard]] inline value_type value() const { return _value; }
82 
88  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
89  {
90  return cuda::std::numeric_limits<value_type>::max();
91  }
92 
98  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
99  {
100  return cuda::std::numeric_limits<value_type>::min();
101  }
102 
108  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
109  {
110  return cuda::std::numeric_limits<value_type>::lowest();
111  }
112 
113  private:
114  value_type _value;
115 };
116 
117 // comparison operators
126 template <typename Integer>
128  dictionary_wrapper<Integer> const& rhs)
129 {
130  return lhs.value() == rhs.value();
131 }
132 
141 template <typename Integer>
143  dictionary_wrapper<Integer> const& rhs)
144 {
145  return lhs.value() != rhs.value();
146 }
147 
156 template <typename Integer>
158  dictionary_wrapper<Integer> const& rhs)
159 {
160  return lhs.value() <= rhs.value();
161 }
162 
171 template <typename Integer>
173  dictionary_wrapper<Integer> const& rhs)
174 {
175  return lhs.value() >= rhs.value();
176 }
177 
186 template <typename Integer>
187 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
188  dictionary_wrapper<Integer> const& rhs)
189 {
190  return lhs.value() < rhs.value();
191 }
192 
201 template <typename Integer>
203  dictionary_wrapper<Integer> const& rhs)
204 {
205  return lhs.value() > rhs.value();
206 }
207 
209  // end of group
211 } // 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:127
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:142
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:172
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:187
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:202
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:157
cuDF interfaces
Definition: host_udf.hpp:26
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:40
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:67
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:41
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:108
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:98
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:88
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:81
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21