type_checks.hpp
1 /*
2  * Copyright (c) 2021-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 #pragma once
17 
19 #include <cudf/scalar/scalar.hpp>
20 
21 #include <algorithm>
22 
23 namespace CUDF_EXPORT cudf {
24 
35 bool column_types_equivalent(column_view const& lhs, column_view const& rhs);
36 
52 bool have_same_types(column_view const& lhs, column_view const& rhs);
53 
69 bool have_same_types(column_view const& lhs, scalar const& rhs);
70 
86 bool have_same_types(scalar const& lhs, column_view const& rhs);
87 
101 bool have_same_types(scalar const& lhs, scalar const& rhs);
102 
110 bool have_same_types(table_view const& lhs, table_view const& rhs);
111 
123 template <typename ForwardIt>
124 inline bool all_have_same_types(ForwardIt first, ForwardIt last)
125 {
126  return first == last || std::all_of(std::next(first), last, [want = *first](auto const& c) {
127  return cudf::have_same_types(want, c);
128  });
129 }
130 
131 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
An owning class to represent a singular value.
Definition: scalar.hpp:49
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:200
column view class definitions
cuDF interfaces
Definition: aggregation.hpp:35
bool column_types_equivalent(column_view const &lhs, column_view const &rhs)
Compare the type IDs of two column_views.
bool all_have_same_types(ForwardIt first, ForwardIt last)
Compare the types of a range of column_view or scalar objects.
bool have_same_types(column_view const &lhs, column_view const &rhs)
Compares the type of two column_views.
Class definitions for cudf::scalar.