dictionary.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, 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;
54  dictionary_wrapper(dictionary_wrapper const& v) = default;
55  dictionary_wrapper& operator=(dictionary_wrapper&&) = default;
56  dictionary_wrapper& operator=(const dictionary_wrapper&) = default;
57 
58  // construct object from type
59  CUDA_HOST_DEVICE_CALLABLE constexpr explicit dictionary_wrapper(value_type v) : _value{v} {}
60 
61  // conversion operator
62  CUDA_HOST_DEVICE_CALLABLE explicit operator value_type() const { return _value; }
63  // simple accessor
64  CUDA_HOST_DEVICE_CALLABLE value_type value() const { return _value; }
65 
66  static CUDA_HOST_DEVICE_CALLABLE constexpr value_type max_value()
67  {
68  return std::numeric_limits<value_type>::max();
69  }
70  static CUDA_HOST_DEVICE_CALLABLE constexpr value_type min_value()
71  {
72  return std::numeric_limits<value_type>::min();
73  }
74  static CUDA_HOST_DEVICE_CALLABLE constexpr value_type lowest_value()
75  {
76  return std::numeric_limits<IndexType>::lowest();
77  }
78 
79  private:
80  value_type _value;
81 };
82 
83 // comparison operators
84 template <typename Integer>
85 CUDA_HOST_DEVICE_CALLABLE bool operator==(dictionary_wrapper<Integer> const& lhs,
86  dictionary_wrapper<Integer> const& rhs)
87 {
88  return lhs.value() == rhs.value();
89 }
90 
91 template <typename Integer>
92 CUDA_HOST_DEVICE_CALLABLE bool operator!=(dictionary_wrapper<Integer> const& lhs,
93  dictionary_wrapper<Integer> const& rhs)
94 {
95  return lhs.value() != rhs.value();
96 }
97 
98 template <typename Integer>
99 CUDA_HOST_DEVICE_CALLABLE bool operator<=(dictionary_wrapper<Integer> const& lhs,
100  dictionary_wrapper<Integer> const& rhs)
101 {
102  return lhs.value() <= rhs.value();
103 }
104 
105 template <typename Integer>
106 CUDA_HOST_DEVICE_CALLABLE bool operator>=(dictionary_wrapper<Integer> const& lhs,
107  dictionary_wrapper<Integer> const& rhs)
108 {
109  return lhs.value() >= rhs.value();
110 }
111 
112 template <typename Integer>
113 CUDA_HOST_DEVICE_CALLABLE constexpr bool operator<(dictionary_wrapper<Integer> const& lhs,
114  dictionary_wrapper<Integer> const& rhs)
115 {
116  return lhs.value() < rhs.value();
117 }
118 
119 template <typename Integer>
120 CUDA_HOST_DEVICE_CALLABLE bool operator>(dictionary_wrapper<Integer> const& lhs,
121  dictionary_wrapper<Integer> const& rhs)
122 {
123  return lhs.value() > rhs.value();
124 }
125 
126 using dictionary32 = dictionary_wrapper<int32_t>;
127  // end of group
129 } // namespace cudf
types.hpp
Type declarations for libcudf.
cudf::dictionary_wrapper
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:48
numeric::operator>
CUDA_HOST_DEVICE_CALLABLE bool operator>(fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs)
Definition: fixed_point.hpp:767
cudf
cuDF interfaces
Definition: aggregation.hpp:34
numeric::operator<
CUDA_HOST_DEVICE_CALLABLE bool operator<(fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs)
Definition: fixed_point.hpp:758
numeric::operator<=
CUDA_HOST_DEVICE_CALLABLE bool operator<=(fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs)
Definition: fixed_point.hpp:740
numeric::operator>=
CUDA_HOST_DEVICE_CALLABLE bool operator>=(fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs)
Definition: fixed_point.hpp:749
cudf::operator==
constexpr bool operator==(data_type const &lhs, data_type const &rhs)
Compares two data_type objects for equality.
Definition: types.hpp:300
cudf::operator!=
bool operator!=(data_type const &lhs, data_type const &rhs)
Compares two data_type objects for inequality.
Definition: types.hpp:318