libcudf  24.02.00
dictionary.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2023, 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 <cuda_runtime.h>
20 #include <cudf/types.hpp>
21 
22 #include <limits>
23 
29 namespace cudf {
47 template <typename IndexType>
49  using value_type = IndexType;
50 
51  dictionary_wrapper() = default;
52  ~dictionary_wrapper() = default;
55 
62 
69 
75  CUDF_HOST_DEVICE inline constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
76 
82  CUDF_HOST_DEVICE inline explicit operator value_type() const { return _value; }
83 
89  CUDF_HOST_DEVICE inline value_type value() const { return _value; }
90 
96  static CUDF_HOST_DEVICE inline constexpr value_type max_value()
97  {
98  return std::numeric_limits<value_type>::max();
99  }
100 
106  static CUDF_HOST_DEVICE inline constexpr value_type min_value()
107  {
108  return std::numeric_limits<value_type>::min();
109  }
110 
116  static CUDF_HOST_DEVICE inline constexpr value_type lowest_value()
117  {
118  return std::numeric_limits<value_type>::lowest();
119  }
120 
121  private:
122  value_type _value;
123 };
124 
125 // comparison operators
134 template <typename Integer>
136  dictionary_wrapper<Integer> const& rhs)
137 {
138  return lhs.value() == rhs.value();
139 }
140 
149 template <typename Integer>
151  dictionary_wrapper<Integer> const& rhs)
152 {
153  return lhs.value() != rhs.value();
154 }
155 
164 template <typename Integer>
166  dictionary_wrapper<Integer> const& rhs)
167 {
168  return lhs.value() <= rhs.value();
169 }
170 
179 template <typename Integer>
181  dictionary_wrapper<Integer> const& rhs)
182 {
183  return lhs.value() >= rhs.value();
184 }
185 
194 template <typename Integer>
195 CUDF_HOST_DEVICE inline constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
196  dictionary_wrapper<Integer> const& rhs)
197 {
198  return lhs.value() < rhs.value();
199 }
200 
209 template <typename Integer>
211  dictionary_wrapper<Integer> const& rhs)
212 {
213  return lhs.value() > rhs.value();
214 }
215 
217  // end of group
219 } // 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:180
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:195
CUDF_HOST_DEVICE bool operator>(dictionary_wrapper< Integer > const &lhs, dictionary_wrapper< Integer > const &rhs)
Greater than operator for dictionary_wrapper.
Definition: dictionary.hpp:210
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:165
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:48
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:75
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:49
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:116
static constexpr CUDF_HOST_DEVICE value_type min_value()
Returns the minimum value of the value type.
Definition: dictionary.hpp:106
static constexpr CUDF_HOST_DEVICE value_type max_value()
Returns the maximum value of the value type.
Definition: dictionary.hpp:96
CUDF_HOST_DEVICE value_type value() const
Simple accessor.
Definition: dictionary.hpp:89
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:32