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 #include <cuda_runtime.h>
12 
18 namespace CUDF_EXPORT cudf {
36 template <typename IndexType>
38  using value_type = IndexType;
39 
40  dictionary_wrapper() = default;
41  ~dictionary_wrapper() = default;
44 
51 
58 
64  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
65 
71  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
72 
78  CUDF_HOST_DEVICE [[nodiscard]] inline value_type value() const { return _value; }
79 
85  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
86  {
87  return cuda::std::numeric_limits<value_type>::max();
88  }
89 
95  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
96  {
97  return cuda::std::numeric_limits<value_type>::min();
98  }
99 
105  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
106  {
107  return cuda::std::numeric_limits<value_type>::lowest();
108  }
109 
110  private:
111  value_type _value;
112 };
113 
114 // comparison operators
123 template <typename Integer>
125  dictionary_wrapper<Integer> const& rhs)
126 {
127  return lhs.value() == rhs.value();
128 }
129 
138 template <typename Integer>
140  dictionary_wrapper<Integer> const& rhs)
141 {
142  return lhs.value() != rhs.value();
143 }
144 
153 template <typename Integer>
155  dictionary_wrapper<Integer> const& rhs)
156 {
157  return lhs.value() <= rhs.value();
158 }
159 
168 template <typename Integer>
170  dictionary_wrapper<Integer> const& rhs)
171 {
172  return lhs.value() >= rhs.value();
173 }
174 
183 template <typename Integer>
184 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
185  dictionary_wrapper<Integer> const& rhs)
186 {
187  return lhs.value() < rhs.value();
188 }
189 
198 template <typename Integer>
200  dictionary_wrapper<Integer> const& rhs)
201 {
202  return lhs.value() > rhs.value();
203 }
204 
206  // end of group
208 } // 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:124
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:139
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:169
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:184
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:199
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:154
cuDF interfaces
Definition: host_udf.hpp:26
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:37
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:64
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:38
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:105
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:95
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:85
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:78
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21