iterator_utilities.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/detail/iterator.cuh>
9 #include <cudf/types.hpp>
10 #include <cudf/utilities/export.hpp>
11 
12 #include <thrust/iterator/constant_iterator.h>
13 #include <thrust/iterator/transform_iterator.h>
14 
15 #include <iterator>
16 
17 namespace CUDF_EXPORT cudf {
18 namespace test {
19 namespace iterators {
41 template <typename Iter>
42 [[maybe_unused]] static auto nulls_at(Iter index_start, Iter index_end)
43 {
44  using index_type = typename std::iterator_traits<Iter>::value_type;
45 
46  return cudf::detail::make_counting_transform_iterator(
47  0, [indices = std::vector<index_type>{index_start, index_end}](auto i) {
48  return std::find(indices.cbegin(), indices.cend(), i) == indices.cend();
49  });
50 }
51 
69 [[maybe_unused]] static auto nulls_at(std::vector<cudf::size_type> const& indices)
70 {
71  return nulls_at(indices.cbegin(), indices.cend());
72 }
73 
89 [[maybe_unused]] static auto null_at(cudf::size_type index)
90 {
91  return nulls_at(std::vector<cudf::size_type>{index});
92 }
93 
99 [[maybe_unused]] static auto all_nulls() { return thrust::make_constant_iterator(false); }
100 
106 [[maybe_unused]] static auto no_nulls() { return thrust::make_constant_iterator(true); }
107 
121 template <class T>
122 [[maybe_unused]] static auto nulls_from_nullptrs(std::vector<T const*> const& ptrs)
123 {
124  return thrust::make_transform_iterator(ptrs.begin(), [](auto ptr) { return ptr != nullptr; });
125 }
126 
127 } // namespace iterators
128 } // namespace test
129 } // namespace CUDF_EXPORT cudf
std::unique_ptr< column > find(strings_column_view const &input, string_scalar const &target, size_type start=0, size_type stop=-1, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Returns a column of character position values where the target string is first found in each string o...
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
cuDF interfaces
Definition: host_udf.hpp:26
Type declarations for libcudf.