21#include <cudf/column/column_factories.hpp>
22#include <cudf/filling.hpp>
23#include <cudf/scalar/scalar_factories.hpp>
25#include <cudf_test/column_wrapper.hpp>
27#include <initializer_list>
29#include <rmm/cuda_stream_view.hpp>
35using namespace cudf::test;
37std::unique_ptr<column> coords_offsets(size_type num_points, rmm::cuda_stream_view stream)
39 auto zero = make_fixed_width_scalar<size_type>(0, stream);
40 auto two = make_fixed_width_scalar<size_type>(2, stream);
42 return sequence(num_points + 1, *zero, *two);
46std::unique_ptr<column> make_non_nullable_lists_column(std::unique_ptr<column> offset,
47 std::unique_ptr<column> child)
49 auto size = offset->size() - 1;
50 return make_lists_column(size, std::move(offset), std::move(child), 0, {});
54std::unique_ptr<column> make_non_nullable_lists_column(std::initializer_list<size_type> offset,
55 std::unique_ptr<column> child)
57 auto d_offset = fixed_width_column_wrapper<size_type>(offset).release();
58 return make_non_nullable_lists_column<T>(std::move(d_offset), std::move(child));
62std::unique_ptr<column> make_non_nullable_lists_column(std::unique_ptr<column> offset,
63 std::initializer_list<T> child)
65 auto d_child = fixed_width_column_wrapper<T>(child).release();
66 return make_non_nullable_lists_column<T>(std::move(offset), std::move(d_child));
87std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_point_column(
88 std::initializer_list<T>&& point_coords, rmm::cuda_stream_view stream)
90 auto num_points = point_coords.size() / 2;
92 return {collection_type_id::SINGLE,
93 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), point_coords)};
115std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_point_column(
116 std::initializer_list<cudf::size_type>&& multipoint_offsets,
117 std::initializer_list<T> point_coords,
118 rmm::cuda_stream_view stream)
120 auto num_points = point_coords.size() / 2;
122 return {collection_type_id::MULTI,
123 make_non_nullable_lists_column<T>(
125 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), point_coords))};
147std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_linestring_column(
148 std::initializer_list<cudf::size_type>&& linestring_offsets,
149 std::initializer_list<T>&& linestring_coords,
150 rmm::cuda_stream_view stream)
152 auto num_points = linestring_coords.size() / 2;
155 collection_type_id::SINGLE,
156 make_non_nullable_lists_column<T>(
158 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), linestring_coords))};
185std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_linestring_column(
186 std::initializer_list<cudf::size_type>&& multilinestring_offsets,
187 std::initializer_list<cudf::size_type>&& linestring_offsets,
188 std::initializer_list<T> linestring_coords,
189 rmm::cuda_stream_view stream)
191 auto num_points = linestring_coords.size() / 2;
193 collection_type_id::MULTI,
194 make_non_nullable_lists_column<T>(
195 multilinestring_offsets,
196 make_non_nullable_lists_column<T>(
198 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), linestring_coords)))};
225std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_polygon_column(
226 std::initializer_list<cudf::size_type>&& polygon_offsets,
227 std::initializer_list<cudf::size_type>&& ring_offsets,
228 std::initializer_list<T> polygon_coords,
229 rmm::cuda_stream_view stream)
231 auto num_points = polygon_coords.size() / 2;
233 collection_type_id::SINGLE,
234 make_non_nullable_lists_column<T>(
236 make_non_nullable_lists_column<T>(
238 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), polygon_coords)))};
267std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_polygon_column(
268 std::initializer_list<cudf::size_type>&& multipolygon_offsets,
269 std::initializer_list<cudf::size_type>&& polygon_offsets,
270 std::initializer_list<cudf::size_type>&& ring_offsets,
271 std::initializer_list<T> polygon_coords,
272 rmm::cuda_stream_view stream)
274 auto num_points = polygon_coords.size() / 2;
276 collection_type_id::MULTI,
277 make_non_nullable_lists_column<T>(
278 multipolygon_offsets,
279 make_non_nullable_lists_column<T>(
281 make_non_nullable_lists_column<T>(
283 make_non_nullable_lists_column<T>(coords_offsets(num_points, stream), polygon_coords))))};