dictionary.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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 {
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 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
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:181
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:196
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:211
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:166
constexpr bool operator==(data_type const &lhs, data_type const &rhs)
Compares two data_type objects for equality.
Definition: types.hpp:314
bool operator!=(data_type const &lhs, data_type const &rhs)
Compares two data_type objects for inequality.
Definition: types.hpp:332
cuDF interfaces
Definition: aggregation.hpp:34
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:49
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:76
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:50
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:117
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:107
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:97
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:90
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:32