dictionary.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/types.hpp>
9 
10 #include <cuda_runtime.h>
11 
12 #include <limits>
13 
19 namespace CUDF_EXPORT cudf {
37 template <typename IndexType>
39  using value_type = IndexType;
40 
41  dictionary_wrapper() = default;
42  ~dictionary_wrapper() = default;
45 
52 
59 
65  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
66 
72  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
73 
79  CUDF_HOST_DEVICE [[nodiscard]] inline value_type value() const { return _value; }
80 
86  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
87  {
88  return std::numeric_limits<value_type>::max();
89  }
90 
96  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
97  {
98  return std::numeric_limits<value_type>::min();
99  }
100 
106  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
107  {
108  return std::numeric_limits<value_type>::lowest();
109  }
110 
111  private:
112  value_type _value;
113 };
114 
115 // comparison operators
124 template <typename Integer>
126  dictionary_wrapper<Integer> const& rhs)
127 {
128  return lhs.value() == rhs.value();
129 }
130 
139 template <typename Integer>
141  dictionary_wrapper<Integer> const& rhs)
142 {
143  return lhs.value() != rhs.value();
144 }
145 
154 template <typename Integer>
156  dictionary_wrapper<Integer> const& rhs)
157 {
158  return lhs.value() <= rhs.value();
159 }
160 
169 template <typename Integer>
171  dictionary_wrapper<Integer> const& rhs)
172 {
173  return lhs.value() >= rhs.value();
174 }
175 
184 template <typename Integer>
185 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
186  dictionary_wrapper<Integer> const& rhs)
187 {
188  return lhs.value() < rhs.value();
189 }
190 
199 template <typename Integer>
201  dictionary_wrapper<Integer> const& rhs)
202 {
203  return lhs.value() > rhs.value();
204 }
205 
207  // end of group
209 } // 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:125
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:140
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:170
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:185
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:200
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:155
cuDF interfaces
Definition: host_udf.hpp:26
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:38
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:65
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:39
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:106
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:96
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:86
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:79
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21