From b33186b788992b2f3e2741dbd45ebb69c8926c18 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 18 Aug 2026 11:07:22 -0700 Subject: [PATCH 01/21] Add lists_column_initializer and opt-in harness failing-current helper Expose scoped fail_on_current_device_resource_use() on BaseFixtureWithHarness, add recursive list initializers for explicit stream/mr nesting, and port list gather test construction sites without changing gather production APIs. --- cpp/include/cudf_test/base_fixture.hpp | 15 + cpp/include/cudf_test/column_wrapper.hpp | 383 +++++++--- cpp/tests/copying/gather_list_tests.cpp | 441 +++++++---- .../copying/segmented_gather_list_tests.cpp | 696 +++++++++++------- .../utilities/memory_resource_utilities.cpp | 20 + .../lists_column_wrapper_tests.cpp | 68 ++ 6 files changed, 1116 insertions(+), 507 deletions(-) diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index 003955369001..793260e47923 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -47,6 +47,8 @@ class BaseFixture : public ::testing::Test { * * Each test instantiates a fresh harness. Tests should construct results with `resources()`. * `TearDown` asserts that no output or temporary allocations remain live. + * Call `fail_on_current_device_resource_use()` in test scopes that must reject accidental + * current-device-resource allocations. */ struct BaseFixtureWithHarness : public BaseFixture { /** @@ -66,6 +68,19 @@ struct BaseFixtureWithHarness : public BaseFixture { */ cudf::memory_resources resources() { return _harness.resources(); } + /** + * @brief Install a scoped failing current-device resource. + * + * While the returned object is alive, allocations from the current device resource fail. + * Destroy it (or let it leave scope) to restore the previous current resource. + * + * @return Scoped guard around the failing current-device resource + */ + [[nodiscard]] scoped_current_device_resource fail_on_current_device_resource_use() + { + return _harness.fail_on_current_device_resource_use(); + } + protected: memory_resource_test_harness _harness{mr()}; }; diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index e749a086cd6b..8ac30e57b0f0 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -35,9 +35,12 @@ #include #include +#include +#include #include #include #include +#include #include namespace CUDF_EXPORT cudf { @@ -337,8 +340,175 @@ auto make_chars_and_offsets(StringsIterator begin, StringsIterator end, Validity } return std::pair(std::move(chars), std::move(offsets)); }; + } // namespace detail +// Forward declaration for lists_column_initializer::build +template +class lists_column_wrapper; + +/** + * @brief Host-side recursive initializer tree for constructing list columns with an + * explicit stream and memory resources at every nesting level. + * + * Prefer this over brace-nested `lists_column_wrapper` constructions that pass + * `stream`/`mr` only at the outer level, which leave brace-constructed children on + * the default test resources. + * + * Example: + * @code{.cpp} + * using Init = cudf::test::lists_column_initializer; + * // List: [{1, 2}, {3}] + * lists_column_wrapper col{Init{{{1, 2}, {3}}}, stream, mr}; + * @endcode + * + * Leaf and nested constructors accept the existing validity iterators + * (`valids`, `null_at(...)`, etc.) and materialize them into owned storage. + * + * @tparam T Host leaf element type (e.g. `int32_t` or `std::string`) + */ +template +class lists_column_initializer { + public: + /** + * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested + * empty `initializer_list` constructors. + */ + lists_column_initializer() = default; + + /** + * @brief Construct a leaf from scalar values. + * + * @param values Leaf element values + */ + lists_column_initializer(std::initializer_list values) : values_{values} {} + + /** + * @brief Construct a leaf from scalar values and a validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param values Leaf element values + * @param v Validity iterator over `values.size()` elements + */ + template + lists_column_initializer(std::initializer_list values, ValidityIterator v) : values_{values} + { + value_validity_.reserve(values_.size()); + for (std::size_t i = 0; i < values_.size(); ++i) { + value_validity_.push_back(static_cast(*v++)); + } + } + + /** + * @brief Construct a nested node from child initializers. + * + * This constructor is a template so the non-template leaf + * `initializer_list` constructor is preferred for scalar lists such as + * `{1, 2, 3}`. Otherwise both overloads are non-templates and constructing + * `Init` from an `int` via the nested overload recurses until the stack + * overflows. + * + * @param children Child list initializers + */ + template + lists_column_initializer(std::initializer_list children) + requires(std::is_same_v) + : children_{children.begin(), children.end()}, nested_{true} + { + } + + /** + * @brief Construct a nested node from child initializers and a row-validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param children Child list initializers + * @param v Validity iterator over `children.size()` rows + */ + template + lists_column_initializer(std::initializer_list children, ValidityIterator v) + requires(std::is_same_v) + : nested_{true} + { + children_.reserve(children.size()); + for (auto const& child : children) { + if (static_cast(*v++)) { + children_.push_back(child); + } else { + children_.emplace_back(); + children_.back().valid_ = false; + } + } + } + + /** + * @brief True if this node holds nested child initializers rather than leaf values. + * @return Whether this node is nested + */ + [[nodiscard]] bool nested() const { return nested_; } + /** + * @brief True if this row is valid (non-null) in its parent list. + * @return Whether this row is valid + */ + [[nodiscard]] bool valid() const { return valid_; } + /** + * @brief Leaf element values when `nested()` is false. + * @return Reference to the leaf values + */ + [[nodiscard]] auto const& values() const { return values_; } + /** + * @brief Per-element validity for leaf values; empty when all leaf values are valid. + * @return Reference to the leaf validity mask + */ + [[nodiscard]] auto const& value_validity() const { return value_validity_; } + /** + * @brief Child initializers when `nested()` is true. + * @return Reference to the child initializers + */ + [[nodiscard]] auto const& children() const { return children_; } + + /** + * @brief Recursively build child list wrappers and row validity for a nested node. + * + * Each valid child is allocated with the provided `stream` and `mr`. Null children are + * represented as default-constructed wrappers (skipped during concatenate). + * + * @tparam ElementT List wrapper element type + * @tparam SourceElementT Source type used by the list wrapper + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate child columns + * @return Child wrappers and an empty validity vector when all rows are valid, + * otherwise a validity mask matching `children().size()` + */ + template + [[nodiscard]] std::pair>, + std::vector> + build(rmm::cuda_stream_view stream, cudf::memory_resources mr) const + { + std::vector> children; + std::vector validity; + children.reserve(children_.size()); + validity.reserve(children_.size()); + bool any_null = false; + for (auto const& child : children_) { + any_null = any_null || !child.valid(); + validity.push_back(child.valid()); + if (child.valid()) { + children.emplace_back(child, stream, mr); + } else { + children.emplace_back(); // null rows are skipped during concatenate + } + } + return {std::move(children), any_null ? std::move(validity) : std::vector{}}; + } + + private: + std::vector values_; + std::vector value_validity_; + std::vector children_; + bool nested_{false}; + bool valid_{true}; +}; + /** * @brief `column_wrapper` derived class for wrapping columns of fixed-width * elements. @@ -1482,191 +1652,181 @@ class lists_column_wrapper : public detail::column_wrapper { operator lists_column_view() const { return cudf::lists_column_view{wrapped->view()}; } /** - * @brief Construct a lists column containing a single list of fixed-width - * type from an initializer list of values. + * @brief Host-side leaf element type (`std::string` for string lists, else `SourceElementT`). + */ + using host_element_t = + std::conditional_t, std::string, SourceElementT>; + /** + * @brief Column wrapper type used to materialize leaf list contents. + */ + using leaf_wrapper_t = std::conditional_t, + strings_column_wrapper, + fixed_width_column_wrapper>; + + /** + * @brief Construct a lists column containing a single list from an initializer + * list of values. * * Example: * @code{.cpp} - * Creates a LIST column with 1 list composed of 2 total integers - * [{0, 1}] + * // Creates a LIST column with 1 list composed of 2 total integers + * // [{0, 1}] * lists_column_wrapper l{0, 1}; * @endcode * + * These leaf constructors are templates (via `requires`) so that the non-template + * nested `initializer_list` constructor is preferred for + * ambiguous cases such as `lists_column_wrapper{{}, {}}`. + * * @param elements The list of elements * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> + template lists_column_wrapper(std::initializer_list elements, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width()) : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(elements, stream, mr).release(), - stream, - mr); + fixed_width_column_wrapper(elements, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list of fixed-width - * type from an iterator range. + * @brief Construct a lists column containing a single list of strings. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); - * // [{0, 1, 2, 3, 4}] - * lists_column_wrapper l(elements, elements+5); + * // Creates a LIST column with 1 list composed of 2 total strings + * // [{"abc", "def"}] + * lists_column_wrapper s{"abc", "def"}; * @endcode * - * @param begin Beginning of the sequence - * @param end End of the sequence + * @param elements The list of strings * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> - lists_column_wrapper(InputIterator begin, - InputIterator end, + template + lists_column_wrapper(std::initializer_list elements, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v) : column_wrapper{} { - build_from_non_nested( - cudf::test::fixed_width_column_wrapper(begin, end, stream, mr).release(), - stream, - mr); + build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list of fixed-width - * type from an initializer list of values and a validity iterator. + * @brief Construct a lists column containing a single list from an iterator range. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 lists composed of 2 total integers - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL}] - * lists_column_wrapper l{{0, 1}, validity}; + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * // [{0, 1, 2, 3, 4}] + * lists_column_wrapper l(elements, elements+5); * @endcode * - * @param elements The list of elements - * @param v The validity iterator + * @param begin Beginning of the sequence + * @param end End of the sequence * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, + template + lists_column_wrapper(InputIterator begin, + InputIterator end, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { - build_from_non_nested( - cudf::test::fixed_width_column_wrapper(elements, v, stream, mr).release(), - stream, - mr); + build_from_non_nested(leaf_wrapper_t(begin, end, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list of fixed-width - * type from an iterator range and a validity iterator. + * @brief Construct a lists column containing a single list from an initializer + * list of values and a validity iterator. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 lists composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * // Creates a LIST column with 1 list composed of 2 total integers * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL, 2, NULL, 4}] - * lists_column_wrapper l(elements, elements+5, validity); + * // [{0, NULL}] + * lists_column_wrapper l{{0, 1}, validity}; * @endcode * - * @param begin Beginning of the sequence - * @param end End of the sequence + * @param elements The list of elements * @param v The validity iterator * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> - lists_column_wrapper(InputIterator begin, - InputIterator end, + template + lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width()) : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(begin, end, v, stream, mr) - .release(), - stream, - mr); + fixed_width_column_wrapper(elements, v, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list of strings - * from an initializer list of values. + * @brief Construct a lists column containing a single list of strings and a + * validity iterator. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total strings - * // [{"abc", "def"}] - * lists_column_wrapper l{"abc", "def"}; + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{"abc", NULL}] + * lists_column_wrapper l{{"abc", "def"}, validity}; * @endcode * - * @param elements The list of elements + * @param elements The list of strings + * @param v The validity iterator * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template >* = nullptr> + template lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v) : column_wrapper{} { - build_from_non_nested( - cudf::test::strings_column_wrapper(elements.begin(), elements.end(), stream, mr).release(), - stream, - mr); + build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list of strings - * from an initializer list of values and a validity iterator. + * @brief Construct a lists column containing a single list from an iterator + * range and a validity iterator. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total strings + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{"abc", NULL}] - * lists_column_wrapper l{{"abc", "def"}, validity}; + * // [{0, NULL, 2, NULL, 4}] + * lists_column_wrapper l(elements, elements+5, validity); * @endcode * - * @param elements The list of elements + * @param begin Beginning of the sequence + * @param end End of the sequence * @param v The validity iterator * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template >* = nullptr> - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(InputIterator begin, + InputIterator end, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { - build_from_non_nested( - cudf::test::strings_column_wrapper(elements.begin(), elements.end(), v, stream, mr).release(), - stream, - mr); + build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); } /** @@ -1688,6 +1848,11 @@ class lists_column_wrapper : public detail::column_wrapper { * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; * @endcode * + * For multi-row (and deeper) columns that should allocate with an explicit stream/mr, use + * `lists_column_initializer` so every nesting level receives those arguments: + * `using Init = cudf::test::lists_column_initializer;` + * `lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr};` + * * @param elements The list of elements * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column @@ -1763,6 +1928,46 @@ class lists_column_wrapper : public detail::column_wrapper { build_from_nested(elements, validity, stream, mr); } + /** + * @brief Construct a lists column from a recursive `lists_column_initializer` tree. + * + * Every nesting level is allocated with the provided `stream` and `mr`. Prefer this over + * brace-nested `lists_column_wrapper` constructions that pass resources only at the outer + * level. + * + * Example: + * @code{.cpp} + * using Init = cudf::test::lists_column_initializer; + * // List: [{0, 1}, {2, 3}, {4, 5}] + * lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr}; + * + * // List>: [{{0, 1}, {2}}, {{3}}] + * lists_column_wrapper nested{Init{{{{0, 1}, {2}}, {{3}}}}, stream, mr}; + * @endcode + * + * @param init Host-side nested values (and optional validity) + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(lists_column_initializer init, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) + : column_wrapper{} + { + if (!init.nested()) { + if (init.value_validity().empty()) { + *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); + } else { + *this = lists_column_wrapper( + init.values().begin(), init.values().end(), init.value_validity().begin(), stream, mr); + } + return; + } + + auto [children, validity] = init.template build(stream, mr); + build_from_nested(children, validity, stream, mr); + } + /** * @brief Construct a list column containing a single empty, optionally null row. * @@ -1826,7 +2031,8 @@ class lists_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column * */ - void build_from_nested(std::initializer_list> elements, + template + void build_from_nested(ListsRange const& elements, std::vector const& v, rmm::cuda_stream_view stream, cudf::memory_resources mr) @@ -1986,8 +2192,9 @@ class lists_column_wrapper : public detail::column_wrapper { cudf::copy_bitmask(col, stream, temp_mr)); } + template std::pair, std::vector>> preprocess_columns( - std::initializer_list> const& elements, + ListsRange const& elements, column_view& expected_hierarchy, int expected_depth, rmm::cuda_stream_view stream, diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index a07747a9403c..2e9ff3fdfed6 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,7 +17,7 @@ #include template -class GatherTestListTyped : public cudf::test::BaseFixture {}; +class GatherTestListTyped : public cudf::test::BaseFixtureWithHarness {}; using FixedWidthTypesNotBool = cudf::test::Concat; TYPED_TEST_SUITE(GatherTestListTyped, FixedWidthTypesNotBool); -class GatherTestList : public cudf::test::BaseFixture {}; +class GatherTestList : public cudf::test::BaseFixtureWithHarness {}; // to disambiguate between {} == 0 and {} == List{0} // Also, see note about compiler issues when declaring nested @@ -33,46 +33,62 @@ class GatherTestList : public cudf::test::BaseFixture {}; template using LCW = cudf::test::lists_column_wrapper; +// Nested list values. Passing these to lists_column_wrapper builds every nesting level with the +// explicit stream and memory resources instead of the current device resource. +using Init = cudf::test::lists_column_initializer; + TYPED_TEST(GatherTestListTyped, Gather) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List - LCW list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; - cudf::test::fixed_width_column_wrapper gather_map{0, 2}; + LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{1, 2, 3, 4}, {6, 7}}; + LCW expected{Init{{1, 2, 3, 4}, {6, 7}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TYPED_TEST(GatherTestListTyped, GatherNothing) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List { - LCW list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; cudf::test::fixed_width_column_wrapper gather_map{}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List { - cudf::test::lists_column_wrapper list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + cudf::test::lists_column_wrapper list{ + Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; cudf::test::fixed_width_column_wrapper gather_map{}; cudf::table_view source_table({list}); - auto result = cudf::gather(source_table, gather_map); + auto result = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -94,58 +110,77 @@ TYPED_TEST(GatherTestListTyped, GatherNulls) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - LCW list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; - cudf::test::fixed_width_column_wrapper gather_map{0, 2}; + LCW list{Init{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, st, mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}; + LCW expected{Init{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TYPED_TEST(GatherTestListTyped, GatherNested) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { - LCW list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - cudf::test::fixed_width_column_wrapper gather_map{0, 2}; + LCW list{Init{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + st, + mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + LCW expected{ + Init{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List>> { - LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{LCW{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}}; - cudf::test::fixed_width_column_wrapper gather_map{1, 2, 4}; + LCW list{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, + st, + mr}; + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{LCW{0}}}, - {{{10, 20}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}}; + LCW expected{Init{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, + st, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -153,21 +188,30 @@ TYPED_TEST(GatherTestListTyped, GatherOutOfOrder) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { - LCW list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - cudf::test::fixed_width_column_wrapper gather_map{1, 2, 0}; + LCW list{Init{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + st, + mr}; + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{2, 3}, {4, 5}}}; + LCW expected{Init{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{2, 3}, {4, 5}}}, + st, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -175,48 +219,64 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List> { - LCW list{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; + LCW list{ + Init{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, + st, + mr}; - cudf::test::fixed_width_column_wrapper gather_map{0, 1, 3}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ - {{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + Init{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, + st, + mr}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List>> { - LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{LCW{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; - - cudf::test::fixed_width_column_wrapper gather_map{1, 2, 4}; + LCW list{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + st, + mr}; + + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{LCW{0}}}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + LCW expected{Init{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + st, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -224,55 +284,70 @@ TYPED_TEST(GatherTestListTyped, GatherNestedWithEmpties) { using T = TypeParam; - LCW list{{{2, 3}, LCW{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {LCW{}}}; - cudf::test::fixed_width_column_wrapper gather_map{0, 2}; + auto const st = this->stream(); + auto const mr = this->resources(); + + LCW list{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{{{2, 3}, LCW{}}, {LCW{}}}; + LCW expected{Init{{{2, 3}, Init{}}, {Init{}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { - LCW list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - cudf::test::fixed_width_column_wrapper gather_map{0, 15, 16, 2}; + LCW list{Init{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + st, + mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY); + auto results = + cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, st, mr.get_output_mr()); std::vector expected_validity{1, 0, 0, 1}; - LCW expected{{{{2, 3}, {4, 5}}, - {LCW{}}, - {LCW{}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - expected_validity.begin()}; - - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), expected); + LCW expected{ + Init{ + {{{2, 3}, {4, 5}}, {Init{}}, {Init{}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + expected_validity.begin()}, + st, + mr}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } TEST_F(GatherTestList, GatherIncompleteHierarchies) { - using LCW = cudf::test::lists_column_wrapper; + auto const st = this->stream(); + auto const mr = this->resources(); { // List, but rows 1 and 2 are empty at the very top. // We expect to get back a "full" hierarchy of type List> anyway. - cudf::test::lists_column_wrapper list{{{{1, 2}}}, LCW{}, LCW{}}; + cudf::test::lists_column_wrapper list{Init{{{{1, 2}}}, Init{}, Init{}}, st, mr}; cudf::table_view source_table({list}); - cudf::test::fixed_width_column_wrapper row1_map{1}; - auto result = cudf::gather(source_table, row1_map); + cudf::test::fixed_width_column_wrapper row1_map{{1}, st, mr}; + auto result = + cudf::gather(source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -292,12 +367,13 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) { // List, gathering nothing. // We expect to get back a "full" hierarchy of type List> anyway. - cudf::test::lists_column_wrapper list{{{{1, 2}}}, LCW{}}; + cudf::test::lists_column_wrapper list{Init{{{{1, 2}}}, Init{}}, st, mr}; cudf::table_view source_table({list}); cudf::test::fixed_width_column_wrapper empty_map{}; - auto result = cudf::gather(source_table, empty_map); + auto result = + cudf::gather(source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -318,34 +394,54 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) TYPED_TEST(GatherTestListTyped, GatherSliced) { using T = TypeParam; + + auto const st = this->stream(); + auto const mr = this->resources(); + { - LCW a{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }; - auto split_a = cudf::split(a, {3}); + LCW a{Init{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }, + st, + mr}; + auto split_a = cudf::split(a, {3}, st); cudf::table_view tbl0({split_a[0]}); cudf::table_view tbl1({split_a[1]}); - auto result0 = cudf::gather(tbl0, cudf::test::fixed_width_column_wrapper{1, 2}); - LCW expected0{ - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected0, result0->get_column(0).view()); - - auto result1 = cudf::gather(tbl1, cudf::test::fixed_width_column_wrapper{0, 3}); - LCW expected1{ - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{50, 50, 50, 50}, {6, 13}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, result1->get_column(0).view()); + cudf::test::fixed_width_column_wrapper map0{{1, 2}, st, mr}; + auto result0 = cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + LCW expected0{Init{ + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + }, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected0, + result0->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + st, + mr); + + cudf::test::fixed_width_column_wrapper map1{{0, 3}, st, mr}; + auto result1 = cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + LCW expected1{Init{ + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{50, 50, 50, 50}, {6, 13}}, + }, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, + result1->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + st, + mr); } auto valids = cudf::test::iterators::valids_at_multiples_of(2); @@ -353,70 +449,93 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) // List>> { LCW list{ - // slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init{// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{LCW{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {LCW{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; + // slice 2 + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, + st, + mr}; - auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}); + auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}, st); // gather from slice 0 { cudf::table_view tbl({sliced[0]}); - cudf::test::fixed_width_column_wrapper map{0}; - auto result = cudf::gather(tbl, map); - LCW expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view()); + cudf::test::fixed_width_column_wrapper map{{0}, st, mr}; + auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } // gather from slice 1 { cudf::table_view tbl({sliced[1]}); - cudf::test::fixed_width_column_wrapper map{1, 2, 0, 1}; - auto result = cudf::gather(tbl, map); + cudf::test::fixed_width_column_wrapper map{{1, 2, 0, 1}, st, mr}; + auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - - {{LCW{0}}}, - - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view()); + Init{ + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + + {{Init{0}}}, + + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + }, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } // gather from slice 2 { cudf::table_view tbl({sliced[2]}); - cudf::test::fixed_width_column_wrapper map{1, 0, 0, 1, 1, 0}; - auto result = cudf::gather(tbl, map); - LCW expected{{{{{10, 20, 30}}, {LCW{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {LCW{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{10, 20, 30}}, {LCW{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view()); + cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, st, mr}; + auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + LCW expected{ + Init{{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } } } diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 1827275b328e..a3e2bcac2825 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -1,7 +1,15 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ + +// Nested `LCW{LCW...` constructions (including empty-list columns with explicit stream/mr) +// trip gcc14's -Wmaybe-uninitialized on column_view_base's copy constructor. Same diagnostic +// as lists/extract_tests.cpp; ignore for the whole file because the warning fires in headers. +#if defined(__GNUC__) && (__GNUC__ >= 14) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #include #include #include @@ -17,7 +25,7 @@ #include template -class SegmentedGatherTest : public cudf::test::BaseFixture {}; +class SegmentedGatherTest : public cudf::test::BaseFixtureWithHarness {}; using FixedWidthTypesNotBool = cudf::test::Concat; using namespace cudf::test::iterators; auto constexpr NULLIFY = cudf::out_of_bounds_policy::NULLIFY; +// Nested list values. Passing these to lists_column_wrapper builds every nesting level with the +// explicit stream and memory resources instead of the current device resource. +using Init = cudf::test::lists_column_initializer; +using I8Init = cudf::test::lists_column_initializer; +using StrInit = cudf::test::lists_column_initializer; + TYPED_TEST(SegmentedGatherTest, Gather) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List - LCW list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; { // Straight-line case. - auto const gather_map = LCW{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}; - auto const expected = LCW{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}; + auto const gather_map = LCW{Init{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}, st, mr}; + auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } { // Nullify out-of-bounds values. - auto const gather_map = LCW{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}; - auto const expected = LCW{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}; - auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + auto const gather_map = LCW{Init{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}, st, mr}; + auto const expected = + LCW{Init{{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}}, st, mr}; + auto const results = cudf::lists::segmented_gather( + cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -62,37 +83,48 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List { - auto const list = LCW{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; - auto const gather_map = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; + auto const list = LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + auto const gather_map = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); - auto const expected = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List> { - auto const list = LCW{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {{}, {8, 9, 10}}}; - auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; + auto const list = LCW{Init{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}, st, mr}; + auto const gather_map = LCW{{LCW{}, LCW{}, LCW{}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // hack to get column of empty list of list - auto const expected_dummy = LCW{{{1, 2, 3, 4}, {5}}, LCW{}, LCW{}, LCW{}}; - auto const expected = cudf::split(expected_dummy, {1})[1]; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + auto const expected_dummy = + LCW{{LCW{Init{{{1, 2, 3, 4}, {5}}}, st, mr}, LCW{}, LCW{}, LCW{}}, st, mr}; + auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List>> { - auto const list = LCW{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; - auto const gather_map = LCW{LCW{}, LCW{}}; + auto const list = LCW{Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; + auto const gather_map = LCW{{LCW{}, LCW{}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // hack to get column of empty list of list of list - auto const expected_dummy = LCW{{{{1, 2, 3, 4}}}, LCW{}, LCW{}}; - auto const expected = cudf::split(expected_dummy, {1})[1]; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + auto const expected_dummy = + LCW{{LCW{Init{{{{1, 2, 3, 4}}}}, st, mr}, LCW{}, LCW{}}, st, mr}; + auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -113,40 +145,54 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) using SegmentedGatherTestSingle = SegmentedGatherTest; TEST_F(SegmentedGatherTestSingle, GatherEmpty) { + auto const st = this->stream(); + auto const mr = this->resources(); + auto const list = LCW{}; auto const gather_map = LCW{}; auto const expected = LCW{}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TYPED_TEST(SegmentedGatherTest, GatherNulls) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - auto const list = LCW{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; + auto const list = + LCW{Init{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, st, mr}; { // Test gathering on lists that contain nulls. - auto const gather_map = LCW{{0, 1}, LCW{}, {1}, {2, 1, 0}}; + auto const gather_map = LCW{Init{{0, 1}, Init{}, {1}, {2, 1, 0}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); auto const expected = - LCW{{{1, 2}, valids}, LCW{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + LCW{Init{{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } { // Test gathering on lists that contain nulls, with out-of-bounds indices. - auto const gather_map = LCW{{10, -10}, LCW{}, {1}, {2, -10, 0}}; + auto const gather_map = LCW{Init{{10, -10}, Init{}, {1}, {2, -10, 0}}, st, mr}; auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - auto const expected = - LCW{{{0, 0}, nulls_at({0, 1})}, LCW{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const expected = LCW{ + Init{{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}}, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -154,78 +200,85 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - auto const gather_map = LCW{{0, -2, -2}, {1}, {1, 0, -1, -5}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{2, 3}, {2, 3}, {2, 3}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, st, mr}; + auto const gather_map = LCW{Init{{0, -2, -2}, {1}, {1, 0, -1, -5}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{2, 3}, {2, 3}, {2, 3}}, {{9, 10, 11}}, - {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - auto const gather_map = LCW{{0, 2, -2}, {1}, {1, 0, -1, -6}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, st, mr}; + auto const gather_map = LCW{Init{{0, 2, -2}, {1}, {1, 0, -1, -6}}, st, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - auto const expected = LCW{{{{2, 3}, LCW{}, {2, 3}}, null_at(1)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, {{9, 10, 11}}, - {{{17, 18}, {15, 16}, {-17, -18}, LCW{}}, null_at(3)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>> { // clang-format off - auto const list = LCW{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + auto const list = LCW{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{LCW{0}}}, + {{Init{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}}; - auto const gather_map = LCW{{1}, LCW{}, {0}, {1}, {0, -1, 1}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - LCW{}, - {{LCW{0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, st, mr}; + auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 1}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init{}, + {{Init{0}}}, {{{0, 1, 3}, {5}}}, - {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {LCW{30}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>>, with out-of-bounds gather indices. { - auto const list = LCW{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{LCW{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}}; - auto const gather_map = LCW{{1}, LCW{}, {0}, {1}, {0, -1, 3, -4}}; + auto const list = LCW{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, + st, + mr}; + auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 3, -4}}, st, mr}; auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); + cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); auto const expected = - LCW{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - LCW{}, - {{LCW{0}}}, - {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, LCW{}, LCW{}}, nulls_at({2, 3})}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); - // clang-format on + LCW{Init{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init{}, + {{Init{0}}}, + {{{0, 1, 3}, {5}}}, + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}}, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -233,33 +286,36 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - auto const gather_map = LCW{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{4, 5}, {2, 3}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; + auto const gather_map = LCW{Init{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - auto const gather_map = LCW{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - auto const expected = LCW{{{4, 5}, {2, 3}}, - {{LCW{}, {12, 13, 14}, LCW{}}, nulls_at({0, 2})}, - {{LCW{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; + auto const gather_map = LCW{Init{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{4, 5}, {2, 3}}, + {{Init{}, {12, 13, 14}, Init{}}, nulls_at({0, 2})}, + {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } } @@ -268,33 +324,36 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + // List> { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - auto const gather_map = LCW{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{4, 5}, {2, 3}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; + auto const gather_map = LCW{Init{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{{{2, 3}, {4, 5}}, + auto const list = LCW{Init{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - auto const gather_map = LCW{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; + auto const gather_map = LCW{Init{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}, st, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - auto const expected = LCW{{{4, 5}, {2, 3}}, - {{{9, 10, 11}, {12, 13, 14}, LCW{}}, null_at(2)}, - {{LCW{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{4, 5}, {2, 3}}, + {{{9, 10, 11}, {12, 13, 14}, Init{}}, null_at(2)}, + {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } } @@ -303,41 +362,44 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) { using T = TypeParam; + auto const st = this->stream(); + auto const mr = this->resources(); + auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List> { // clang-format off - auto const list = LCW{{{{2, 3}, valids}, {4, 5}}, + auto const list = LCW{Init{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - auto const gather_map = LCW{{0, 1}, {0, 2}, LCW{}, {0, 1, 4}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{{2, 3}, valids}, {4, 5}}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, st, mr}; + auto const gather_map = LCW{Init{{0, 1}, {0, 2}, Init{}, {0, 1, 4}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {12, 13, 14}}, no_nulls()}, - LCW{}, - {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + Init{}, + {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } // List>>> { // clang-format off - auto const list = LCW{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + auto const list = LCW{Init{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{LCW{0}}}, + {{Init{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; - auto const gather_map = LCW{{1, 2, 4}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}); - auto const expected = LCW{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{LCW{0}}}, - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, st, mr}; + auto const gather_map = LCW{Init{{1, 2, 4}}, st, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } } @@ -346,52 +408,72 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) { using T = TypeParam; - auto const list = LCW{{{2, 3}, LCW{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {LCW{}}}; - auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; + auto const st = this->stream(); + auto const mr = this->resources(); + + auto const list = + LCW{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; + auto const gather_map = LCW{Init{{0}, {0}, {0}}, st, mr}; auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); auto const expected = - LCW{{{2, 3}}, {{6, 7, 8}}, {LCW{}}}; // skip one null, gather one null. - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + LCW{Init{{{2, 3}}, {{6, 7, 8}}, {Init{}}}, st, mr}; // skip one null, gather one null. + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TYPED_TEST(SegmentedGatherTest, GatherSliced) { using T = TypeParam; + + auto const st = this->stream(); + auto const mr = this->resources(); + { - auto const a = LCW{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }; - auto const split_a = cudf::split(a, {3}); + auto const a = LCW{Init{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }, + st, + mr}; + auto const split_a = cudf::split(a, {3}, st); { - auto const list = LCW{{1, 2}, {0, 2}, {0, 1}}; + auto const list = LCW{Init{{1, 2}, {0, 2}, {0, 1}}, st, mr}; auto const gather_map = cudf::lists_column_view{list}; - auto const result = - cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, gather_map); - auto const expected = LCW{ - {{2, 2}, {3, 3}}, - {{4, 4, 4}, {6, 6}}, - {{7, 7, 7}, {8, 8}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); + auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, + gather_map, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto const expected = LCW{Init{ + {{2, 2}, {3, 3}}, + {{4, 4, 4}, {6, 6}}, + {{7, 7, 7}, {8, 8}}, + }, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } { - auto const list = LCW{{0, 1}, LCW{}, LCW{}, {0, 1}, LCW{}}; + auto const list = LCW{Init{{0, 1}, Init{}, Init{}, {0, 1}, Init{}}, st, mr}; auto const gather_map = cudf::lists_column_view{list}; - auto const result = - cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, gather_map); + auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, + gather_map, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); auto const expected = - LCW{{{10, 10, 10}, {11, 11}}, LCW{}, LCW{}, {{50, 50, 50, 50}, {6, 13}}, LCW{}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); + LCW{Init{{{10, 10, 10}, {11, 11}}, Init{}, Init{}, {{50, 50, 50, 50}, {6, 13}}, Init{}}, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -400,74 +482,99 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // List>> { LCW list{ - // slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init{// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{LCW{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {LCW{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {LCW{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; + // slice 2 + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, + st, + mr}; - auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}); + auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}, st); // gather from slice 0 { - LCW map{{0, 1}}; + LCW map{Init{{0, 1}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, - cudf::lists_column_view{map}); - LCW expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view()); + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } // gather from slice 1 { - LCW map{{0}, {1, 2, 0, 1}, {0, 1, 2}}; + LCW map{Init{{0}, {1, 2, 0, 1}, {0, 1, 2}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, - cudf::lists_column_view{map}); + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ - {{LCW{0}}}, - - {{{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}, - {{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view()); + Init{ + {{Init{0}}}, + + {{{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}, + {{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + }, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } // gather from slice 2 { - LCW map{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}; + LCW map{Init{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, - cudf::lists_column_view{map}); + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); std::vector expected_valids = {false, true, true, false, false, true}; - LCW expected{{{{LCW{30}}, - {{{10, 20}, valids}}, - {{{10, 20}, valids}}, - {LCW{30}}, - {LCW{30}}, - {{{10, 20}, valids}}}, - expected_valids.begin()}, - {{{LCW{30}}, - {{10, 20, 30}}, - {{10, 20, 30}}, - {LCW{30}}, - {LCW{30}}, - {{{20, 30}, valids}, {62, 72, 82}}}, - expected_valids.begin()}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view()); + LCW expected{Init{{{{Init{30}}, + {{{10, 20}, valids}}, + {{{10, 20}, valids}}, + {Init{30}}, + {Init{30}}, + {{{10, 20}, valids}}}, + expected_valids.begin()}, + {{{Init{30}}, + {{10, 20, 30}}, + {{10, 20, 30}}, + {Init{30}}, + {Init{30}}, + {{{20, 30}, valids}, {62, 72, 82}}}, + expected_valids.begin()}}, + st, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } } } @@ -476,26 +583,41 @@ using SegmentedGatherTestString = SegmentedGatherTest; TEST_F(SegmentedGatherTestString, StringGather) { using T = cudf::string_view; + + auto const st = this->stream(); + auto const mr = this->resources(); + // List { - auto const list = LCW{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; - auto const gather_map = LCW{{0, 1, 3, 2}, {1, 0, 3, 2}, LCW{}}; - auto const expected = LCW{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, LCW{}}; - auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); + auto const list = + LCW{StrInit{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, st, mr}; + auto const gather_map = cudf::test::lists_column_wrapper{ + I8Init{{0, 1, 3, 2}, {1, 0, 3, 2}, I8Init{}}, st, mr}; + auto const expected = + LCW{StrInit{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, StrInit{}}, st, mr}; + auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List, with out-of-order gather indices. { - auto const list = LCW{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; - auto const gather_map = LCW{{0, 1, 3, 4}, {1, -5, 3, 2}, LCW{}}; - auto const expected = LCW{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, - {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, - LCW{}}; - auto result = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); + auto const list = + LCW{StrInit{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, st, mr}; + auto const gather_map = cudf::test::lists_column_wrapper{ + I8Init{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}, st, mr}; + auto const expected = + LCW{StrInit{{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, + {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, + StrInit{}}}, + st, + mr}; + auto result = cudf::lists::segmented_gather( + cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } } @@ -504,92 +626,150 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) { using T = float; + auto const st = this->stream(); + auto const mr = this->resources(); + // List { - auto const list = LCW{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - auto const gather_map = LCW{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}; + auto const list = + LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, st, mr}; + auto const gather_map = LCW{Init{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}, st, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - auto const expected = LCW{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}; + auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); - auto const sliced = cudf::split(list, {1, 4}); - auto const split_m = cudf::split(gather_map, {1, 4}); - auto const split_e = cudf::split(expected, {1, 4}); + auto const sliced = cudf::split(list, {1, 4}, st); + auto const split_m = cudf::split(gather_map, {1, 4}, st); + auto const split_e = cudf::split(expected, {1, 4}, st); auto result0 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, - cudf::lists_column_view{split_m[0]}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view()); + cudf::lists_column_view{split_m[0]}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], + result0->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); auto result1 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, - cudf::lists_column_view{split_m[1]}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view()); + cudf::lists_column_view{split_m[1]}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], + result1->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); auto result2 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, - cudf::lists_column_view{split_m[2]}); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view()); + cudf::lists_column_view{split_m[2]}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], + result2->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } // List, with out-of-bounds gather indices. { - auto const list = LCW{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - auto const gather_map = LCW{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}; + auto const list = + LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, st, mr}; + auto const gather_map = LCW{Init{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}, st, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 auto const expected = - LCW{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}; + LCW{Init{{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}}, + st, + mr}; auto results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); - auto const sliced = cudf::split(list, {1, 4}); - auto const split_m = cudf::split(gather_map, {1, 4}); - auto const split_e = cudf::split(expected, {1, 4}); + auto const sliced = cudf::split(list, {1, 4}, st); + auto const split_m = cudf::split(gather_map, {1, 4}, st); + auto const split_e = cudf::split(expected, {1, 4}, st); auto const result0 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view()); + cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], + result0->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); auto const result1 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view()); + cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], + result1->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); auto const result2 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, NULLIFY); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view()); + cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, NULLIFY, st, mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], + result2->view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + st, + mr); } } TEST_F(SegmentedGatherTestFloat, Fails) { using T = float; + + auto const st = this->stream(); + auto const mr = this->resources(); + // List - LCW list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; - LCW size_mismatch_map{{3, 2, 1, 0}, {0}, {0, 1}}; - cudf::test::fixed_width_column_wrapper nonlist_map0{1, 2, 0, 1}; - cudf::test::strings_column_wrapper nonlist_map1{"1", "2", "0", "1"}; - LCW nonlist_map2{{"1", "2", "0", "1"}}; + LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + cudf::test::lists_column_wrapper size_mismatch_map{ + I8Init{{3, 2, 1, 0}, {0}, {0, 1}}, st, mr}; + cudf::test::fixed_width_column_wrapper nonlist_map0{{1, 2, 0, 1}, st, mr}; + cudf::test::strings_column_wrapper nonlist_map1{{"1", "2", "0", "1"}, st, mr}; + LCW nonlist_map2{StrInit{{"1", "2", "0", "1"}}, st, mr}; // Input must be a list of integer indices. It should fail for integers, // strings, or lists containing anything other than integers. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nonlist_map0}), + cudf::lists_column_view{nonlist_map0}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), cudf::logic_error); EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nonlist_map1}), + cudf::lists_column_view{nonlist_map1}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), cudf::logic_error); EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nonlist_map2}), + cudf::lists_column_view{nonlist_map2}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), cudf::logic_error); auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW nulls_map{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}; + cudf::test::lists_column_wrapper nulls_map{ + I8Init{{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}}, st, mr}; // Nulls are not supported in the gather map. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nulls_map}), + cudf::lists_column_view{nulls_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), std::invalid_argument); // Gather map and list column sizes must be the same. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{size_mismatch_map}), + cudf::lists_column_view{size_mismatch_map}, + cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), cudf::logic_error); } + +#if defined(__GNUC__) && (__GNUC__ >= 14) +#pragma GCC diagnostic pop +#endif diff --git a/cpp/tests/utilities/memory_resource_utilities.cpp b/cpp/tests/utilities/memory_resource_utilities.cpp index 06e57bb027a4..0baafeb9a5be 100644 --- a/cpp/tests/utilities/memory_resource_utilities.cpp +++ b/cpp/tests/utilities/memory_resource_utilities.cpp @@ -11,7 +11,11 @@ #include +#include +#include + #include +#include #include namespace cudf::test { @@ -27,11 +31,27 @@ scoped_current_device_resource::~scoped_current_device_resource() std::ignore = cudf::set_current_device_resource(std::move(_previous)); } +namespace { + +void print_allocation_stacktrace() +{ + constexpr int max_frames = 64; + void* frames[max_frames]; + int const nframes = ::backtrace(frames, max_frames); + std::cerr << "Unexpected allocation from the current device resource. Callstack (" << nframes + << " frames):\n"; + if (nframes > 0) { ::backtrace_symbols_fd(frames, nframes, STDERR_FILENO); } + std::cerr.flush(); +} + +} // namespace + memory_resource_test_harness::memory_resource_test_harness(rmm::device_async_resource_ref upstream) : _setup_mr{upstream}, _output_mr{upstream}, _temporary_mr{upstream}, _failing_mr{[](std::size_t, cuda::stream_ref, void*) -> void* { + print_allocation_stacktrace(); throw rmm::bad_alloc{"Unexpected allocation from the current device resource"}; }, [](void*, std::size_t, cuda::stream_ref, void*) {}} diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index ae83a6104ac0..50531b2b6448 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1549,3 +1549,71 @@ TYPED_TEST(ListColumnWrapperTestTyped, LargeListsOfStructsWithValidity) CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected_struct_column, cudf::lists_column_view(*lists_column).child()); } + +// Harness-scoped construction via lists_column_initializer. +// Multi-row nested Init still routes through cudf::concatenate temporaries on the current +// resource; keep fail_on_current scopes on leaf / single-child paths until concatenate is ported. +struct ListsColumnInitializerHarnessTest : public cudf::test::BaseFixtureWithHarness {}; + +TEST_F(ListsColumnInitializerHarnessTest, LeafInitUsesExplicitResources) +{ + using Init = cudf::test::lists_column_initializer; + using LCW = cudf::test::lists_column_wrapper; + + auto const st = this->stream(); + auto const mr = this->resources(); + + std::unique_ptr built; + { + auto fail_on_current = this->fail_on_current_device_resource_use(); + LCW list{Init{{1, 2, 3, 4}}, st, mr}; + this->_harness.synchronize(st); + built = list.release(); + } + + LCW expected{Init{{1, 2, 3, 4}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); +} + +TEST_F(ListsColumnInitializerHarnessTest, LeafNullableInitUsesExplicitResources) +{ + using Init = cudf::test::lists_column_initializer; + using LCW = cudf::test::lists_column_wrapper; + using cudf::test::iterators::null_at; + + auto const st = this->stream(); + auto const mr = this->resources(); + + std::unique_ptr built; + { + auto fail_on_current = this->fail_on_current_device_resource_use(); + LCW list{Init{{{1, 2, 3, 4}, null_at(1)}}, st, mr}; + this->_harness.synchronize(st); + built = list.release(); + } + + LCW expected{Init{{{1, 2, 3, 4}, null_at(1)}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); +} + +TEST_F(ListsColumnInitializerHarnessTest, SingleChildNestedInitUsesExplicitResources) +{ + using Init = cudf::test::lists_column_initializer; + using LCW = cudf::test::lists_column_wrapper; + + auto const st = this->stream(); + auto const mr = this->resources(); + + // One outer row whose only child is a leaf list: both levels avoid concatenate. + std::unique_ptr built; + { + auto fail_on_current = this->fail_on_current_device_resource_use(); + LCW list{Init{{{{1, 2, 3}}}}, st, mr}; + this->_harness.synchronize(st); + built = list.release(); + } + + LCW expected{Init{{{{1, 2, 3}}}}, st, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); +} From 9da3e46fd4e505ea590307d1f0f656ada8a73641 Mon Sep 17 00:00:00 2001 From: Niranda Perera Date: Fri, 14 Aug 2026 17:19:54 -0700 Subject: [PATCH 02/21] Fix Init nesting in segmented gather list test ports Correct over-nested lists_column_initializer constructions and restore base empty-row brace patterns so list/segmented gather harness tests pass. --- .../copying/segmented_gather_list_tests.cpp | 52 +++++++++---------- .../lists_column_wrapper_tests.cpp | 4 +- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index a3e2bcac2825..cf041519fe0a 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -71,7 +71,7 @@ TYPED_TEST(SegmentedGatherTest, Gather) // Nullify out-of-bounds values. auto const gather_map = LCW{Init{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}, st, mr}; auto const expected = - LCW{Init{{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}}, st, mr}; + LCW{Init{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}, st, mr}; auto const results = cudf::lists::segmented_gather( cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -99,30 +99,29 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) } // List> { - auto const list = LCW{Init{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}, st, mr}; - auto const gather_map = LCW{{LCW{}, LCW{}, LCW{}}, st, mr}; + // Keep base brace nesting for empty-row hierarchy (Init empty encoding differs). + auto const list = LCW{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {LCW{}, {8, 9, 10}}}; + auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // hack to get column of empty list of list - auto const expected_dummy = - LCW{{LCW{Init{{{1, 2, 3, 4}, {5}}}, st, mr}, LCW{}, LCW{}, LCW{}}, st, mr}; - auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + auto const expected_dummy = LCW{{{1, 2, 3, 4}, {5}}, LCW{}, LCW{}, LCW{}}; + auto const expected = cudf::split(expected_dummy, {1}, st)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List>> { - auto const list = LCW{Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; - auto const gather_map = LCW{{LCW{}, LCW{}}, st, mr}; + auto const list = LCW{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + auto const gather_map = LCW{LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // hack to get column of empty list of list of list - auto const expected_dummy = - LCW{{LCW{Init{{{{1, 2, 3, 4}}}}, st, mr}, LCW{}, LCW{}}, st, mr}; - auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + auto const expected_dummy = LCW{{{{1, 2, 3, 4}}}, LCW{}, LCW{}}; + auto const expected = cudf::split(expected_dummy, {1}, st)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); @@ -178,7 +177,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); auto const expected = - LCW{Init{{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}}, st, mr}; + LCW{Init{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -188,7 +187,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) auto const results = cudf::lists::segmented_gather( cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); auto const expected = LCW{ - Init{{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}}, + Init{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -227,9 +226,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) auto const gather_map = LCW{Init{{0, 2, -2}, {1}, {1, 0, -1, -6}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, + auto const expected = LCW{Init{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, {{9, 10, 11}}, - {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}}, st, mr}; + {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } @@ -246,11 +245,11 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, st, mr}; auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 1}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + auto const expected = LCW{Init{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, Init{}, {{Init{0}}}, {{{0, 1, 3}, {5}}}, - {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}}, st, mr}; + {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); // clang-format on } @@ -270,11 +269,11 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) auto const results = cudf::lists::segmented_gather( cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); auto const expected = - LCW{Init{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + LCW{Init{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, Init{}, {{Init{0}}}, {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}}, + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -411,14 +410,13 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const st = this->stream(); auto const mr = this->resources(); - auto const list = - LCW{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; - auto const gather_map = LCW{Init{{0}, {0}, {0}}, st, mr}; + auto const list = LCW{{{2, 3}, LCW{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {LCW{}}}; + auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); auto const expected = - LCW{Init{{{2, 3}}, {{6, 7, 8}}, {Init{}}}, st, mr}; // skip one null, gather one null. + LCW{{{2, 3}}, {{6, 7, 8}}, {LCW{}}}; // skip one null, gather one null. CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -609,9 +607,9 @@ TEST_F(SegmentedGatherTestString, StringGather) auto const gather_map = cudf::test::lists_column_wrapper{ I8Init{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}, st, mr}; auto const expected = - LCW{StrInit{{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, + LCW{StrInit{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, - StrInit{}}}, + StrInit{}}, st, mr}; auto result = cudf::lists::segmented_gather( @@ -682,7 +680,7 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) auto const gather_map = LCW{Init{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}, st, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 auto const expected = - LCW{Init{{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}}, + LCW{Init{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}, st, mr}; auto results = cudf::lists::segmented_gather( @@ -755,7 +753,7 @@ TEST_F(SegmentedGatherTestFloat, Fails) auto valids = cudf::test::iterators::valids_at_multiples_of(2); cudf::test::lists_column_wrapper nulls_map{ - I8Init{{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}}, st, mr}; + I8Init{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}, st, mr}; // Nulls are not supported in the gather map. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index 50531b2b6448..efde223fcc68 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1587,12 +1587,12 @@ TEST_F(ListsColumnInitializerHarnessTest, LeafNullableInitUsesExplicitResources) std::unique_ptr built; { auto fail_on_current = this->fail_on_current_device_resource_use(); - LCW list{Init{{{1, 2, 3, 4}, null_at(1)}}, st, mr}; + LCW list{Init{{1, 2, 3, 4}, null_at(1)}, st, mr}; this->_harness.synchronize(st); built = list.release(); } - LCW expected{Init{{{1, 2, 3, 4}, null_at(1)}}, st, mr}; + LCW expected{Init{{1, 2, 3, 4}, null_at(1)}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } From e607cb19912c50bf176dbcb89f09e1def3c26c35 Mon Sep 17 00:00:00 2001 From: Niranda Perera Date: Mon, 17 Aug 2026 14:28:15 -0700 Subject: [PATCH 03/21] reorder ctrs --- cpp/include/cudf_test/column_wrapper.hpp | 88 ++++++++++++------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 8ac30e57b0f0..c9889822665c 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -1693,30 +1693,6 @@ class lists_column_wrapper : public detail::column_wrapper { fixed_width_column_wrapper(elements, stream, mr).release(), stream, mr); } - /** - * @brief Construct a lists column containing a single list of strings. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total strings - * // [{"abc", "def"}] - * lists_column_wrapper s{"abc", "def"}; - * @endcode - * - * @param elements The list of strings - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v) - : column_wrapper{} - { - build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); - } - /** * @brief Construct a lists column containing a single list from an iterator range. * @@ -1773,60 +1749,84 @@ class lists_column_wrapper : public detail::column_wrapper { } /** - * @brief Construct a lists column containing a single list of strings and a - * validity iterator. + * @brief Construct a lists column containing a single list from an iterator + * range and a validity iterator. * * Example: * @code{.cpp} + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{"abc", NULL}] - * lists_column_wrapper l{{"abc", "def"}, validity}; + * // [{0, NULL, 2, NULL, 4}] + * lists_column_wrapper l(elements, elements+5, validity); * @endcode * - * @param elements The list of strings + * @param begin Beginning of the sequence + * @param end End of the sequence * @param v The validity iterator * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(InputIterator begin, + InputIterator end, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list of strings. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total strings + * // [{"abc", "def"}] + * lists_column_wrapper s{"abc", "def"}; + * @endcode + * + * @param elements The list of strings + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) requires(std::is_same_v) : column_wrapper{} { - build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); + build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); } /** - * @brief Construct a lists column containing a single list from an iterator - * range and a validity iterator. + * @brief Construct a lists column containing a single list of strings and a + * validity iterator. * * Example: * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL, 2, NULL, 4}] - * lists_column_wrapper l(elements, elements+5, validity); + * // [{"abc", NULL}] + * lists_column_wrapper l{{"abc", "def"}, validity}; * @endcode * - * @param begin Beginning of the sequence - * @param end End of the sequence + * @param elements The list of strings * @param v The validity iterator * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(InputIterator begin, - InputIterator end, + template + lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v) : column_wrapper{} { - build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); + build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); } /** From 8402bb66bd26507113cf3d4c176871f185a563a0 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 18 Aug 2026 11:22:25 -0700 Subject: [PATCH 04/21] precommit Signed-off-by: niranda perera --- cpp/tests/copying/gather_list_tests.cpp | 67 +++---- .../copying/segmented_gather_list_tests.cpp | 170 ++++++++++++------ .../lists_column_wrapper_tests.cpp | 8 +- 3 files changed, 159 insertions(+), 86 deletions(-) diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 2e9ff3fdfed6..2f8ad7db254b 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -49,8 +49,8 @@ TYPED_TEST(GatherTestListTyped, Gather) cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{1, 2, 3, 4}, {6, 7}}, st, mr}; @@ -71,8 +71,8 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) cudf::test::fixed_width_column_wrapper gather_map{}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected; @@ -87,8 +87,8 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) cudf::test::fixed_width_column_wrapper gather_map{}; cudf::table_view source_table({list}); - auto result = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -120,8 +120,8 @@ TYPED_TEST(GatherTestListTyped, GatherNulls) cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}, st, mr}; @@ -146,8 +146,8 @@ TYPED_TEST(GatherTestListTyped, GatherNested) cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ Init{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; @@ -170,8 +170,8 @@ TYPED_TEST(GatherTestListTyped, GatherNested) cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, {{Init{0}}}, @@ -201,8 +201,8 @@ TYPED_TEST(GatherTestListTyped, GatherOutOfOrder) cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, @@ -237,8 +237,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ Init{{{{2, 3}, valids}, {4, 5}}, @@ -266,8 +266,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, {{Init{0}}}, @@ -291,8 +291,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedWithEmpties) cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{2, 3}, Init{}}, {Init{}}}, st, mr}; @@ -317,8 +317,8 @@ TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, st, mr}; cudf::table_view source_table({list}); - auto results = - cudf::gather(source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, st, mr.get_output_mr()); + auto results = cudf::gather( + source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, st, mr.get_output_mr()); std::vector expected_validity{1, 0, 0, 1}; LCW expected{ @@ -346,8 +346,8 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) cudf::table_view source_table({list}); cudf::test::fixed_width_column_wrapper row1_map{{1}, st, mr}; - auto result = - cudf::gather(source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = cudf::gather( + source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -372,8 +372,8 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) cudf::table_view source_table({list}); cudf::test::fixed_width_column_wrapper empty_map{}; - auto result = - cudf::gather(source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = cudf::gather( + source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -416,7 +416,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::table_view tbl1({split_a[1]}); cudf::test::fixed_width_column_wrapper map0{{1, 2}, st, mr}; - auto result0 = cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result0 = + cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected0{Init{ {{4, 4, 4}, {5, 5}, {6, 6}}, {{7, 7, 7}, {8, 8}, {9, 9}}, @@ -430,7 +431,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) mr); cudf::test::fixed_width_column_wrapper map1{{0, 3}, st, mr}; - auto result1 = cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result1 = + cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected1{Init{ {{10, 10, 10}, {11, 11}, {12, 12}}, {{50, 50, 50, 50}, {6, 13}}, @@ -475,7 +477,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::table_view tbl({sliced[0]}); cudf::test::fixed_width_column_wrapper map{{0}, st, mr}; - auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view(), @@ -490,7 +493,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::table_view tbl({sliced[1]}); cudf::test::fixed_width_column_wrapper map{{1, 2, 0, 1}, st, mr}; - auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ Init{ {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, @@ -520,7 +524,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::table_view tbl({sliced[2]}); cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, st, mr}; - auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + auto result = + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); LCW expected{ Init{{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index cf041519fe0a..712a96ec82b2 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -62,7 +62,9 @@ TYPED_TEST(SegmentedGatherTest, Gather) auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -72,8 +74,11 @@ TYPED_TEST(SegmentedGatherTest, Gather) auto const gather_map = LCW{Init{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}, st, mr}; auto const expected = LCW{Init{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}, st, mr}; - auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -92,7 +97,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) auto const gather_map = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); auto const expected = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); @@ -104,7 +111,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); // hack to get column of empty list of list auto const expected_dummy = LCW{{{1, 2, 3, 4}, {5}}, LCW{}, LCW{}, LCW{}}; @@ -118,7 +127,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) auto const gather_map = LCW{LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); // hack to get column of empty list of list of list auto const expected_dummy = LCW{{{{1, 2, 3, 4}}}, LCW{}, LCW{}}; auto const expected = cudf::split(expected_dummy, {1}, st)[1]; @@ -152,7 +163,9 @@ TEST_F(SegmentedGatherTestSingle, GatherEmpty) auto const expected = LCW{}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -175,7 +188,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) auto const gather_map = LCW{Init{{0, 1}, Init{}, {1}, {2, 1, 0}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); auto const expected = LCW{Init{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -184,12 +199,15 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) { // Test gathering on lists that contain nulls, with out-of-bounds indices. auto const gather_map = LCW{Init{{10, -10}, Init{}, {1}, {2, -10, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); - auto const expected = LCW{ - Init{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}, - st, - mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + st, + mr.get_output_mr()); + auto const expected = + LCW{Init{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}, + st, + mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -266,14 +284,17 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) st, mr}; auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 3, -4}}, st, mr}; - auto const results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + st, + mr.get_output_mr()); auto const expected = LCW{Init{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - Init{}, - {{Init{0}}}, - {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}, + Init{}, + {{Init{0}}}, + {{{0, 1, 3}, {5}}}, + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -414,7 +435,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); auto const expected = LCW{{{2, 3}}, {{6, 7, 8}}, {LCW{}}}; // skip one null, gather one null. CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -448,7 +471,9 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) auto const gather_map = cudf::lists_column_view{list}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, gather_map, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); auto const expected = LCW{Init{ {{2, 2}, {3, 3}}, {{4, 4, 4}, {6, 6}}, @@ -465,7 +490,9 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) auto const gather_map = cudf::lists_column_view{list}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, gather_map, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); auto const expected = LCW{Init{{{10, 10, 10}, {11, 11}}, Init{}, Init{}, {{50, 50, 50, 50}, {6, 13}}, Init{}}, st, @@ -506,7 +533,9 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) LCW map{Init{{0, 1}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view(), @@ -521,7 +550,9 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) LCW map{Init{{0}, {1, 2, 0, 1}, {0, 1, 2}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); LCW expected{ Init{ {{Init{0}}}, @@ -548,7 +579,9 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) LCW map{Init{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}, st, mr}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); std::vector expected_valids = {false, true, true, false, false, true}; LCW expected{Init{{{{Init{30}}, @@ -595,7 +628,9 @@ TEST_F(SegmentedGatherTestString, StringGather) LCW{StrInit{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, StrInit{}}, st, mr}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -608,12 +643,15 @@ TEST_F(SegmentedGatherTestString, StringGather) I8Init{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}, st, mr}; auto const expected = LCW{StrInit{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, - {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, - StrInit{}}, + {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, + StrInit{}}, st, mr}; - auto result = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); } @@ -636,7 +674,9 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}, st, mr}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); @@ -646,7 +686,9 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) auto result0 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -655,7 +697,9 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) mr); auto result1 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -664,7 +708,9 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) mr); auto result2 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -679,12 +725,13 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, st, mr}; auto const gather_map = LCW{Init{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}, st, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - auto const expected = - LCW{Init{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}, - st, - mr}; - auto results = cudf::lists::segmented_gather( - cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); + auto const expected = LCW{ + Init{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}, st, mr}; + auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); @@ -692,24 +739,33 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) auto const split_m = cudf::split(gather_map, {1, 4}, st); auto const split_e = cudf::split(expected, {1, 4}, st); - auto const result0 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, NULLIFY, st, mr.get_output_mr()); + auto const result0 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, + cudf::lists_column_view{split_m[0]}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, st, mr); - auto const result1 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, NULLIFY, st, mr.get_output_mr()); + auto const result1 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, + cudf::lists_column_view{split_m[1]}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, st, mr); - auto const result2 = cudf::lists::segmented_gather( - cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, NULLIFY, st, mr.get_output_mr()); + auto const result2 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, + cudf::lists_column_view{split_m[2]}, + NULLIFY, + st, + mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -738,17 +794,23 @@ TEST_F(SegmentedGatherTestFloat, Fails) // strings, or lists containing anything other than integers. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nonlist_map0}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()), cudf::logic_error); EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nonlist_map1}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()), cudf::logic_error); EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nonlist_map2}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()), cudf::logic_error); auto valids = cudf::test::iterators::valids_at_multiples_of(2); @@ -758,13 +820,17 @@ TEST_F(SegmentedGatherTestFloat, Fails) // Nulls are not supported in the gather map. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nulls_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()), std::invalid_argument); // Gather map and list column sizes must be the same. EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{size_mismatch_map}, - cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()), + cudf::out_of_bounds_policy::DONT_CHECK, + st, + mr.get_output_mr()), cudf::logic_error); } diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index efde223fcc68..e8085b1cb3b2 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -1572,7 +1572,8 @@ TEST_F(ListsColumnInitializerHarnessTest, LeafInitUsesExplicitResources) } LCW expected{Init{{1, 2, 3, 4}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TEST_F(ListsColumnInitializerHarnessTest, LeafNullableInitUsesExplicitResources) @@ -1615,5 +1616,6 @@ TEST_F(ListsColumnInitializerHarnessTest, SingleChildNestedInitUsesExplicitResou } LCW expected{Init{{{{1, 2, 3}}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } From 60c8c7efb147101bd11d4b25aa04dd475adbd0d9 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 18 Aug 2026 13:30:16 -0700 Subject: [PATCH 05/21] fix tests --- .../copying/segmented_gather_list_tests.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 712a96ec82b2..472c82adfb35 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -94,20 +94,19 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) // List { auto const list = LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; - auto const gather_map = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; + auto const gather_map = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{{LCW{}, LCW{}, LCW{}, LCW{}}, st, mr}; + auto const expected = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List> { - // Keep base brace nesting for empty-row hierarchy (Init empty encoding differs). - auto const list = LCW{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {LCW{}, {8, 9, 10}}}; + auto const list = LCW{Init{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}, st, mr}; auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, @@ -116,14 +115,14 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) mr.get_output_mr()); // hack to get column of empty list of list - auto const expected_dummy = LCW{{{1, 2, 3, 4}, {5}}, LCW{}, LCW{}, LCW{}}; + auto const expected_dummy = LCW{Init{{{1, 2, 3, 4}, {5}}, Init{}, Init{}, Init{}}, st, mr}; auto const expected = cudf::split(expected_dummy, {1}, st)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } // List>> { - auto const list = LCW{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + auto const list = LCW{Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; auto const gather_map = LCW{LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, @@ -131,7 +130,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) st, mr.get_output_mr()); // hack to get column of empty list of list of list - auto const expected_dummy = LCW{{{{1, 2, 3, 4}}}, LCW{}, LCW{}}; + auto const expected_dummy = LCW{Init{{{{1, 2, 3, 4}}}, Init{}, Init{}}, st, mr}; auto const expected = cudf::split(expected_dummy, {1}, st)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); @@ -431,7 +430,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const st = this->stream(); auto const mr = this->resources(); - auto const list = LCW{{{2, 3}, LCW{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {LCW{}}}; + auto const list = + LCW{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; + // Per-row singleton lists: brace LCWs (Init{{0},{0},{0}} flattens to one list of three). auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, @@ -439,7 +440,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) st, mr.get_output_mr()); auto const expected = - LCW{{{2, 3}}, {{6, 7, 8}}, {LCW{}}}; // skip one null, gather one null. + LCW{Init{{{2, 3}}, {{6, 7, 8}}, {Init{}}}, st, mr}; // skip one null, gather one null. CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } From e2235c50dabdde0cb4a35f45d81c854d2e425900 Mon Sep 17 00:00:00 2001 From: Niranda Perera Date: Mon, 24 Aug 2026 15:39:35 -0700 Subject: [PATCH 06/21] Apply suggestions from code review Co-authored-by: Bradley Dice --- cpp/include/cudf_test/column_wrapper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index c9889822665c..60f63d646cfa 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -343,7 +343,7 @@ auto make_chars_and_offsets(StringsIterator begin, StringsIterator end, Validity } // namespace detail -// Forward declaration for lists_column_initializer::build +// Forward declaration for lists_column_initializer template class lists_column_wrapper; @@ -482,7 +482,7 @@ class lists_column_initializer { template [[nodiscard]] std::pair>, std::vector> - build(rmm::cuda_stream_view stream, cudf::memory_resources mr) const + build(cuda::stream_ref stream, cudf::memory_resources mr) const { std::vector> children; std::vector validity; From 81a0096b88047dcd6ad1afc81c34ed34b5b755d4 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 24 Aug 2026 16:23:38 -0700 Subject: [PATCH 07/21] addressing comments Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 7 +- cpp/tests/copying/gather_list_tests.cpp | 499 +++++----- .../copying/segmented_gather_list_tests.cpp | 936 ++++++++++-------- 3 files changed, 764 insertions(+), 678 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 60f63d646cfa..4262e857a2c2 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -426,7 +426,8 @@ class lists_column_initializer { */ template lists_column_initializer(std::initializer_list children, ValidityIterator v) - requires(std::is_same_v) + requires(std::is_same_v && + std::is_convertible_v, bool>) : nested_{true} { children_.reserve(children.size()); @@ -434,7 +435,9 @@ class lists_column_initializer { if (static_cast(*v++)) { children_.push_back(child); } else { - children_.emplace_back(); + + + + children_.emplace_back(); children_.back().valid_ = false; } } diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 2f8ad7db254b..5080ac78ecc3 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -41,54 +41,56 @@ TYPED_TEST(GatherTestListTyped, Gather) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List - LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{1, 2, 3, 4}, {6, 7}}, st, mr}; + Init expected{{1, 2, 3, 4}, {6, 7}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } TYPED_TEST(GatherTestListTyped, GatherNothing) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List { - LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; cudf::test::fixed_width_column_wrapper gather_map{}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); LCW expected; CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List { - cudf::test::lists_column_wrapper list{ - Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; + Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; cudf::test::fixed_width_column_wrapper gather_map{}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto result = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -110,77 +112,79 @@ TYPED_TEST(GatherTestListTyped, GatherNulls) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - LCW list{Init{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, st, mr}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; + Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}, st, mr}; + Init expected{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } TYPED_TEST(GatherTestListTyped, GatherNested) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { - LCW list{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - st, - mr}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; + + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{ - Init{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; + Init expected{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } // List>> { - LCW list{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, - st, - mr}; - cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; + + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, - st, - mr}; + Init expected{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -188,30 +192,29 @@ TYPED_TEST(GatherTestListTyped, GatherOutOfOrder) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { - LCW list{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - st, - mr}; - cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, stream, mr}; + + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{2, 3}, {4, 5}}}, - st, - mr}; + Init expected{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{2, 3}, {4, 5}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -219,64 +222,60 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List> { - LCW list{ - Init{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, - st, - mr}; + Init list{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, st, mr}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, stream, mr}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{ - Init{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, - st, - mr}; + Init expected{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } // List>> { - LCW list{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, - st, - mr}; - - cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + + cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; + + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, - st, - mr}; + Init expected{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -284,70 +283,70 @@ TYPED_TEST(GatherTestListTyped, GatherNestedWithEmpties) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); - LCW list{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, st, mr}; + Init list{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({list}); + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{Init{{{2, 3}, Init{}}, {Init{}}}, st, mr}; + Init expected{{{2, 3}, Init{}}, {Init{}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { - LCW list{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - st, - mr}; - cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, stream, mr}; + + cudf::table_view source_table({LCW(list, stream, mr)}); auto results = cudf::gather( - source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, st, mr.get_output_mr()); + source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, stream, mr.get_output_mr()); std::vector expected_validity{1, 0, 0, 1}; - LCW expected{ - Init{ - {{{2, 3}, {4, 5}}, {Init{}}, {Init{}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - expected_validity.begin()}, - st, - mr}; + Init expected{ + {{{2, 3}, {4, 5}}, {Init{}}, {Init{}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + expected_validity.begin()}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } TEST_F(GatherTestList, GatherIncompleteHierarchies) { - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); { // List, but rows 1 and 2 are empty at the very top. // We expect to get back a "full" hierarchy of type List> anyway. - cudf::test::lists_column_wrapper list{Init{{{{1, 2}}}, Init{}, Init{}}, st, mr}; + Init list{{{{1, 2}}}, Init{}, Init{}}; - cudf::table_view source_table({list}); - - cudf::test::fixed_width_column_wrapper row1_map{{1}, st, mr}; + cudf::test::fixed_width_column_wrapper row1_map{{1}, stream, mr}; + cudf::table_view source_table({LCW(list, stream, mr)}); auto result = cudf::gather( - source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -367,13 +366,12 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) { // List, gathering nothing. // We expect to get back a "full" hierarchy of type List> anyway. - cudf::test::lists_column_wrapper list{Init{{{{1, 2}}}, Init{}}, st, mr}; - - cudf::table_view source_table({list}); + Init list{{{{1, 2}}}, Init{}}; cudf::test::fixed_width_column_wrapper empty_map{}; + cudf::table_view source_table({LCW(list, stream, mr)}); auto result = cudf::gather( - source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); + source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -395,54 +393,49 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); { - LCW a{Init{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }, - st, - mr}; - auto split_a = cudf::split(a, {3}, st); + Init a{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }; + auto const col = LCW(a, stream, mr); + auto split_a = cudf::split(col, {3}, stream); cudf::table_view tbl0({split_a[0]}); cudf::table_view tbl1({split_a[1]}); - cudf::test::fixed_width_column_wrapper map0{{1, 2}, st, mr}; + cudf::test::fixed_width_column_wrapper map0{{1, 2}, stream, mr}; auto result0 = - cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected0{Init{ - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - }, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected0, + cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); + Init expected0{ + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + }; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected0, stream, mr), result0->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, - st, + stream, mr); - cudf::test::fixed_width_column_wrapper map1{{0, 3}, st, mr}; + cudf::test::fixed_width_column_wrapper map1{{0, 3}, stream, mr}; auto result1 = - cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected1{Init{ - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{50, 50, 50, 50}, {6, 13}}, - }, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, + cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); + Init expected1{ + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{50, 50, 50, 50}, {6, 13}}, + }; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected1, stream, mr), result1->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, - st, + stream, mr); } @@ -450,41 +443,39 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) // List>> { - LCW list{ - Init{// slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init list{// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, - st, - mr}; + // slice 2 + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; - auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}, st); + auto const col = LCW(list, stream, mr); + auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); // gather from slice 0 { cudf::table_view tbl({sliced[0]}); - cudf::test::fixed_width_column_wrapper map{{0}, st, mr}; + cudf::test::fixed_width_column_wrapper map{{0}, stream, mr}; auto result = - cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); + Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } @@ -492,30 +483,27 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) { cudf::table_view tbl({sliced[1]}); - cudf::test::fixed_width_column_wrapper map{{1, 2, 0, 1}, st, mr}; + cudf::test::fixed_width_column_wrapper map{{1, 2, 0, 1}, stream, mr}; auto result = - cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{ - Init{ - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - - {{Init{0}}}, - - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - }, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); + Init expected{ + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + + {{Init{0}}}, + + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + }; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } @@ -523,24 +511,23 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) { cudf::table_view tbl({sliced[2]}); - cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, st, mr}; + cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, stream, mr}; auto result = - cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - LCW expected{ - Init{{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, - result->get_column(0).view(), - cudf::test::debug_output_level::FIRST_ERROR, - cudf::test::default_ulp, - st, - mr); + cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); + Init expected + { + {{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + result->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + stream, + mr); + } } } -} diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 472c82adfb35..4a99fd928fd9 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -50,37 +50,44 @@ TYPED_TEST(SegmentedGatherTest, Gather) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List - LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; { // Straight-line case. - auto const gather_map = LCW{Init{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}, st, mr}; - auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}; + Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } { // Nullify out-of-bounds values. - auto const gather_map = LCW{Init{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}, st, mr}; - auto const expected = - LCW{Init{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - NULLIFY, - st, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init gather_map{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}; + Init expected{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -88,52 +95,57 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List { - auto const list = LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; auto const gather_map = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - auto const expected = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + auto const expected = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List> { - auto const list = LCW{Init{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}, st, mr}; + Init list{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}; auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); // hack to get column of empty list of list - auto const expected_dummy = LCW{Init{{{1, 2, 3, 4}, {5}}, Init{}, Init{}, Init{}}, st, mr}; - auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + Init expected_dummy{{{1, 2, 3, 4}, {5}}, Init{}, Init{}, Init{}}; + auto const col = LCW(expected_dummy, stream, mr); + auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List>> { - auto const list = LCW{Init{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, st, mr}; + Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; auto const gather_map = LCW{LCW{}, LCW{}}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); // hack to get column of empty list of list of list - auto const expected_dummy = LCW{Init{{{{1, 2, 3, 4}}}, Init{}, Init{}}, st, mr}; - auto const expected = cudf::split(expected_dummy, {1}, st)[1]; + Init expected_dummy{{{{1, 2, 3, 4}}}, Init{}, Init{}}; + auto const col = LCW(expected_dummy, stream, mr); + auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); // the result should preserve the full List>> hierarchy // even though it is empty past the first level @@ -154,8 +166,8 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) using SegmentedGatherTestSingle = SegmentedGatherTest; TEST_F(SegmentedGatherTestSingle, GatherEmpty) { - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); auto const list = LCW{}; auto const gather_map = LCW{}; @@ -163,52 +175,55 @@ TEST_F(SegmentedGatherTestSingle, GatherEmpty) auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - *results, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TYPED_TEST(SegmentedGatherTest, GatherNulls) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - auto const list = - LCW{Init{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, st, mr}; + Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; { // Test gathering on lists that contain nulls. - auto const gather_map = LCW{Init{{0, 1}, Init{}, {1}, {2, 1, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - auto const expected = - LCW{Init{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init gather_map{{0, 1}, Init{}, {1}, {2, 1, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } { // Test gathering on lists that contain nulls, with out-of-bounds indices. - auto const gather_map = LCW{Init{{10, -10}, Init{}, {1}, {2, -10, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - NULLIFY, - st, - mr.get_output_mr()); - auto const expected = - LCW{Init{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init gather_map{{10, -10}, Init{}, {1}, {2, -10, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + Init expected{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -216,88 +231,113 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, st, mr}; - auto const gather_map = LCW{Init{{0, -2, -2}, {1}, {1, 0, -1, -5}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{2, 3}, {2, 3}, {2, 3}}, - {{9, 10, 11}}, - {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; + Init gather_map{{0, -2, -2}, {1}, {1, 0, -1, -5}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{2, 3}, {2, 3}, {2, 3}}, + {{9, 10, 11}}, + {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, st, mr}; - auto const gather_map = LCW{Init{{0, 2, -2}, {1}, {1, 0, -1, -6}}, st, mr}; + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; + Init gather_map{{0, 2, -2}, {1}, {1, 0, -1, -6}}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, - {{9, 10, 11}}, - {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + Init expected{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, + {{9, 10, 11}}, + {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>> { // clang-format off - auto const list = LCW{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, st, mr}; - auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 1}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - Init{}, - {{Init{0}}}, - {{{0, 1, 3}, {5}}}, - {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; + Init gather_map{{1}, Init{}, {0}, {1}, {0, -1, 1}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init{}, + {{Init{0}}}, + {{{0, 1, 3}, {5}}}, + {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>>, with out-of-bounds gather indices. { - auto const list = LCW{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}, - st, - mr}; - auto const gather_map = LCW{Init{{1}, Init{}, {0}, {1}, {0, -1, 3, -4}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - NULLIFY, - st, - mr.get_output_mr()); - auto const expected = - LCW{Init{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; + Init gather_map{{1}, Init{}, {0}, {1}, {0, -1, 3, -4}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, Init{}, {{Init{0}}}, {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -305,36 +345,54 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; - auto const gather_map = LCW{Init{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{4, 5}, {2, 3}}, - {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + Init gather_map{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{4, 5}, {2, 3}}, + {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, + {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; - auto const gather_map = LCW{Init{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{4, 5}, {2, 3}}, - {{Init{}, {12, 13, 14}, Init{}}, nulls_at({0, 2})}, - {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + Init gather_map{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + Init expected{{{4, 5}, {2, 3}}, + {{Init{}, {12, 13, 14}, Init{}}, nulls_at({0, 2})}, + {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } } @@ -343,36 +401,53 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List> { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; - auto const gather_map = LCW{Init{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{4, 5}, {2, 3}}, - {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + Init gather_map{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{4, 5}, {2, 3}}, + {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>, with out-of-bounds gather indices. { // clang-format off - auto const list = LCW{Init{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, st, mr}; - auto const gather_map = LCW{Init{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}, st, mr}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, NULLIFY, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{4, 5}, {2, 3}}, - {{{9, 10, 11}, {12, 13, 14}, Init{}}, null_at(2)}, - {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + Init gather_map{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + Init expected{{{4, 5}, {2, 3}}, + {{{9, 10, 11}, {12, 13, 14}, Init{}}, null_at(2)}, + {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } } @@ -381,44 +456,62 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List> { // clang-format off - auto const list = LCW{Init{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, st, mr}; - auto const gather_map = LCW{Init{{0, 1}, {0, 2}, Init{}, {0, 1, 4}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {12, 13, 14}}, no_nulls()}, - Init{}, - {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; + Init gather_map{{0, 1}, {0, 2}, Init{}, {0, 1, 4}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {12, 13, 14}}, no_nulls()}, + Init{}, + {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } // List>>> { // clang-format off - auto const list = LCW{Init{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, st, mr}; - auto const gather_map = LCW{Init{{1, 2, 4}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, st, mr.get_output_mr()); - auto const expected = LCW{Init{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; + Init gather_map{{1, 2, 4}}; + auto const results = + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{Init{0}}}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); // clang-format on } } @@ -427,79 +520,80 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); - auto const list = - LCW{Init{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}, st, mr}; + Init list{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}; // Per-row singleton lists: brace LCWs (Init{{0},{0},{0}} flattens to one list of three). auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; - auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + auto results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); - auto const expected = - LCW{Init{{{2, 3}}, {{6, 7, 8}}, {Init{}}}, st, mr}; // skip one null, gather one null. - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init expected{{{2, 3}}, {{6, 7, 8}}, {Init{}}}; // skip one null, gather one null. + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), + LCW(expected, stream, mr), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } TYPED_TEST(SegmentedGatherTest, GatherSliced) { using T = TypeParam; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); { - auto const a = LCW{Init{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }, - st, - mr}; - auto const split_a = cudf::split(a, {3}, st); + Init a{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }; + auto const col = LCW(a, stream, mr); + auto const split_a = cudf::split(col, {3}, stream); { - auto const list = LCW{Init{{1, 2}, {0, 2}, {0, 1}}, st, mr}; - auto const gather_map = cudf::lists_column_view{list}; + Init list{{1, 2}, {0, 2}, {0, 1}}; + auto const gather_map = cudf::lists_column_view{LCW(list, stream, mr)}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); - auto const expected = LCW{Init{ - {{2, 2}, {3, 3}}, - {{4, 4, 4}, {6, 6}}, - {{7, 7, 7}, {8, 8}}, - }, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init expected{ + {{2, 2}, {3, 3}}, + {{4, 4, 4}, {6, 6}}, + {{7, 7, 7}, {8, 8}}, + }; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } { - auto const list = LCW{Init{{0, 1}, Init{}, Init{}, {0, 1}, Init{}}, st, mr}; - auto const gather_map = cudf::lists_column_view{list}; + Init list{{0, 1}, Init{}, Init{}, {0, 1}, Init{}}; + auto const gather_map = cudf::lists_column_view{LCW(list, stream, mr)}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); - auto const expected = - LCW{Init{{{10, 10, 10}, {11, 11}}, Init{}, Init{}, {{50, 50, 50, 50}, {6, 13}}, Init{}}, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); + Init expected{{{10, 10, 10}, {11, 11}}, Init{}, Init{}, {{50, 50, 50, 50}, {6, 13}}, Init{}}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -507,105 +601,101 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // List>> { - LCW list{ - Init{// slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + Init list{// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, - st, - mr}; + // slice 2 + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; - auto sliced = cudf::slice(list, {0, 1, 2, 5, 5, 7}, st); + auto const col = LCW(list, stream, mr); + auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); // gather from slice 0 { - LCW map{Init{{0, 1}}, st, mr}; - auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, - cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - LCW expected{Init{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, st, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + Init map{{0, 1}}; + auto result = + cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, + cudf::lists_column_view{LCW(map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } // gather from slice 1 { - LCW map{Init{{0}, {1, 2, 0, 1}, {0, 1, 2}}, st, mr}; - auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, - cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - LCW expected{ - Init{ - {{Init{0}}}, - - {{{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}, - {{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - }, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + Init map{{0}, {1, 2, 0, 1}, {0, 1, 2}}; + auto result = + cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, + cudf::lists_column_view{LCW(map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + Init expected{ + {{Init{0}}}, + + {{{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}, + {{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + }; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } // gather from slice 2 { - LCW map{Init{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}, st, mr}; - auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, - cudf::lists_column_view{map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); + Init map{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}; + auto result = + cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, + cudf::lists_column_view{LCW(map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); std::vector expected_valids = {false, true, true, false, false, true}; - LCW expected{Init{{{{Init{30}}, - {{{10, 20}, valids}}, - {{{10, 20}, valids}}, - {Init{30}}, - {Init{30}}, - {{{10, 20}, valids}}}, - expected_valids.begin()}, - {{{Init{30}}, - {{10, 20, 30}}, - {{10, 20, 30}}, - {Init{30}}, - {Init{30}}, - {{{20, 30}, valids}, {62, 72, 82}}}, - expected_valids.begin()}}, - st, - mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, + Init expected{{{{Init{30}}, + {{{10, 20}, valids}}, + {{{10, 20}, valids}}, + {Init{30}}, + {Init{30}}, + {{{10, 20}, valids}}}, + expected_valids.begin()}, + {{{Init{30}}, + {{10, 20, 30}}, + {{10, 20, 30}}, + {Init{30}}, + {Init{30}}, + {{{20, 30}, valids}, {62, 72, 82}}}, + expected_valids.begin()}}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } } @@ -616,45 +706,45 @@ TEST_F(SegmentedGatherTestString, StringGather) { using T = cudf::string_view; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List { - auto const list = - LCW{StrInit{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, st, mr}; - auto const gather_map = cudf::test::lists_column_wrapper{ - I8Init{{0, 1, 3, 2}, {1, 0, 3, 2}, I8Init{}}, st, mr}; - auto const expected = - LCW{StrInit{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, StrInit{}}, st, mr}; - auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); + StrInit list{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; + I8Init gather_map{{0, 1, 3, 2}, {1, 0, 3, 2}, I8Init{}}; + StrInit expected{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, StrInit{}}; + auto const result = cudf::lists::segmented_gather( + cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{cudf::test::lists_column_wrapper(gather_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } // List, with out-of-order gather indices. { - auto const list = - LCW{StrInit{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, st, mr}; - auto const gather_map = cudf::test::lists_column_wrapper{ - I8Init{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}, st, mr}; - auto const expected = - LCW{StrInit{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, + StrInit list{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; + I8Init gather_map{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}; + StrInit expected{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, - StrInit{}}, - st, - mr}; - auto result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, - NULLIFY, - st, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL( - expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, st, mr); + StrInit{}}; + auto result = cudf::lists::segmented_gather( + cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{cudf::test::lists_column_wrapper(gather_map, stream, mr)}, + NULLIFY, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), + result->view(), + cudf::test::debug_output_level::FIRST_ERROR, + stream, + mr); } } @@ -663,115 +753,118 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) { using T = float; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List { - auto const list = - LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, st, mr}; - auto const gather_map = LCW{Init{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; + Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - auto const expected = LCW{Init{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}, st, mr}; - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, + Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}; + auto const list_col = LCW(list, stream, mr); + auto const gather_map_col = LCW(gather_map, stream, mr); + auto const expected_col = LCW(expected, stream, mr); + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, + cudf::lists_column_view{gather_map_col}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + results->view(), expected_col, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); - auto const sliced = cudf::split(list, {1, 4}, st); - auto const split_m = cudf::split(gather_map, {1, 4}, st); - auto const split_e = cudf::split(expected, {1, 4}, st); + auto const sliced = cudf::split(list_col, {1, 4}, stream); + auto const split_m = cudf::split(gather_map_col, {1, 4}, stream); + auto const split_e = cudf::split(expected_col, {1, 4}, stream); auto result0 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); auto result1 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); auto result2 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } // List, with out-of-bounds gather indices. { - auto const list = - LCW{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, st, mr}; - auto const gather_map = LCW{Init{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; + Init gather_map{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - auto const expected = LCW{ - Init{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}, st, mr}; - auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{gather_map}, + Init expected{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}; + auto const list_col = LCW(list, stream, mr); + auto const gather_map_col = LCW(gather_map, stream, mr); + auto const expected_col = LCW(expected, stream, mr); + auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, + cudf::lists_column_view{gather_map_col}, NULLIFY, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUAL( - results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); + results->view(), expected_col, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); - auto const sliced = cudf::split(list, {1, 4}, st); - auto const split_m = cudf::split(gather_map, {1, 4}, st); - auto const split_e = cudf::split(expected, {1, 4}, st); + auto const sliced = cudf::split(list_col, {1, 4}, stream); + auto const split_m = cudf::split(gather_map_col, {1, 4}, stream); + auto const split_e = cudf::split(expected_col, {1, 4}, stream); auto const result0 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{split_m[0]}, NULLIFY, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[0], result0->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); auto const result1 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{split_m[1]}, NULLIFY, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[1], result1->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); auto const result2 = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{split_m[2]}, NULLIFY, - st, + stream, mr.get_output_mr()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(split_e[2], result2->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, - st, + stream, mr); } } @@ -780,59 +873,62 @@ TEST_F(SegmentedGatherTestFloat, Fails) { using T = float; - auto const st = this->stream(); - auto const mr = this->resources(); + auto const stream = this->stream(); + auto const mr = this->resources(); // List - LCW list{Init{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, st, mr}; - cudf::test::lists_column_wrapper size_mismatch_map{ - I8Init{{3, 2, 1, 0}, {0}, {0, 1}}, st, mr}; - cudf::test::fixed_width_column_wrapper nonlist_map0{{1, 2, 0, 1}, st, mr}; - cudf::test::strings_column_wrapper nonlist_map1{{"1", "2", "0", "1"}, st, mr}; - LCW nonlist_map2{StrInit{{"1", "2", "0", "1"}}, st, mr}; + Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + I8Init size_mismatch_map{{3, 2, 1, 0}, {0}, {0, 1}}; + cudf::test::fixed_width_column_wrapper nonlist_map0{{1, 2, 0, 1}, stream, mr}; + cudf::test::strings_column_wrapper nonlist_map1{{"1", "2", "0", "1"}, stream, mr}; + StrInit nonlist_map2{{"1", "2", "0", "1"}}; // Input must be a list of integer indices. It should fail for integers, // strings, or lists containing anything other than integers. - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{nonlist_map0}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()), cudf::logic_error); - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{nonlist_map1}, cudf::out_of_bounds_policy::DONT_CHECK, - st, + stream, mr.get_output_mr()), cudf::logic_error); - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nonlist_map2}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()), + EXPECT_THROW(cudf::lists::segmented_gather( + cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{LCW(nonlist_map2, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), cudf::logic_error); auto valids = cudf::test::iterators::valids_at_multiples_of(2); - cudf::test::lists_column_wrapper nulls_map{ - I8Init{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}, st, mr}; + I8Init nulls_map{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}; // Nulls are not supported in the gather map. - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{nulls_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()), - std::invalid_argument); + EXPECT_THROW( + cudf::lists::segmented_gather( + cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{cudf::test::lists_column_wrapper(nulls_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), + std::invalid_argument); // Gather map and list column sizes must be the same. - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, - cudf::lists_column_view{size_mismatch_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - st, - mr.get_output_mr()), - cudf::logic_error); + EXPECT_THROW( + cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + cudf::lists_column_view{cudf::test::lists_column_wrapper( + size_mismatch_map, stream, mr)}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), + cudf::logic_error); } #if defined(__GNUC__) && (__GNUC__ >= 14) From 4e09b94cc33245bf0040361dea86bee84c639941 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 24 Aug 2026 17:04:23 -0700 Subject: [PATCH 08/21] remove stray + Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 4262e857a2c2..10492aff8136 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -435,9 +435,7 @@ class lists_column_initializer { if (static_cast(*v++)) { children_.push_back(child); } else { - + - - children_.emplace_back(); + children_.emplace_back(); children_.back().valid_ = false; } } From 4d0ade6b09d5407b4dd09520e30c5fe757789dcf Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 24 Aug 2026 17:14:15 -0700 Subject: [PATCH 09/21] malformed init Signed-off-by: niranda perera --- cpp/tests/copying/gather_list_tests.cpp | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 5080ac78ecc3..6c8803d3c1b9 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -514,20 +514,18 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, stream, mr}; auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected - { - {{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), - result->get_column(0).view(), - cudf::test::debug_output_level::FIRST_ERROR, - cudf::test::default_ulp, - stream, - mr); - } + Init expected{{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + result->get_column(0).view(), + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + stream, + mr); } } +} From 56af3f23e654fd0e1730a5fc52af00bba3ba2eef Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 24 Aug 2026 17:36:04 -0700 Subject: [PATCH 10/21] fix tests Signed-off-by: niranda perera --- cpp/tests/copying/gather_list_tests.cpp | 39 ++++++++++++------- .../copying/segmented_gather_list_tests.cpp | 6 ++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 6c8803d3c1b9..f35e77babe0e 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -48,7 +48,8 @@ TYPED_TEST(GatherTestListTyped, Gather) Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -73,7 +74,8 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; cudf::test::fixed_width_column_wrapper gather_map{}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -88,7 +90,8 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; cudf::test::fixed_width_column_wrapper gather_map{}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -121,7 +124,8 @@ TYPED_TEST(GatherTestListTyped, GatherNulls) Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -148,7 +152,8 @@ TYPED_TEST(GatherTestListTyped, GatherNested) {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -172,7 +177,8 @@ TYPED_TEST(GatherTestListTyped, GatherNested) {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -202,7 +208,8 @@ TYPED_TEST(GatherTestListTyped, GatherOutOfOrder) {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -236,7 +243,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -263,7 +271,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -289,7 +298,8 @@ TYPED_TEST(GatherTestListTyped, GatherNestedWithEmpties) Init list{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -316,7 +326,8 @@ TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, stream, mr.get_output_mr()); @@ -344,7 +355,8 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) Init list{{{{1, 2}}}, Init{}, Init{}}; cudf::test::fixed_width_column_wrapper row1_map{{1}, stream, mr}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -369,7 +381,8 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) Init list{{{{1, 2}}}, Init{}}; cudf::test::fixed_width_column_wrapper empty_map{}; - cudf::table_view source_table({LCW(list, stream, mr)}); + auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 4a99fd928fd9..1748a05d7507 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -562,7 +562,8 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) { Init list{{1, 2}, {0, 2}, {0, 1}}; - auto const gather_map = cudf::lists_column_view{LCW(list, stream, mr)}; + auto const map_col = LCW(list, stream, mr); + auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, @@ -582,7 +583,8 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) { Init list{{0, 1}, Init{}, Init{}, {0, 1}, Init{}}; - auto const gather_map = cudf::lists_column_view{LCW(list, stream, mr)}; + auto const map_col = LCW(list, stream, mr); + auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, From a6d710880b1acb93c729f8ecc0044b4081aee415 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 25 Aug 2026 16:02:46 -0700 Subject: [PATCH 11/21] Init to I32init Signed-off-by: niranda perera --- .../copying/segmented_gather_list_tests.cpp | 242 +++++++++--------- 1 file changed, 123 insertions(+), 119 deletions(-) diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 1748a05d7507..69ecd89568aa 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -42,7 +42,7 @@ auto constexpr NULLIFY = cudf::out_of_bounds_policy::NULLIFY; // Nested list values. Passing these to lists_column_wrapper builds every nesting level with the // explicit stream and memory resources instead of the current device resource. -using Init = cudf::test::lists_column_initializer; +using I32Init = cudf::test::lists_column_initializer; using I8Init = cudf::test::lists_column_initializer; using StrInit = cudf::test::lists_column_initializer; @@ -54,12 +54,12 @@ TYPED_TEST(SegmentedGatherTest, Gather) auto const mr = this->resources(); // List - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; { // Straight-line case. - Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}; - Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}; + I32Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}; + I32Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, @@ -75,8 +75,8 @@ TYPED_TEST(SegmentedGatherTest, Gather) { // Nullify out-of-bounds values. - Init gather_map{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}; - Init expected{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}; + I32Init gather_map{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}; + I32Init expected{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, @@ -100,7 +100,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) // List { - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; auto const gather_map = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, @@ -114,7 +114,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) } // List> { - Init list{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {Init{}, {8, 9, 10}}}; + I32Init list{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {I32Init{}, {8, 9, 10}}}; auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, @@ -124,7 +124,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) mr.get_output_mr()); // hack to get column of empty list of list - Init expected_dummy{{{1, 2, 3, 4}, {5}}, Init{}, Init{}, Init{}}; + I32Init expected_dummy{{{1, 2, 3, 4}, {5}}, I32Init{}, I32Init{}, I32Init{}}; auto const col = LCW(expected_dummy, stream, mr); auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -132,7 +132,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) } // List>> { - Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + I32Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; auto const gather_map = LCW{LCW{}, LCW{}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, @@ -141,7 +141,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) stream, mr.get_output_mr()); // hack to get column of empty list of list of list - Init expected_dummy{{{{1, 2, 3, 4}}}, Init{}, Init{}}; + I32Init expected_dummy{{{{1, 2, 3, 4}}}, I32Init{}, I32Init{}}; auto const col = LCW(expected_dummy, stream, mr); auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( @@ -191,18 +191,18 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; + I32Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; { // Test gathering on lists that contain nulls. - Init gather_map{{0, 1}, Init{}, {1}, {2, 1, 0}}; + I32Init gather_map{{0, 1}, I32Init{}, {1}, {2, 1, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{1, 2}, valids}, Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}; + I32Init expected{{{1, 2}, valids}, I32Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -211,14 +211,15 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) } { // Test gathering on lists that contain nulls, with out-of-bounds indices. - Init gather_map{{10, -10}, Init{}, {1}, {2, -10, 0}}; + I32Init gather_map{{10, -10}, I32Init{}, {1}, {2, -10, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, NULLIFY, stream, mr.get_output_mr()); - Init expected{{{0, 0}, nulls_at({0, 1})}, Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}; + I32Init expected{ + {{0, 0}, nulls_at({0, 1})}, I32Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -237,17 +238,17 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List> { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - Init gather_map{{0, -2, -2}, {1}, {1, 0, -1, -5}}; + I32Init gather_map{{0, -2, -2}, {1}, {1, 0, -1, -5}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{2, 3}, {2, 3}, {2, 3}}, + I32Init expected{{{2, 3}, {2, 3}, {2, 3}}, {{9, 10, 11}}, {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), @@ -261,19 +262,19 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>, with out-of-bounds gather indices. { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - Init gather_map{{0, 2, -2}, {1}, {1, 0, -1, -6}}; + I32Init gather_map{{0, 2, -2}, {1}, {1, 0, -1, -6}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, NULLIFY, stream, mr.get_output_mr()); - Init expected{{{{2, 3}, Init{}, {2, 3}}, null_at(1)}, + I32Init expected{{{{2, 3}, I32Init{}, {2, 3}}, null_at(1)}, {{9, 10, 11}}, - {{{17, 18}, {15, 16}, {-17, -18}, Init{}}, null_at(3)}}; + {{{17, 18}, {15, 16}, {-17, -18}, I32Init{}}, null_at(3)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -285,25 +286,25 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>> { // clang-format off - Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + I32Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, + {{I32Init{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; - Init gather_map{{1}, Init{}, {0}, {1}, {0, -1, 1}}; + {{{10, 20}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}}; + I32Init gather_map{{1}, I32Init{}, {0}, {1}, {0, -1, 1}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - Init{}, - {{Init{0}}}, + I32Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + I32Init{}, + {{I32Init{0}}}, {{{0, 1, 3}, {5}}}, - {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {Init{30}}}}; + {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {I32Init{30}}}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -314,25 +315,26 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>>, with out-of-bounds gather indices. { - Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; - Init gather_map{{1}, Init{}, {0}, {1}, {0, -1, 3, -4}}; + I32Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{I32Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}}; + I32Init gather_map{{1}, I32Init{}, {0}, {1}, {0, -1, 3, -4}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, NULLIFY, stream, mr.get_output_mr()); - Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - Init{}, - {{Init{0}}}, - {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, Init{}, Init{}}, nulls_at({2, 3})}}; + I32Init expected{ + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + I32Init{}, + {{I32Init{0}}}, + {{{0, 1, 3}, {5}}}, + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, I32Init{}, I32Init{}}, nulls_at({2, 3})}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -351,17 +353,17 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) // List> { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - Init gather_map{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}; + I32Init gather_map{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{4, 5}, {2, 3}}, + I32Init expected{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), @@ -375,19 +377,19 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) // List>, with out-of-bounds gather indices. { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - Init gather_map{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}; + I32Init gather_map{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, NULLIFY, stream, mr.get_output_mr()); - Init expected{{{4, 5}, {2, 3}}, - {{Init{}, {12, 13, 14}, Init{}}, nulls_at({0, 2})}, - {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + I32Init expected{{{4, 5}, {2, 3}}, + {{I32Init{}, {12, 13, 14}, I32Init{}}, nulls_at({0, 2})}, + {{I32Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -407,17 +409,17 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) // List> { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - Init gather_map{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}; + I32Init gather_map{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{4, 5}, {2, 3}}, + I32Init expected{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), @@ -430,19 +432,19 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) // List>, with out-of-bounds gather indices. { // clang-format off - Init list{{{2, 3}, {4, 5}}, + I32Init list{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - Init gather_map{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}; + I32Init gather_map{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, NULLIFY, stream, mr.get_output_mr()); - Init expected{{{4, 5}, {2, 3}}, - {{{9, 10, 11}, {12, 13, 14}, Init{}}, null_at(2)}, - {{Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + I32Init expected{{{4, 5}, {2, 3}}, + {{{9, 10, 11}, {12, 13, 14}, I32Init{}}, null_at(2)}, + {{I32Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -464,20 +466,20 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) // List> { // clang-format off - Init list{{{{2, 3}, valids}, {4, 5}}, + I32Init list{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - Init gather_map{{0, 1}, {0, 2}, Init{}, {0, 1, 4}}; + I32Init gather_map{{0, 1}, {0, 2}, I32Init{}, {0, 1, 4}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{2, 3}, valids}, {4, 5}}, + I32Init expected{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {12, 13, 14}}, no_nulls()}, - Init{}, + I32Init{}, {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), @@ -490,23 +492,23 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) // List>>> { // clang-format off - Init list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + I32Init list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, + {{I32Init{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; - Init gather_map{{1, 2, 4}}; + {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; + I32Init gather_map{{1, 2, 4}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{LCW(gather_map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; + I32Init expected{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{I32Init{0}}}, + {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -523,15 +525,15 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const stream = this->stream(); auto const mr = this->resources(); - Init list{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}; - // Per-row singleton lists: brace LCWs (Init{{0},{0},{0}} flattens to one list of three). + I32Init list{{{2, 3}, I32Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {I32Init{}}}; + // Per-row singleton lists: brace LCWs (I32Init{{0},{0},{0}} flattens to one list of three). auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; auto results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{2, 3}}, {{6, 7, 8}}, {Init{}}}; // skip one null, gather one null. + I32Init expected{{{2, 3}}, {{6, 7, 8}}, {I32Init{}}}; // skip one null, gather one null. CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, @@ -547,7 +549,7 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) auto const mr = this->resources(); { - Init a{ + I32Init a{ {{1, 1, 1}, {2, 2}, {3, 3}}, {{4, 4, 4}, {5, 5}, {6, 6}}, {{7, 7, 7}, {8, 8}, {9, 9}}, @@ -561,7 +563,7 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) auto const split_a = cudf::split(col, {3}, stream); { - Init list{{1, 2}, {0, 2}, {0, 1}}; + I32Init list{{1, 2}, {0, 2}, {0, 1}}; auto const map_col = LCW(list, stream, mr); auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, @@ -569,7 +571,7 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{ + I32Init expected{ {{2, 2}, {3, 3}}, {{4, 4, 4}, {6, 6}}, {{7, 7, 7}, {8, 8}}, @@ -582,7 +584,7 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) } { - Init list{{0, 1}, Init{}, Init{}, {0, 1}, Init{}}; + I32Init list{{0, 1}, I32Init{}, I32Init{}, {0, 1}, I32Init{}}; auto const map_col = LCW(list, stream, mr); auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, @@ -590,7 +592,8 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{10, 10, 10}, {11, 11}}, Init{}, Init{}, {{50, 50, 50, 50}, {6, 13}}, Init{}}; + I32Init expected{ + {{10, 10, 10}, {11, 11}}, I32Init{}, I32Init{}, {{50, 50, 50, 50}, {6, 13}}, I32Init{}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -603,36 +606,37 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // List>> { - Init list{// slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + I32Init list{ + // slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{I32Init{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; + // slice 2 + {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {I32Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; auto const col = LCW(list, stream, mr); auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); // gather from slice 0 { - Init map{{0, 1}}; + I32Init map{{0, 1}}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, cudf::lists_column_view{LCW(map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; + I32Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -643,15 +647,15 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // gather from slice 1 { - Init map{{0}, {1, 2, 0, 1}, {0, 1, 2}}; + I32Init map{{0}, {1, 2, 0, 1}, {0, 1, 2}}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, cudf::lists_column_view{LCW(map, stream, mr)}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{ - {{Init{0}}}, + I32Init expected{ + {{I32Init{0}}}, {{{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}, @@ -670,7 +674,7 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // gather from slice 2 { - Init map{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}; + I32Init map{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}; auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, cudf::lists_column_view{LCW(map, stream, mr)}, @@ -679,20 +683,20 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) mr.get_output_mr()); std::vector expected_valids = {false, true, true, false, false, true}; - Init expected{{{{Init{30}}, - {{{10, 20}, valids}}, - {{{10, 20}, valids}}, - {Init{30}}, - {Init{30}}, - {{{10, 20}, valids}}}, - expected_valids.begin()}, - {{{Init{30}}, - {{10, 20, 30}}, - {{10, 20, 30}}, - {Init{30}}, - {Init{30}}, - {{{20, 30}, valids}, {62, 72, 82}}}, - expected_valids.begin()}}; + I32Init expected{{{{I32Init{30}}, + {{{10, 20}, valids}}, + {{{10, 20}, valids}}, + {I32Init{30}}, + {I32Init{30}}, + {{{10, 20}, valids}}}, + expected_valids.begin()}, + {{{I32Init{30}}, + {{10, 20, 30}}, + {{10, 20, 30}}, + {I32Init{30}}, + {I32Init{30}}, + {{{20, 30}, valids}, {62, 72, 82}}}, + expected_valids.begin()}}; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), result->view(), cudf::test::debug_output_level::FIRST_ERROR, @@ -760,10 +764,10 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) // List { - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}; + I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; + I32Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}; + I32Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}; auto const list_col = LCW(list, stream, mr); auto const gather_map_col = LCW(gather_map, stream, mr); auto const expected_col = LCW(expected, stream, mr); @@ -816,10 +820,10 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) // List, with out-of-bounds gather indices. { - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - Init gather_map{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}; + I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; + I32Init gather_map{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - Init expected{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}; + I32Init expected{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}; auto const list_col = LCW(list, stream, mr); auto const gather_map_col = LCW(gather_map, stream, mr); auto const expected_col = LCW(expected, stream, mr); @@ -879,7 +883,7 @@ TEST_F(SegmentedGatherTestFloat, Fails) auto const mr = this->resources(); // List - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; I8Init size_mismatch_map{{3, 2, 1, 0}, {0}, {0, 1}}; cudf::test::fixed_width_column_wrapper nonlist_map0{{1, 2, 0, 1}, stream, mr}; cudf::test::strings_column_wrapper nonlist_map1{{"1", "2", "0", "1"}, stream, mr}; From 5f7858481bad1ee37623ebfe871068cb15327ec4 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 26 Aug 2026 18:44:05 +0000 Subject: [PATCH 12/21] Split lists column wrapper into separate header --- cpp/include/cudf_test/column_wrapper.hpp | 810 ----------------- .../cudf_test/lists_column_wrapper.hpp | 852 ++++++++++++++++++ .../tests/streaming/test_cudf_utils.cpp | 1 + cpp/tests/column/column_test.cpp | 1 + cpp/tests/column/column_view_shallow_test.cpp | 3 +- cpp/tests/column/factories_test.cpp | 1 + cpp/tests/copying/concatenate_tests.cpp | 1 + .../copying/copy_if_else_nested_tests.cpp | 3 +- cpp/tests/copying/copy_tests.cpp | 3 +- cpp/tests/copying/gather_list_tests.cpp | 1 + cpp/tests/copying/gather_struct_tests.cpp | 3 +- cpp/tests/copying/get_value_tests.cpp | 1 + cpp/tests/copying/pack_tests.cpp | 1 + .../copying/purge_nonempty_nulls_tests.cpp | 1 + .../copying/scatter_list_scalar_tests.cpp | 1 + cpp/tests/copying/scatter_list_tests.cpp | 1 + .../copying/scatter_struct_scalar_tests.cpp | 3 +- cpp/tests/copying/scatter_struct_tests.cpp | 3 +- .../copying/segmented_gather_list_tests.cpp | 1 + cpp/tests/copying/slice_tests.cpp | 1 + cpp/tests/copying/split_tests.cpp | 1 + cpp/tests/copying/utility_tests.cpp | 1 + cpp/tests/groupby/collect_list_tests.cpp | 1 + cpp/tests/groupby/collect_set_tests.cpp | 3 +- cpp/tests/groupby/keys_tests.cpp | 3 +- cpp/tests/groupby/lists_tests.cpp | 3 +- cpp/tests/groupby/max_tests.cpp | 1 + cpp/tests/groupby/merge_lists_tests.cpp | 3 +- cpp/tests/groupby/merge_sets_tests.cpp | 3 +- cpp/tests/groupby/min_tests.cpp | 1 + cpp/tests/groupby/nth_element_tests.cpp | 3 +- cpp/tests/groupby/rank_scan_tests.cpp | 1 + cpp/tests/groupby/replace_nulls_tests.cpp | 3 +- cpp/tests/groupby/structs_tests.cpp | 3 +- cpp/tests/groupby/topk_tests.cpp | 3 +- cpp/tests/hashing/md5_test.cpp | 3 +- cpp/tests/hashing/murmurhash3_x86_32_test.cpp | 1 + cpp/tests/hashing/sha1_test.cpp | 3 +- cpp/tests/hashing/sha224_test.cpp | 3 +- cpp/tests/hashing/sha256_test.cpp | 3 +- cpp/tests/hashing/sha384_test.cpp | 3 +- cpp/tests/hashing/sha512_test.cpp | 3 +- cpp/tests/interop/from_arrow_device_test.cpp | 1 + cpp/tests/interop/from_arrow_host_test.cpp | 1 + cpp/tests/interop/from_arrow_stream_test.cpp | 1 + cpp/tests/interop/from_arrow_test.cpp | 1 + cpp/tests/interop/to_arrow_device_test.cpp | 1 + cpp/tests/interop/to_arrow_host_test.cpp | 1 + cpp/tests/interop/to_arrow_test.cpp | 3 +- cpp/tests/io/cudftable_test.cpp | 1 + .../io/experimental/variant_extract_test.cpp | 1 + cpp/tests/io/json/json_test.cpp | 1 + cpp/tests/io/json/json_writer.cpp | 3 +- cpp/tests/io/orc_chunked_reader_test.cu | 1 + cpp/tests/io/orc_test.cpp | 1 + cpp/tests/io/parquet_chunked_reader_test.cu | 1 + cpp/tests/io/parquet_chunked_writer_test.cpp | 2 + cpp/tests/io/parquet_reader_test.cpp | 1 + cpp/tests/io/parquet_v2_test.cpp | 2 + cpp/tests/io/parquet_writer_test.cpp | 1 + cpp/tests/join/join_tests.cpp | 1 + .../concatenate_list_elements_tests.cpp | 1 + .../lists/combine/concatenate_rows_tests.cpp | 3 +- cpp/tests/lists/contains_tests.cpp | 1 + cpp/tests/lists/count_elements_tests.cpp | 3 +- cpp/tests/lists/explode_tests.cpp | 3 +- cpp/tests/lists/extract_tests.cpp | 3 +- cpp/tests/lists/reverse_tests.cpp | 3 +- cpp/tests/lists/sequences_tests.cpp | 3 +- .../difference_distinct_tests.cpp | 3 +- .../set_operations/have_overlap_tests.cpp | 3 +- .../intersect_distinct_tests.cpp | 3 +- .../set_operations/union_distinct_tests.cpp | 3 +- cpp/tests/lists/sort_lists_tests.cpp | 1 + .../apply_boolean_mask_tests.cpp | 1 + .../stream_compaction/distinct_tests.cpp | 3 +- cpp/tests/merge/merge_test.cpp | 1 + .../partitioning/hash_partition_test.cpp | 1 + cpp/tests/partitioning/partition_test.cpp | 1 + .../quantiles/percentile_approx_test.cpp | 1 + cpp/tests/reductions/collect_ops_tests.cpp | 3 +- cpp/tests/reductions/distinct_count_tests.cpp | 1 + cpp/tests/reductions/list_rank_test.cpp | 1 + cpp/tests/reductions/reduction_tests.cpp | 1 + cpp/tests/reductions/unique_count_tests.cpp | 1 + cpp/tests/reshape/byte_cast_tests.cpp | 1 + .../reshape/interleave_columns_tests.cpp | 3 +- cpp/tests/rolling/collect_ops_test.cpp | 1 + cpp/tests/rolling/empty_input_test.cpp | 3 +- cpp/tests/rolling/lead_lag_test.cpp | 1 + cpp/tests/rolling/offset_row_window_test.cpp | 3 +- .../rolling/range_rolling_window_test.cpp | 1 + cpp/tests/scalar/factories_test.cpp | 1 + cpp/tests/scalar/scalar_test.cpp | 1 + cpp/tests/search/search_list_test.cpp | 3 +- cpp/tests/search/search_struct_test.cpp | 3 +- cpp/tests/sort/is_sorted_tests.cpp | 3 +- cpp/tests/sort/rank_test.cpp | 1 + cpp/tests/sort/sort_nested_types_tests.cpp | 3 +- cpp/tests/sort/sort_test.cpp | 3 +- cpp/tests/sort/top_k_tests.cpp | 1 + .../apply_boolean_mask_tests.cpp | 1 + .../stream_compaction/distinct_tests.cpp | 3 +- .../stable_distinct_tests.cpp | 3 +- cpp/tests/stream_compaction/unique_tests.cpp | 3 +- cpp/tests/streams/copying_test.cpp | 1 + .../io/experimental/hybrid_scan_test.cpp | 3 +- cpp/tests/streams/io/orc_test.cpp | 3 +- cpp/tests/streams/io/parquet_test.cpp | 3 +- cpp/tests/streams/lists_test.cpp | 3 +- cpp/tests/streams/strings/combine_test.cpp | 3 +- cpp/tests/streams/strings/convert_test.cpp | 3 +- .../combine/join_list_elements_tests.cpp | 3 +- cpp/tests/strings/extract_tests.cpp | 1 + cpp/tests/strings/find_multiple_tests.cpp | 1 + cpp/tests/strings/findall_tests.cpp | 1 + cpp/tests/strings/format_lists_tests.cpp | 3 +- cpp/tests/strings/split_tests.cpp | 1 + cpp/tests/structs/structs_column_tests.cpp | 1 + cpp/tests/structs/utilities_tests.cpp | 3 +- cpp/tests/table/table_tests.cpp | 1 + cpp/tests/text/minhash_tests.cpp | 3 +- cpp/tests/text/ngrams_tests.cpp | 1 + cpp/tests/text/subword_tests.cpp | 3 +- cpp/tests/text/tokenize_tests.cpp | 1 + cpp/tests/transform/one_hot_encode_tests.cpp | 3 +- cpp/tests/transform/row_bit_count_test.cu | 1 + cpp/tests/unary/math_ops_test.cpp | 3 +- .../column_utilities_tests.cpp | 1 + .../lists_column_wrapper_tests.cpp | 1 + .../utilities_tests/type_check_tests.cpp | 3 +- 131 files changed, 1043 insertions(+), 870 deletions(-) create mode 100644 cpp/include/cudf_test/lists_column_wrapper.hpp diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 10492aff8136..9d09bd40992e 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -343,173 +343,6 @@ auto make_chars_and_offsets(StringsIterator begin, StringsIterator end, Validity } // namespace detail -// Forward declaration for lists_column_initializer -template -class lists_column_wrapper; - -/** - * @brief Host-side recursive initializer tree for constructing list columns with an - * explicit stream and memory resources at every nesting level. - * - * Prefer this over brace-nested `lists_column_wrapper` constructions that pass - * `stream`/`mr` only at the outer level, which leave brace-constructed children on - * the default test resources. - * - * Example: - * @code{.cpp} - * using Init = cudf::test::lists_column_initializer; - * // List: [{1, 2}, {3}] - * lists_column_wrapper col{Init{{{1, 2}, {3}}}, stream, mr}; - * @endcode - * - * Leaf and nested constructors accept the existing validity iterators - * (`valids`, `null_at(...)`, etc.) and materialize them into owned storage. - * - * @tparam T Host leaf element type (e.g. `int32_t` or `std::string`) - */ -template -class lists_column_initializer { - public: - /** - * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested - * empty `initializer_list` constructors. - */ - lists_column_initializer() = default; - - /** - * @brief Construct a leaf from scalar values. - * - * @param values Leaf element values - */ - lists_column_initializer(std::initializer_list values) : values_{values} {} - - /** - * @brief Construct a leaf from scalar values and a validity iterator. - * - * @tparam ValidityIterator Iterator convertible to `bool` - * @param values Leaf element values - * @param v Validity iterator over `values.size()` elements - */ - template - lists_column_initializer(std::initializer_list values, ValidityIterator v) : values_{values} - { - value_validity_.reserve(values_.size()); - for (std::size_t i = 0; i < values_.size(); ++i) { - value_validity_.push_back(static_cast(*v++)); - } - } - - /** - * @brief Construct a nested node from child initializers. - * - * This constructor is a template so the non-template leaf - * `initializer_list` constructor is preferred for scalar lists such as - * `{1, 2, 3}`. Otherwise both overloads are non-templates and constructing - * `Init` from an `int` via the nested overload recurses until the stack - * overflows. - * - * @param children Child list initializers - */ - template - lists_column_initializer(std::initializer_list children) - requires(std::is_same_v) - : children_{children.begin(), children.end()}, nested_{true} - { - } - - /** - * @brief Construct a nested node from child initializers and a row-validity iterator. - * - * @tparam ValidityIterator Iterator convertible to `bool` - * @param children Child list initializers - * @param v Validity iterator over `children.size()` rows - */ - template - lists_column_initializer(std::initializer_list children, ValidityIterator v) - requires(std::is_same_v && - std::is_convertible_v, bool>) - : nested_{true} - { - children_.reserve(children.size()); - for (auto const& child : children) { - if (static_cast(*v++)) { - children_.push_back(child); - } else { - children_.emplace_back(); - children_.back().valid_ = false; - } - } - } - - /** - * @brief True if this node holds nested child initializers rather than leaf values. - * @return Whether this node is nested - */ - [[nodiscard]] bool nested() const { return nested_; } - /** - * @brief True if this row is valid (non-null) in its parent list. - * @return Whether this row is valid - */ - [[nodiscard]] bool valid() const { return valid_; } - /** - * @brief Leaf element values when `nested()` is false. - * @return Reference to the leaf values - */ - [[nodiscard]] auto const& values() const { return values_; } - /** - * @brief Per-element validity for leaf values; empty when all leaf values are valid. - * @return Reference to the leaf validity mask - */ - [[nodiscard]] auto const& value_validity() const { return value_validity_; } - /** - * @brief Child initializers when `nested()` is true. - * @return Reference to the child initializers - */ - [[nodiscard]] auto const& children() const { return children_; } - - /** - * @brief Recursively build child list wrappers and row validity for a nested node. - * - * Each valid child is allocated with the provided `stream` and `mr`. Null children are - * represented as default-constructed wrappers (skipped during concatenate). - * - * @tparam ElementT List wrapper element type - * @tparam SourceElementT Source type used by the list wrapper - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate child columns - * @return Child wrappers and an empty validity vector when all rows are valid, - * otherwise a validity mask matching `children().size()` - */ - template - [[nodiscard]] std::pair>, - std::vector> - build(cuda::stream_ref stream, cudf::memory_resources mr) const - { - std::vector> children; - std::vector validity; - children.reserve(children_.size()); - validity.reserve(children_.size()); - bool any_null = false; - for (auto const& child : children_) { - any_null = any_null || !child.valid(); - validity.push_back(child.valid()); - if (child.valid()) { - children.emplace_back(child, stream, mr); - } else { - children.emplace_back(); // null rows are skipped during concatenate - } - } - return {std::move(children), any_null ? std::move(validity) : std::vector{}}; - } - - private: - std::vector values_; - std::vector value_validity_; - std::vector children_; - bool nested_{false}; - bool valid_{true}; -}; - /** * @brief `column_wrapper` derived class for wrapping columns of fixed-width * elements. @@ -1609,649 +1442,6 @@ class dictionary_column_wrapper : public detail::column_wrapper { } }; -/** - * @brief `column_wrapper` derived class for wrapping columns of lists. - * - * Important note : due to the way initializer lists work, there is a - * non-obvious behavioral difference when declaring nested empty lists - * in different situations. Specifically, - * - * - When compiled inside of a templated class function (such as a TYPED_TEST - * cudf test wrapper), nested empty lists behave as they read, semantically. - * - * @code{.pseudo} - * lists_column_wrapper col{ {LCW{}} } - * This yields a List> column containing 1 row : a list - * containing an empty list. - * @endcode - * - * - When compiled under other situations (a global function, or a non - * templated class function), the behavior is different. - * - * @code{.pseudo} - * lists_column_wrapper col{ {LCW{}} } - * This yields a List column containing 1 row that is an empty - * list. - * @endcode - * - * This only effects the initial nesting of the empty list. In summary, the - * correct way to declare an "Empty List" in the two cases are: - * - * @code{.pseudo} - * // situation 1 (cudf TYPED_TEST case) - * LCW{} - * // situation 2 (cudf TEST_F case) - * {LCW{}} - * @endcode - */ -template -class lists_column_wrapper : public detail::column_wrapper { - public: - /** - * @brief Cast to lists_column_view - */ - operator lists_column_view() const { return cudf::lists_column_view{wrapped->view()}; } - - /** - * @brief Host-side leaf element type (`std::string` for string lists, else `SourceElementT`). - */ - using host_element_t = - std::conditional_t, std::string, SourceElementT>; - /** - * @brief Column wrapper type used to materialize leaf list contents. - */ - using leaf_wrapper_t = std::conditional_t, - strings_column_wrapper, - fixed_width_column_wrapper>; - - /** - * @brief Construct a lists column containing a single list from an initializer - * list of values. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total integers - * // [{0, 1}] - * lists_column_wrapper l{0, 1}; - * @endcode - * - * These leaf constructors are templates (via `requires`) so that the non-template - * nested `initializer_list` constructor is preferred for - * ambiguous cases such as `lists_column_wrapper{{}, {}}`. - * - * @param elements The list of elements - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width()) - : column_wrapper{} - { - build_from_non_nested( - fixed_width_column_wrapper(elements, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list from an iterator range. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); - * // [{0, 1, 2, 3, 4}] - * lists_column_wrapper l(elements, elements+5); - * @endcode - * - * @param begin Beginning of the sequence - * @param end End of the sequence - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(InputIterator begin, - InputIterator end, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - build_from_non_nested(leaf_wrapper_t(begin, end, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list from an initializer - * list of values and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total integers - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL}] - * lists_column_wrapper l{{0, 1}, validity}; - * @endcode - * - * @param elements The list of elements - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width()) - : column_wrapper{} - { - build_from_non_nested( - fixed_width_column_wrapper(elements, v, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list from an iterator - * range and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL, 2, NULL, 4}] - * lists_column_wrapper l(elements, elements+5, validity); - * @endcode - * - * @param begin Beginning of the sequence - * @param end End of the sequence - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(InputIterator begin, - InputIterator end, - ValidityIterator v, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list of strings. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total strings - * // [{"abc", "def"}] - * lists_column_wrapper s{"abc", "def"}; - * @endcode - * - * @param elements The list of strings - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v) - : column_wrapper{} - { - build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list of strings and a - * validity iterator. - * - * Example: - * @code{.cpp} - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{"abc", NULL}] - * lists_column_wrapper l{{"abc", "def"}, validity}; - * @endcode - * - * @param elements The list of strings - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v) - : column_wrapper{} - { - build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column of nested lists from an initializer list of values. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 3 lists - * // [{0, 1}, {2, 3}, {4, 5}] - * lists_column_wrapper l{ {0, 1}, {2, 3}, {4, 5} }; - * @endcode - * - * Automatically handles nesting - * Example: - * @code{.cpp} - * // Creates a LIST of LIST columns with 2 lists on the top level and - * // 4 below - * // [ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} ] - * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; - * @endcode - * - * For multi-row (and deeper) columns that should allocate with an explicit stream/mr, use - * `lists_column_initializer` so every nesting level receives those arguments: - * `using Init = cudf::test::lists_column_initializer;` - * `lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr};` - * - * @param elements The list of elements - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - lists_column_wrapper(std::initializer_list> elements, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - std::vector valids; - build_from_nested(elements, valids, stream, mr); - } - - /** - * @brief Construct an empty lists column - * - * Example: - * @code{.cpp} - * // Creates an empty LIST column - * // [] - * lists_column_wrapper l{}; - * @endcode - */ - lists_column_wrapper() : column_wrapper{} - { - // Mark as a root so nesting unwraps to the empty child, matching - // build_from_non_nested on an empty leaf. - root = true; - depth = 0; - wrapped = make_empty_lists_column(data_type{type_to_id()}); - } - - /** - * @brief Construct a lists column of nested lists from an initializer list of values - * and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 3 lists - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, 1}, NULL, {4, 5}] - * lists_column_wrapper l{ {{0, 1}, {2, 3}, {4, 5}, validity} }; - * @endcode - * - * Automatically handles nesting - * Example: - * @code{.cpp} - * // Creates a LIST of LIST columns with 2 lists on the top level and - * // 4 below - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [ {{0, 1}, NULL}, {{4, 5}, NULL} ] - * lists_column_wrapper l{ {{{0, 1}, {2, 3}}, validity}, {{{4, 5}, {6, 7}}, validity} }; - * @endcode - * - * @param elements The list of elements - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list> elements, - ValidityIterator v, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - std::vector validity; - std::transform(elements.begin(), - elements.end(), - v, - std::back_inserter(validity), - [](lists_column_wrapper const& l, bool valid) { return valid; }); - build_from_nested(elements, validity, stream, mr); - } - - /** - * @brief Construct a lists column from a recursive `lists_column_initializer` tree. - * - * Every nesting level is allocated with the provided `stream` and `mr`. Prefer this over - * brace-nested `lists_column_wrapper` constructions that pass resources only at the outer - * level. - * - * Example: - * @code{.cpp} - * using Init = cudf::test::lists_column_initializer; - * // List: [{0, 1}, {2, 3}, {4, 5}] - * lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr}; - * - * // List>: [{{0, 1}, {2}}, {{3}}] - * lists_column_wrapper nested{Init{{{{0, 1}, {2}}, {{3}}}}, stream, mr}; - * @endcode - * - * @param init Host-side nested values (and optional validity) - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - lists_column_wrapper(lists_column_initializer init, - rmm::cuda_stream_view stream, - cudf::memory_resources mr) - : column_wrapper{} - { - if (!init.nested()) { - if (init.value_validity().empty()) { - *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); - } else { - *this = lists_column_wrapper( - init.values().begin(), init.values().end(), init.value_validity().begin(), stream, mr); - } - return; - } - - auto [children, validity] = init.template build(stream, mr); - build_from_nested(children, validity, stream, mr); - } - - /** - * @brief Construct a list column containing a single empty, optionally null row. - * - * @param valid Whether or not the empty row is also null - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * @return A list column containing a single empty row - */ - static lists_column_wrapper make_one_empty_row_column( - bool valid = true, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - { - cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); - cudf::test::fixed_width_column_wrapper values{}; - return lists_column_wrapper( - 1, - offsets.release(), - values.release(), - valid ? 0 : 1, - valid ? rmm::device_buffer{} - : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr())); - } - - private: - /** - * @brief Construct a list column from constituent parts. - * - * @param num_rows The number of lists the column represents - * @param offsets The column of offset values for this column - * @param values The column of values bounded by the offsets - * @param null_count The number of null list entries - * @param null_mask The bits specifying the null lists in device memory - */ - lists_column_wrapper(size_type num_rows, - std::unique_ptr&& offsets, - std::unique_ptr&& values, - size_type null_count, - rmm::device_buffer&& null_mask) - { - // construct the list column - wrapped = make_lists_column( - num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); - } - - /** - * @brief Initialize as a nested list column composed of other list columns. - * - * This function handles a special case. For convenience of declaration, we want to treat these - * two cases as equivalent - * - * List = { 0, 1 } - * List = { {0, 1} } - * - * while at the same time, allowing further nesting - * List = { {{0, 1}} } - * - * @param elements Input columns to be wrapped - * @param v The validity of each row - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * - */ - template - void build_from_nested(ListsRange const& elements, - std::vector const& v, - rmm::cuda_stream_view stream, - cudf::memory_resources mr) - { - auto valids = cudf::detail::make_counting_transform_iterator( - 0, [&v](auto i) { return v.empty() ? true : v[i]; }); - - // compute the expected hierarchy and depth - auto const hierarchy_and_depth = - std::accumulate(elements.begin(), - elements.end(), - std::pair{{}, -1}, - [](auto acc, lists_column_wrapper const& lcw) { - return lcw.depth > acc.second ? std::pair(lcw.get_view(), lcw.depth) : acc; - }); - column_view expected_hierarchy = hierarchy_and_depth.first; - int32_t const expected_depth = hierarchy_and_depth.second; - - // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy - auto [cols, stubs] = preprocess_columns( - elements, expected_hierarchy, expected_depth, stream, mr.get_temporary_mr()); - - // generate offsets - size_type count = 0; - std::vector offsetv; - std::transform(cols.cbegin(), - cols.cend(), - valids, - std::back_inserter(offsetv), - [&](cudf::column_view const& col, bool valid) { - // nulls are represented as a repeated offset - size_type ret = count; - if (valid) { count += col.size(); } - return ret; - }); - // add the final offset - offsetv.push_back(count); - auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) - .release(); - - // concatenate them together, skipping children that are null. - std::vector children; - thrust::copy_if(std::cbegin(cols), - std::cend(cols), - valids, - std::back_inserter(children), - cuda::std::identity{}); - - auto data = children.empty() ? cudf::empty_like(expected_hierarchy) - : cudf::concatenate(children, stream, mr.get_output_mr()); - - // increment depth - depth = expected_depth + 1; - - auto [null_mask, null_count] = [&] { - if (v.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); - return cudf::test::detail::make_null_mask(v.begin(), v.end(), stream, mr); - }(); - - // construct the list column - wrapped = make_lists_column( - cols.size(), std::move(offsets), std::move(data), null_count, std::move(null_mask)); - } - - /** - * @brief Initialize as a "root" list column from a non-list input column. Root columns - * will be "unwrapped" when used in the nesting (list of lists) case. - * - * @param c Input column to be wrapped - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * - */ - void build_from_non_nested(std::unique_ptr c, - rmm::cuda_stream_view stream, - cudf::memory_resources mr) - { - CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), - "Unexpected type"); - - std::vector offsetv; - if (c->size() > 0) { - offsetv.push_back(0); - offsetv.push_back(c->size()); - } - auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) - .release(); - - // construct the list column. mark this as a root - root = true; - depth = 0; - - size_type num_elements = offsets->size() == 0 ? 0 : offsets->size() - 1; - wrapped = - make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{}); - } - - /** - * @brief Given an input column that may be an "incomplete hierarchy" due to being empty - * at a level before the leaf, normalize it so that it matches the expected hierarchy of - * sibling columns. - * - * cudf functions that handle lists expect that all columns are fully formed hierarchies, - * even if they are empty somewhere in the middle of the hierarchy. - * If we had the following lists_column_wrapper declaration: - * - * @code{.pseudo} - * [ {{{1, 2, 3}}}, {} ] - * Row 0 in this case is a List>>, where row 1 appears to be just a List<>. - * @endcode - * - * These two columns will end up getting passed to cudf::concatenate() to merge. But - * concatenate() will throw an exception because row 1 will appear to have a child type - * of nothing, while row 0 will appear to have a child type of List>. - * To handle this cleanly, we want to "normalize" row 1 so that it appears as a - * List>> column even though it has 0 elements at the top level. - * - * This function also detects the case where the user has constructed a truly invalid - * pair of columns, such as - * - * @code{.pseudo} - * [ {{{1, 2, 3}}}, {4, 5} ] - * Row 0 in this case is a List>>, and row 1 is a concrete List with - * elements. This is purely an invalid way of constructing a lists column. - * @endcode - * - * @param col Input column to be normalized - * @param expected_hierarchy Input column which represents the expected hierarchy - * @param stream CUDA stream used for device memory operations - * @param temp_mr Device memory resource used for temporary normalized copies - * - * @return A new column representing a normalized copy of col - */ - std::unique_ptr normalize_column(column_view const& col, - column_view const& expected_hierarchy, - rmm::cuda_stream_view stream, - rmm::device_async_resource_ref temp_mr) - { - // if are at the bottom of the short column, it must be empty - if (col.type().id() != type_id::LIST) { - CUDF_EXPECTS(col.is_empty(), "Encountered mismatched column!"); - - auto remainder = empty_like(expected_hierarchy); - return remainder; - } - - lists_column_view lcv(col); - return make_lists_column(col.size(), - std::make_unique(lcv.offsets(), stream, temp_mr), - normalize_column(lists_column_view(col).child(), - lists_column_view(expected_hierarchy).child(), - stream, - temp_mr), - col.null_count(), - cudf::copy_bitmask(col, stream, temp_mr)); - } - - template - std::pair, std::vector>> preprocess_columns( - ListsRange const& elements, - column_view& expected_hierarchy, - int expected_depth, - rmm::cuda_stream_view stream, - rmm::device_async_resource_ref temp_mr) - { - std::vector> stubs; - std::vector cols; - - // preprocess the incoming lists. - // - unwrap any "root" lists - // - handle incomplete hierarchies - std::transform( - elements.begin(), - elements.end(), - std::back_inserter(cols), - [&](lists_column_wrapper const& l) -> column_view { - // depth mismatch. attempt to normalize the short column. - // this function will also catch if this is a legitimately broken - // set of input - if (l.depth < expected_depth) { - if (l.root) { - // this exception distinguishes between the following two cases: - // - // { {{{1, 2, 3}}}, {} } - // In this case, row 0 is a List>>, whereas row 1 is - // just a List<> which is an apparent mismatch. However, because row 1 - // is empty we will allow that to semantically mean - // "a List>> that's empty at the top level" - // - // { {{{1, 2, 3}}}, {4, 5, 6} } - // In this case, row 1 is a concrete List with actual values. - // There is no way to rectify the differences so we will treat it as a - // true column mismatch. - CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); - stubs.push_back(empty_like(expected_hierarchy)); - } else { - stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, temp_mr)); - } - return *(stubs.back()); - } - // the empty hierarchy case - return l.get_view(); - }); - - return {std::move(cols), std::move(stubs)}; - } - - [[nodiscard]] column_view get_view() const - { - return root ? lists_column_view(*wrapped).child() : *wrapped; - } - - int depth = 0; - bool root = false; -}; - /** * @brief True when `T` is convertible to `rmm::cuda_stream_view`. */ diff --git a/cpp/include/cudf_test/lists_column_wrapper.hpp b/cpp/include/cudf_test/lists_column_wrapper.hpp new file mode 100644 index 000000000000..9532733c25e8 --- /dev/null +++ b/cpp/include/cudf_test/lists_column_wrapper.hpp @@ -0,0 +1,852 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace CUDF_EXPORT cudf { +namespace test { + +// Forward declaration for lists_column_initializer +template +class lists_column_wrapper; + +/** + * @brief Host-side recursive initializer tree for constructing list columns with an + * explicit stream and memory resources at every nesting level. + * + * Prefer this over brace-nested `lists_column_wrapper` constructions that pass + * `stream`/`mr` only at the outer level, which leave brace-constructed children on + * the default test resources. + * + * Example: + * @code{.cpp} + * using Init = cudf::test::lists_column_initializer; + * // List: [{1, 2}, {3}] + * lists_column_wrapper col{Init{{{1, 2}, {3}}}, stream, mr}; + * @endcode + * + * Leaf and nested constructors accept the existing validity iterators + * (`valids`, `null_at(...)`, etc.) and materialize them into owned storage. + * + * @tparam T Host leaf element type (e.g. `int32_t` or `std::string`) + */ +template +class lists_column_initializer { + public: + /** + * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested + * empty `initializer_list` constructors. + */ + lists_column_initializer() = default; + + /** + * @brief Construct a leaf from scalar values. + * + * @param values Leaf element values + */ + lists_column_initializer(std::initializer_list values) : values_{values} {} + + /** + * @brief Construct a leaf from scalar values and a validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param values Leaf element values + * @param v Validity iterator over `values.size()` elements + */ + template + lists_column_initializer(std::initializer_list values, ValidityIterator v) : values_{values} + { + value_validity_.reserve(values_.size()); + for (std::size_t i = 0; i < values_.size(); ++i) { + value_validity_.push_back(static_cast(*v++)); + } + } + + /** + * @brief Construct a nested node from child initializers. + * + * This constructor is a template so the non-template leaf + * `initializer_list` constructor is preferred for scalar lists such as + * `{1, 2, 3}`. Otherwise both overloads are non-templates and constructing + * `Init` from an `int` via the nested overload recurses until the stack + * overflows. + * + * @param children Child list initializers + */ + template + lists_column_initializer(std::initializer_list children) + requires(std::is_same_v) + : children_{children.begin(), children.end()}, nested_{true} + { + } + + /** + * @brief Construct a nested node from child initializers and a row-validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param children Child list initializers + * @param v Validity iterator over `children.size()` rows + */ + template + lists_column_initializer(std::initializer_list children, ValidityIterator v) + requires(std::is_same_v && + std::is_convertible_v, bool>) + : nested_{true} + { + children_.reserve(children.size()); + for (auto const& child : children) { + if (static_cast(*v++)) { + children_.push_back(child); + } else { + children_.emplace_back(); + children_.back().valid_ = false; + } + } + } + + /** + * @brief True if this node holds nested child initializers rather than leaf values. + * @return Whether this node is nested + */ + [[nodiscard]] bool nested() const { return nested_; } + /** + * @brief True if this row is valid (non-null) in its parent list. + * @return Whether this row is valid + */ + [[nodiscard]] bool valid() const { return valid_; } + /** + * @brief Leaf element values when `nested()` is false. + * @return Reference to the leaf values + */ + [[nodiscard]] auto const& values() const { return values_; } + /** + * @brief Per-element validity for leaf values; empty when all leaf values are valid. + * @return Reference to the leaf validity mask + */ + [[nodiscard]] auto const& value_validity() const { return value_validity_; } + /** + * @brief Child initializers when `nested()` is true. + * @return Reference to the child initializers + */ + [[nodiscard]] auto const& children() const { return children_; } + + /** + * @brief Recursively build child list wrappers and row validity for a nested node. + * + * Each valid child is allocated with the provided `stream` and `mr`. Null children are + * represented as default-constructed wrappers (skipped during concatenate). + * + * @tparam ElementT List wrapper element type + * @tparam SourceElementT Source type used by the list wrapper + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate child columns + * @return Child wrappers and an empty validity vector when all rows are valid, + * otherwise a validity mask matching `children().size()` + */ + template + [[nodiscard]] std::pair>, + std::vector> + build(cuda::stream_ref stream, cudf::memory_resources mr) const + { + std::vector> children; + std::vector validity; + children.reserve(children_.size()); + validity.reserve(children_.size()); + bool any_null = false; + for (auto const& child : children_) { + any_null = any_null || !child.valid(); + validity.push_back(child.valid()); + if (child.valid()) { + children.emplace_back(child, stream, mr); + } else { + children.emplace_back(); // null rows are skipped during concatenate + } + } + return {std::move(children), any_null ? std::move(validity) : std::vector{}}; + } + + private: + std::vector values_; + std::vector value_validity_; + std::vector children_; + bool nested_{false}; + bool valid_{true}; +}; + +/** + * @brief `column_wrapper` derived class for wrapping columns of lists. + * + * Important note : due to the way initializer lists work, there is a + * non-obvious behavioral difference when declaring nested empty lists + * in different situations. Specifically, + * + * - When compiled inside of a templated class function (such as a TYPED_TEST + * cudf test wrapper), nested empty lists behave as they read, semantically. + * + * @code{.pseudo} + * lists_column_wrapper col{ {LCW{}} } + * This yields a List> column containing 1 row : a list + * containing an empty list. + * @endcode + * + * - When compiled under other situations (a global function, or a non + * templated class function), the behavior is different. + * + * @code{.pseudo} + * lists_column_wrapper col{ {LCW{}} } + * This yields a List column containing 1 row that is an empty + * list. + * @endcode + * + * This only effects the initial nesting of the empty list. In summary, the + * correct way to declare an "Empty List" in the two cases are: + * + * @code{.pseudo} + * // situation 1 (cudf TYPED_TEST case) + * LCW{} + * // situation 2 (cudf TEST_F case) + * {LCW{}} + * @endcode + */ +template +class lists_column_wrapper : public detail::column_wrapper { + public: + /** + * @brief Cast to lists_column_view + */ + operator lists_column_view() const { return cudf::lists_column_view{wrapped->view()}; } + + /** + * @brief Host-side leaf element type (`std::string` for string lists, else `SourceElementT`). + */ + using host_element_t = + std::conditional_t, std::string, SourceElementT>; + /** + * @brief Column wrapper type used to materialize leaf list contents. + */ + using leaf_wrapper_t = std::conditional_t, + strings_column_wrapper, + fixed_width_column_wrapper>; + + /** + * @brief Construct a lists column containing a single list from an initializer + * list of values. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total integers + * // [{0, 1}] + * lists_column_wrapper l{0, 1}; + * @endcode + * + * These leaf constructors are templates (via `requires`) so that the non-template + * nested `initializer_list` constructor is preferred for + * ambiguous cases such as `lists_column_wrapper{{}, {}}`. + * + * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width()) + : column_wrapper{} + { + build_from_non_nested( + fixed_width_column_wrapper(elements, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list from an iterator range. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * // [{0, 1, 2, 3, 4}] + * lists_column_wrapper l(elements, elements+5); + * @endcode + * + * @param begin Beginning of the sequence + * @param end End of the sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + build_from_non_nested(leaf_wrapper_t(begin, end, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list from an initializer + * list of values and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total integers + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, NULL}] + * lists_column_wrapper l{{0, 1}, validity}; + * @endcode + * + * @param elements The list of elements + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width()) + : column_wrapper{} + { + build_from_non_nested( + fixed_width_column_wrapper(elements, v, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list from an iterator + * range and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, NULL, 2, NULL, 4}] + * lists_column_wrapper l(elements, elements+5, validity); + * @endcode + * + * @param begin Beginning of the sequence + * @param end End of the sequence + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(InputIterator begin, + InputIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list of strings. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total strings + * // [{"abc", "def"}] + * lists_column_wrapper s{"abc", "def"}; + * @endcode + * + * @param elements The list of strings + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v) + : column_wrapper{} + { + build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list of strings and a + * validity iterator. + * + * Example: + * @code{.cpp} + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{"abc", NULL}] + * lists_column_wrapper l{{"abc", "def"}, validity}; + * @endcode + * + * @param elements The list of strings + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v) + : column_wrapper{} + { + build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column of nested lists from an initializer list of values. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 3 lists + * // [{0, 1}, {2, 3}, {4, 5}] + * lists_column_wrapper l{ {0, 1}, {2, 3}, {4, 5} }; + * @endcode + * + * Automatically handles nesting + * Example: + * @code{.cpp} + * // Creates a LIST of LIST columns with 2 lists on the top level and + * // 4 below + * // [ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} ] + * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; + * @endcode + * + * For multi-row (and deeper) columns that should allocate with an explicit stream/mr, use + * `lists_column_initializer` so every nesting level receives those arguments: + * `using Init = cudf::test::lists_column_initializer;` + * `lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr};` + * + * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(std::initializer_list> elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + std::vector valids; + build_from_nested(elements, valids, stream, mr); + } + + /** + * @brief Construct an empty lists column + * + * Example: + * @code{.cpp} + * // Creates an empty LIST column + * // [] + * lists_column_wrapper l{}; + * @endcode + */ + lists_column_wrapper() : column_wrapper{} + { + // Mark as a root so nesting unwraps to the empty child, matching + // build_from_non_nested on an empty leaf. + root = true; + depth = 0; + wrapped = make_empty_lists_column(data_type{type_to_id()}); + } + + /** + * @brief Construct a lists column of nested lists from an initializer list of values + * and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 3 lists + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, 1}, NULL, {4, 5}] + * lists_column_wrapper l{ {{0, 1}, {2, 3}, {4, 5}, validity} }; + * @endcode + * + * Automatically handles nesting + * Example: + * @code{.cpp} + * // Creates a LIST of LIST columns with 2 lists on the top level and + * // 4 below + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [ {{0, 1}, NULL}, {{4, 5}, NULL} ] + * lists_column_wrapper l{ {{{0, 1}, {2, 3}}, validity}, {{{4, 5}, {6, 7}}, validity} }; + * @endcode + * + * @param elements The list of elements + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list> elements, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + std::vector validity; + std::transform(elements.begin(), + elements.end(), + v, + std::back_inserter(validity), + [](lists_column_wrapper const& l, bool valid) { return valid; }); + build_from_nested(elements, validity, stream, mr); + } + + /** + * @brief Construct a lists column from a recursive `lists_column_initializer` tree. + * + * Every nesting level is allocated with the provided `stream` and `mr`. Prefer this over + * brace-nested `lists_column_wrapper` constructions that pass resources only at the outer + * level. + * + * Example: + * @code{.cpp} + * using Init = cudf::test::lists_column_initializer; + * // List: [{0, 1}, {2, 3}, {4, 5}] + * lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr}; + * + * // List>: [{{0, 1}, {2}}, {{3}}] + * lists_column_wrapper nested{Init{{{{0, 1}, {2}}, {{3}}}}, stream, mr}; + * @endcode + * + * @param init Host-side nested values (and optional validity) + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(lists_column_initializer init, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) + : column_wrapper{} + { + if (!init.nested()) { + if (init.value_validity().empty()) { + *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); + } else { + *this = lists_column_wrapper( + init.values().begin(), init.values().end(), init.value_validity().begin(), stream, mr); + } + return; + } + + auto [children, validity] = init.template build(stream, mr); + build_from_nested(children, validity, stream, mr); + } + + /** + * @brief Construct a list column containing a single empty, optionally null row. + * + * @param valid Whether or not the empty row is also null + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * @return A list column containing a single empty row + */ + static lists_column_wrapper make_one_empty_row_column( + bool valid = true, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + { + cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); + cudf::test::fixed_width_column_wrapper values{}; + return lists_column_wrapper( + 1, + offsets.release(), + values.release(), + valid ? 0 : 1, + valid ? rmm::device_buffer{} + : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr())); + } + + private: + /** + * @brief Construct a list column from constituent parts. + * + * @param num_rows The number of lists the column represents + * @param offsets The column of offset values for this column + * @param values The column of values bounded by the offsets + * @param null_count The number of null list entries + * @param null_mask The bits specifying the null lists in device memory + */ + lists_column_wrapper(size_type num_rows, + std::unique_ptr&& offsets, + std::unique_ptr&& values, + size_type null_count, + rmm::device_buffer&& null_mask) + { + // construct the list column + wrapped = make_lists_column( + num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); + } + + /** + * @brief Initialize as a nested list column composed of other list columns. + * + * This function handles a special case. For convenience of declaration, we want to treat these + * two cases as equivalent + * + * List = { 0, 1 } + * List = { {0, 1} } + * + * while at the same time, allowing further nesting + * List = { {{0, 1}} } + * + * @param elements Input columns to be wrapped + * @param v The validity of each row + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * + */ + template + void build_from_nested(ListsRange const& elements, + std::vector const& v, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) + { + auto valids = cudf::detail::make_counting_transform_iterator( + 0, [&v](auto i) { return v.empty() ? true : v[i]; }); + + // compute the expected hierarchy and depth + auto const hierarchy_and_depth = + std::accumulate(elements.begin(), + elements.end(), + std::pair{{}, -1}, + [](auto acc, lists_column_wrapper const& lcw) { + return lcw.depth > acc.second ? std::pair(lcw.get_view(), lcw.depth) : acc; + }); + column_view expected_hierarchy = hierarchy_and_depth.first; + int32_t const expected_depth = hierarchy_and_depth.second; + + // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy + auto [cols, stubs] = preprocess_columns( + elements, expected_hierarchy, expected_depth, stream, mr.get_temporary_mr()); + + // generate offsets + size_type count = 0; + std::vector offsetv; + std::transform(cols.cbegin(), + cols.cend(), + valids, + std::back_inserter(offsetv), + [&](cudf::column_view const& col, bool valid) { + // nulls are represented as a repeated offset + size_type ret = count; + if (valid) { count += col.size(); } + return ret; + }); + // add the final offset + offsetv.push_back(count); + auto offsets = + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); + + // concatenate them together, skipping children that are null. + std::vector children; + thrust::copy_if(std::cbegin(cols), + std::cend(cols), + valids, + std::back_inserter(children), + cuda::std::identity{}); + + auto data = children.empty() ? cudf::empty_like(expected_hierarchy) + : cudf::concatenate(children, stream, mr.get_output_mr()); + + // increment depth + depth = expected_depth + 1; + + auto [null_mask, null_count] = [&] { + if (v.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); + return cudf::test::detail::make_null_mask(v.begin(), v.end(), stream, mr); + }(); + + // construct the list column + wrapped = make_lists_column( + cols.size(), std::move(offsets), std::move(data), null_count, std::move(null_mask)); + } + + /** + * @brief Initialize as a "root" list column from a non-list input column. Root columns + * will be "unwrapped" when used in the nesting (list of lists) case. + * + * @param c Input column to be wrapped + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * + */ + void build_from_non_nested(std::unique_ptr c, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) + { + CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), + "Unexpected type"); + + std::vector offsetv; + if (c->size() > 0) { + offsetv.push_back(0); + offsetv.push_back(c->size()); + } + auto offsets = + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); + + // construct the list column. mark this as a root + root = true; + depth = 0; + + size_type num_elements = offsets->size() == 0 ? 0 : offsets->size() - 1; + wrapped = + make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{}); + } + + /** + * @brief Given an input column that may be an "incomplete hierarchy" due to being empty + * at a level before the leaf, normalize it so that it matches the expected hierarchy of + * sibling columns. + * + * cudf functions that handle lists expect that all columns are fully formed hierarchies, + * even if they are empty somewhere in the middle of the hierarchy. + * If we had the following lists_column_wrapper declaration: + * + * @code{.pseudo} + * [ {{{1, 2, 3}}}, {} ] + * Row 0 in this case is a List>>, where row 1 appears to be just a List<>. + * @endcode + * + * These two columns will end up getting passed to cudf::concatenate() to merge. But + * concatenate() will throw an exception because row 1 will appear to have a child type + * of nothing, while row 0 will appear to have a child type of List>. + * To handle this cleanly, we want to "normalize" row 1 so that it appears as a + * List>> column even though it has 0 elements at the top level. + * + * This function also detects the case where the user has constructed a truly invalid + * pair of columns, such as + * + * @code{.pseudo} + * [ {{{1, 2, 3}}}, {4, 5} ] + * Row 0 in this case is a List>>, and row 1 is a concrete List with + * elements. This is purely an invalid way of constructing a lists column. + * @endcode + * + * @param col Input column to be normalized + * @param expected_hierarchy Input column which represents the expected hierarchy + * @param stream CUDA stream used for device memory operations + * @param temp_mr Device memory resource used for temporary normalized copies + * + * @return A new column representing a normalized copy of col + */ + std::unique_ptr normalize_column(column_view const& col, + column_view const& expected_hierarchy, + rmm::cuda_stream_view stream, + rmm::device_async_resource_ref temp_mr) + { + // if are at the bottom of the short column, it must be empty + if (col.type().id() != type_id::LIST) { + CUDF_EXPECTS(col.is_empty(), "Encountered mismatched column!"); + + auto remainder = empty_like(expected_hierarchy); + return remainder; + } + + lists_column_view lcv(col); + return make_lists_column(col.size(), + std::make_unique(lcv.offsets(), stream, temp_mr), + normalize_column(lists_column_view(col).child(), + lists_column_view(expected_hierarchy).child(), + stream, + temp_mr), + col.null_count(), + cudf::copy_bitmask(col, stream, temp_mr)); + } + + template + std::pair, std::vector>> preprocess_columns( + ListsRange const& elements, + column_view& expected_hierarchy, + int expected_depth, + rmm::cuda_stream_view stream, + rmm::device_async_resource_ref temp_mr) + { + std::vector> stubs; + std::vector cols; + + // preprocess the incoming lists. + // - unwrap any "root" lists + // - handle incomplete hierarchies + std::transform( + elements.begin(), + elements.end(), + std::back_inserter(cols), + [&](lists_column_wrapper const& l) -> column_view { + // depth mismatch. attempt to normalize the short column. + // this function will also catch if this is a legitimately broken + // set of input + if (l.depth < expected_depth) { + if (l.root) { + // this exception distinguishes between the following two cases: + // + // { {{{1, 2, 3}}}, {} } + // In this case, row 0 is a List>>, whereas row 1 is + // just a List<> which is an apparent mismatch. However, because row 1 + // is empty we will allow that to semantically mean + // "a List>> that's empty at the top level" + // + // { {{{1, 2, 3}}}, {4, 5, 6} } + // In this case, row 1 is a concrete List with actual values. + // There is no way to rectify the differences so we will treat it as a + // true column mismatch. + CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); + stubs.push_back(empty_like(expected_hierarchy)); + } else { + stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, temp_mr)); + } + return *(stubs.back()); + } + // the empty hierarchy case + return l.get_view(); + }); + + return {std::move(cols), std::move(stubs)}; + } + + [[nodiscard]] column_view get_view() const + { + return root ? lists_column_view(*wrapped).child() : *wrapped; + } + + int depth = 0; + bool root = false; +}; + +} // namespace test +} // namespace CUDF_EXPORT cudf diff --git a/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp b/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp index a9e4b5b5219f..bc1cc23a9f43 100644 --- a/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp +++ b/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include diff --git a/cpp/tests/column/column_test.cpp b/cpp/tests/column/column_test.cpp index d7aade39aef4..e564fd73fbe2 100644 --- a/cpp/tests/column/column_test.cpp +++ b/cpp/tests/column/column_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/column/column_view_shallow_test.cpp b/cpp/tests/column/column_view_shallow_test.cpp index af56e8ef3ced..491a6ce735d7 100644 --- a/cpp/tests/column/column_view_shallow_test.cpp +++ b/cpp/tests/column/column_view_shallow_test.cpp @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include +#include #include #include diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index 3e5384a38bb4..9c8a85379c1b 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index e23bf57c3216..d4ca3a8b94be 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/copying/copy_if_else_nested_tests.cpp b/cpp/tests/copying/copy_if_else_nested_tests.cpp index 6dd50754dab0..59c000e20fbe 100644 --- a/cpp/tests/copying/copy_if_else_nested_tests.cpp +++ b/cpp/tests/copying/copy_if_else_nested_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/copy_tests.cpp b/cpp/tests/copying/copy_tests.cpp index 47828562e7bb..3df2a3e24c8c 100644 --- a/cpp/tests/copying/copy_tests.cpp +++ b/cpp/tests/copying/copy_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index f35e77babe0e..307af4687ab9 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/gather_struct_tests.cpp b/cpp/tests/copying/gather_struct_tests.cpp index e3b0dd9bee07..f70e27233ccd 100644 --- a/cpp/tests/copying/gather_struct_tests.cpp +++ b/cpp/tests/copying/gather_struct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/get_value_tests.cpp b/cpp/tests/copying/get_value_tests.cpp index f2e9107ca452..4968fc03d133 100644 --- a/cpp/tests/copying/get_value_tests.cpp +++ b/cpp/tests/copying/get_value_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/pack_tests.cpp b/cpp/tests/copying/pack_tests.cpp index 9f701ac1245d..7544814884c3 100644 --- a/cpp/tests/copying/pack_tests.cpp +++ b/cpp/tests/copying/pack_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp index 4650de9ee092..e7c6c6766dc4 100644 --- a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp +++ b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/scatter_list_scalar_tests.cpp b/cpp/tests/copying/scatter_list_scalar_tests.cpp index b0b56f084a65..205d1c30773e 100644 --- a/cpp/tests/copying/scatter_list_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_list_scalar_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/scatter_list_tests.cpp b/cpp/tests/copying/scatter_list_tests.cpp index 083e5fecf680..167796e73d3d 100644 --- a/cpp/tests/copying/scatter_list_tests.cpp +++ b/cpp/tests/copying/scatter_list_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/scatter_struct_scalar_tests.cpp b/cpp/tests/copying/scatter_struct_scalar_tests.cpp index 7021bd7b6699..abfede8587e1 100644 --- a/cpp/tests/copying/scatter_struct_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_struct_scalar_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/scatter_struct_tests.cpp b/cpp/tests/copying/scatter_struct_tests.cpp index 8139990de85b..bbfbed13408f 100644 --- a/cpp/tests/copying/scatter_struct_tests.cpp +++ b/cpp/tests/copying/scatter_struct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 69ecd89568aa..2de5030cb98d 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/slice_tests.cpp b/cpp/tests/copying/slice_tests.cpp index e3ad84b14e21..89dff78a243c 100644 --- a/cpp/tests/copying/slice_tests.cpp +++ b/cpp/tests/copying/slice_tests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index 5ff460b4f2d0..8ddc4edbfd61 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/copying/utility_tests.cpp b/cpp/tests/copying/utility_tests.cpp index 45cf58cab6ae..6d79f4590625 100644 --- a/cpp/tests/copying/utility_tests.cpp +++ b/cpp/tests/copying/utility_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/groupby/collect_list_tests.cpp b/cpp/tests/groupby/collect_list_tests.cpp index 601ed4e9736a..2a7ca950ff52 100644 --- a/cpp/tests/groupby/collect_list_tests.cpp +++ b/cpp/tests/groupby/collect_list_tests.cpp @@ -7,6 +7,7 @@ #include #include +#include #include template diff --git a/cpp/tests/groupby/collect_set_tests.cpp b/cpp/tests/groupby/collect_set_tests.cpp index ec8c0c693255..ddcedc49e22d 100644 --- a/cpp/tests/groupby/collect_set_tests.cpp +++ b/cpp/tests/groupby/collect_set_tests.cpp @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include +#include #include #include diff --git a/cpp/tests/groupby/keys_tests.cpp b/cpp/tests/groupby/keys_tests.cpp index f97ee317dbb1..18fabef769fd 100644 --- a/cpp/tests/groupby/keys_tests.cpp +++ b/cpp/tests/groupby/keys_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/lists_tests.cpp b/cpp/tests/groupby/lists_tests.cpp index f6a7131efaff..12e011e46323 100644 --- a/cpp/tests/groupby/lists_tests.cpp +++ b/cpp/tests/groupby/lists_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/max_tests.cpp b/cpp/tests/groupby/max_tests.cpp index 538a11ba2039..52f57d08e299 100644 --- a/cpp/tests/groupby/max_tests.cpp +++ b/cpp/tests/groupby/max_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/merge_lists_tests.cpp b/cpp/tests/groupby/merge_lists_tests.cpp index 24c269c11b97..24b28f8509f1 100644 --- a/cpp/tests/groupby/merge_lists_tests.cpp +++ b/cpp/tests/groupby/merge_lists_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/merge_sets_tests.cpp b/cpp/tests/groupby/merge_sets_tests.cpp index 1304732a7313..17a28dd6a458 100644 --- a/cpp/tests/groupby/merge_sets_tests.cpp +++ b/cpp/tests/groupby/merge_sets_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/min_tests.cpp b/cpp/tests/groupby/min_tests.cpp index 8f59f8b59cf2..13fc11774eef 100644 --- a/cpp/tests/groupby/min_tests.cpp +++ b/cpp/tests/groupby/min_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/nth_element_tests.cpp b/cpp/tests/groupby/nth_element_tests.cpp index 4e5b8a4a9fcb..48fb58c5d7a0 100644 --- a/cpp/tests/groupby/nth_element_tests.cpp +++ b/cpp/tests/groupby/nth_element_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/rank_scan_tests.cpp b/cpp/tests/groupby/rank_scan_tests.cpp index b0d3a8443a38..36cbfa532b20 100644 --- a/cpp/tests/groupby/rank_scan_tests.cpp +++ b/cpp/tests/groupby/rank_scan_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/replace_nulls_tests.cpp b/cpp/tests/groupby/replace_nulls_tests.cpp index 5d3e938cdbe0..fe2106ff3cdf 100644 --- a/cpp/tests/groupby/replace_nulls_tests.cpp +++ b/cpp/tests/groupby/replace_nulls_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/structs_tests.cpp b/cpp/tests/groupby/structs_tests.cpp index 802209365745..13af4124f5ee 100644 --- a/cpp/tests/groupby/structs_tests.cpp +++ b/cpp/tests/groupby/structs_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/groupby/topk_tests.cpp b/cpp/tests/groupby/topk_tests.cpp index 5e923e986c80..c462685f59ec 100644 --- a/cpp/tests/groupby/topk_tests.cpp +++ b/cpp/tests/groupby/topk_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,7 @@ #include #include #include +#include #include template diff --git a/cpp/tests/hashing/md5_test.cpp b/cpp/tests/hashing/md5_test.cpp index 013e2189c4aa..6bca307e122d 100644 --- a/cpp/tests/hashing/md5_test.cpp +++ b/cpp/tests/hashing/md5_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/murmurhash3_x86_32_test.cpp b/cpp/tests/hashing/murmurhash3_x86_32_test.cpp index 6ce28ee7f4b0..bef8bd35332d 100644 --- a/cpp/tests/hashing/murmurhash3_x86_32_test.cpp +++ b/cpp/tests/hashing/murmurhash3_x86_32_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/sha1_test.cpp b/cpp/tests/hashing/sha1_test.cpp index 6b9bb841d2dd..cee1418e44ca 100644 --- a/cpp/tests/hashing/sha1_test.cpp +++ b/cpp/tests/hashing/sha1_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/sha224_test.cpp b/cpp/tests/hashing/sha224_test.cpp index 2269a5eb9b57..2c4d161e3b67 100644 --- a/cpp/tests/hashing/sha224_test.cpp +++ b/cpp/tests/hashing/sha224_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/sha256_test.cpp b/cpp/tests/hashing/sha256_test.cpp index 9a260cb13c77..be5c8884f0e9 100644 --- a/cpp/tests/hashing/sha256_test.cpp +++ b/cpp/tests/hashing/sha256_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/sha384_test.cpp b/cpp/tests/hashing/sha384_test.cpp index 48f508a6df06..54fdd85a58fc 100644 --- a/cpp/tests/hashing/sha384_test.cpp +++ b/cpp/tests/hashing/sha384_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/hashing/sha512_test.cpp b/cpp/tests/hashing/sha512_test.cpp index 7f76f13c5501..8c0a880d0da2 100644 --- a/cpp/tests/hashing/sha512_test.cpp +++ b/cpp/tests/hashing/sha512_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/interop/from_arrow_device_test.cpp b/cpp/tests/interop/from_arrow_device_test.cpp index df83837bb2e8..a4c991c6ee78 100644 --- a/cpp/tests/interop/from_arrow_device_test.cpp +++ b/cpp/tests/interop/from_arrow_device_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/interop/from_arrow_host_test.cpp b/cpp/tests/interop/from_arrow_host_test.cpp index 7af852026f4d..70d094e78e1b 100644 --- a/cpp/tests/interop/from_arrow_host_test.cpp +++ b/cpp/tests/interop/from_arrow_host_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/interop/from_arrow_stream_test.cpp b/cpp/tests/interop/from_arrow_stream_test.cpp index 833716f06eb3..551c2522fbfd 100644 --- a/cpp/tests/interop/from_arrow_stream_test.cpp +++ b/cpp/tests/interop/from_arrow_stream_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/interop/from_arrow_test.cpp b/cpp/tests/interop/from_arrow_test.cpp index 3ee6c378f558..1bbdaaa62447 100644 --- a/cpp/tests/interop/from_arrow_test.cpp +++ b/cpp/tests/interop/from_arrow_test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/interop/to_arrow_device_test.cpp b/cpp/tests/interop/to_arrow_device_test.cpp index 7c4e5ea043f0..75c429aedf77 100644 --- a/cpp/tests/interop/to_arrow_device_test.cpp +++ b/cpp/tests/interop/to_arrow_device_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/interop/to_arrow_host_test.cpp b/cpp/tests/interop/to_arrow_host_test.cpp index 8c62a8961e18..a136d453b6df 100644 --- a/cpp/tests/interop/to_arrow_host_test.cpp +++ b/cpp/tests/interop/to_arrow_host_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/interop/to_arrow_test.cpp b/cpp/tests/interop/to_arrow_test.cpp index 5659def59a1e..d57ffe2feb41 100644 --- a/cpp/tests/interop/to_arrow_test.cpp +++ b/cpp/tests/interop/to_arrow_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/cudftable_test.cpp b/cpp/tests/io/cudftable_test.cpp index cce0e53d08dd..de0d7bb483a4 100644 --- a/cpp/tests/io/cudftable_test.cpp +++ b/cpp/tests/io/cudftable_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/experimental/variant_extract_test.cpp b/cpp/tests/io/experimental/variant_extract_test.cpp index 1c712fdfad52..c484155f0d2f 100644 --- a/cpp/tests/io/experimental/variant_extract_test.cpp +++ b/cpp/tests/io/experimental/variant_extract_test.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/json/json_test.cpp b/cpp/tests/io/json/json_test.cpp index 1b8162695e65..0f9731dd2011 100644 --- a/cpp/tests/io/json/json_test.cpp +++ b/cpp/tests/io/json/json_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/io/json/json_writer.cpp b/cpp/tests/io/json/json_writer.cpp index d08740d74a70..aba9ed5ffc86 100644 --- a/cpp/tests/io/json/json_writer.cpp +++ b/cpp/tests/io/json/json_writer.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/orc_chunked_reader_test.cu b/cpp/tests/io/orc_chunked_reader_test.cu index ee8c6c634870..c867f919a794 100644 --- a/cpp/tests/io/orc_chunked_reader_test.cu +++ b/cpp/tests/io/orc_chunked_reader_test.cu @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/orc_test.cpp b/cpp/tests/io/orc_test.cpp index 4f957d547e9b..cc14555002cd 100644 --- a/cpp/tests/io/orc_test.cpp +++ b/cpp/tests/io/orc_test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/io/parquet_chunked_reader_test.cu b/cpp/tests/io/parquet_chunked_reader_test.cu index a9094405a1a4..b280b82b3506 100644 --- a/cpp/tests/io/parquet_chunked_reader_test.cu +++ b/cpp/tests/io/parquet_chunked_reader_test.cu @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/parquet_chunked_writer_test.cpp b/cpp/tests/io/parquet_chunked_writer_test.cpp index 68b3317672f3..66ea0c2e9687 100644 --- a/cpp/tests/io/parquet_chunked_writer_test.cpp +++ b/cpp/tests/io/parquet_chunked_writer_test.cpp @@ -6,8 +6,10 @@ #include "parquet_common.hpp" #include +#include #include #include +#include #include #include diff --git a/cpp/tests/io/parquet_reader_test.cpp b/cpp/tests/io/parquet_reader_test.cpp index 6e55ccbd5ca0..c00222278794 100644 --- a/cpp/tests/io/parquet_reader_test.cpp +++ b/cpp/tests/io/parquet_reader_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/io/parquet_v2_test.cpp b/cpp/tests/io/parquet_v2_test.cpp index 1035dcf272d3..2907cd1a4512 100644 --- a/cpp/tests/io/parquet_v2_test.cpp +++ b/cpp/tests/io/parquet_v2_test.cpp @@ -6,8 +6,10 @@ #include "parquet_common.hpp" #include +#include #include #include +#include #include #include diff --git a/cpp/tests/io/parquet_writer_test.cpp b/cpp/tests/io/parquet_writer_test.cpp index 851d3d490978..f9cded385469 100644 --- a/cpp/tests/io/parquet_writer_test.cpp +++ b/cpp/tests/io/parquet_writer_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/join/join_tests.cpp b/cpp/tests/join/join_tests.cpp index 943044fd134c..79e3e8e46659 100644 --- a/cpp/tests/join/join_tests.cpp +++ b/cpp/tests/join/join_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index 6e758a782d65..e2347681433f 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index 2408ebfbbbbe..f26a27f16d47 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/contains_tests.cpp b/cpp/tests/lists/contains_tests.cpp index 856b0e0dd6af..b6d96026b9f6 100644 --- a/cpp/tests/lists/contains_tests.cpp +++ b/cpp/tests/lists/contains_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/count_elements_tests.cpp b/cpp/tests/lists/count_elements_tests.cpp index 956c2ef740d4..40ab2a8cf93c 100644 --- a/cpp/tests/lists/count_elements_tests.cpp +++ b/cpp/tests/lists/count_elements_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/explode_tests.cpp b/cpp/tests/lists/explode_tests.cpp index 373ac65c85bc..f10c45083615 100644 --- a/cpp/tests/lists/explode_tests.cpp +++ b/cpp/tests/lists/explode_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/extract_tests.cpp b/cpp/tests/lists/extract_tests.cpp index b454c1770ccd..8e38053785c2 100644 --- a/cpp/tests/lists/extract_tests.cpp +++ b/cpp/tests/lists/extract_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/reverse_tests.cpp b/cpp/tests/lists/reverse_tests.cpp index e260b328b3ac..1432cf6f7ae1 100644 --- a/cpp/tests/lists/reverse_tests.cpp +++ b/cpp/tests/lists/reverse_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/sequences_tests.cpp b/cpp/tests/lists/sequences_tests.cpp index 5a7267e1d27b..c8930d85a01f 100644 --- a/cpp/tests/lists/sequences_tests.cpp +++ b/cpp/tests/lists/sequences_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp index 425978615f9a..515b3d69734a 100644 --- a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/set_operations/have_overlap_tests.cpp b/cpp/tests/lists/set_operations/have_overlap_tests.cpp index 74a687c7375f..7260c7d4ff4e 100644 --- a/cpp/tests/lists/set_operations/have_overlap_tests.cpp +++ b/cpp/tests/lists/set_operations/have_overlap_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp index 74462f21320e..30e9d583c9f5 100644 --- a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/set_operations/union_distinct_tests.cpp b/cpp/tests/lists/set_operations/union_distinct_tests.cpp index 51ba65453f12..340cf0746009 100644 --- a/cpp/tests/lists/set_operations/union_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/union_distinct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/sort_lists_tests.cpp b/cpp/tests/lists/sort_lists_tests.cpp index 3bad25dbd668..8b7bc0e8463f 100644 --- a/cpp/tests/lists/sort_lists_tests.cpp +++ b/cpp/tests/lists/sort_lists_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp b/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp index 36be64551bb5..1e0793c3cc71 100644 --- a/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp +++ b/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/lists/stream_compaction/distinct_tests.cpp b/cpp/tests/lists/stream_compaction/distinct_tests.cpp index f7b1c12562b2..b16ed2519385 100644 --- a/cpp/tests/lists/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/lists/stream_compaction/distinct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/merge/merge_test.cpp b/cpp/tests/merge/merge_test.cpp index 0302846ec96e..1d8ea3010ae2 100644 --- a/cpp/tests/merge/merge_test.cpp +++ b/cpp/tests/merge/merge_test.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index df3ae6fcbbec..b8cee03fea28 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/partitioning/partition_test.cpp b/cpp/tests/partitioning/partition_test.cpp index 1655373280dd..6066b06acff4 100644 --- a/cpp/tests/partitioning/partition_test.cpp +++ b/cpp/tests/partitioning/partition_test.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/quantiles/percentile_approx_test.cpp b/cpp/tests/quantiles/percentile_approx_test.cpp index 6e1fb1f899f0..faa296465826 100644 --- a/cpp/tests/quantiles/percentile_approx_test.cpp +++ b/cpp/tests/quantiles/percentile_approx_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/reductions/collect_ops_tests.cpp b/cpp/tests/reductions/collect_ops_tests.cpp index 598cb9a7deab..e0aad1db4e58 100644 --- a/cpp/tests/reductions/collect_ops_tests.cpp +++ b/cpp/tests/reductions/collect_ops_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/reductions/distinct_count_tests.cpp b/cpp/tests/reductions/distinct_count_tests.cpp index 12655805adaf..5e3f60d75c8c 100644 --- a/cpp/tests/reductions/distinct_count_tests.cpp +++ b/cpp/tests/reductions/distinct_count_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index 732cad257e68..9952f7bb4948 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include diff --git a/cpp/tests/reductions/reduction_tests.cpp b/cpp/tests/reductions/reduction_tests.cpp index 67a388e41eca..b951cb5d91df 100644 --- a/cpp/tests/reductions/reduction_tests.cpp +++ b/cpp/tests/reductions/reduction_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/reductions/unique_count_tests.cpp b/cpp/tests/reductions/unique_count_tests.cpp index bb364acfbeee..b1a791d10a8b 100644 --- a/cpp/tests/reductions/unique_count_tests.cpp +++ b/cpp/tests/reductions/unique_count_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/reshape/byte_cast_tests.cpp b/cpp/tests/reshape/byte_cast_tests.cpp index 850d2ac8c969..8916fd067e32 100644 --- a/cpp/tests/reshape/byte_cast_tests.cpp +++ b/cpp/tests/reshape/byte_cast_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 66dc44a8e790..39c4332a18bd 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/rolling/collect_ops_test.cpp b/cpp/tests/rolling/collect_ops_test.cpp index ca1f1ba827c8..ae2112f5fd8b 100644 --- a/cpp/tests/rolling/collect_ops_test.cpp +++ b/cpp/tests/rolling/collect_ops_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/rolling/empty_input_test.cpp b/cpp/tests/rolling/empty_input_test.cpp index b6a73d0803c3..6b4ff90b6104 100644 --- a/cpp/tests/rolling/empty_input_test.cpp +++ b/cpp/tests/rolling/empty_input_test.cpp @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include +#include #include #include diff --git a/cpp/tests/rolling/lead_lag_test.cpp b/cpp/tests/rolling/lead_lag_test.cpp index 126b3ef4679d..127d68d04f24 100644 --- a/cpp/tests/rolling/lead_lag_test.cpp +++ b/cpp/tests/rolling/lead_lag_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/rolling/offset_row_window_test.cpp b/cpp/tests/rolling/offset_row_window_test.cpp index 4f345436476b..8b272a24c953 100644 --- a/cpp/tests/rolling/offset_row_window_test.cpp +++ b/cpp/tests/rolling/offset_row_window_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/rolling/range_rolling_window_test.cpp b/cpp/tests/rolling/range_rolling_window_test.cpp index e73291c1114c..0c6586843c9c 100644 --- a/cpp/tests/rolling/range_rolling_window_test.cpp +++ b/cpp/tests/rolling/range_rolling_window_test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/scalar/factories_test.cpp b/cpp/tests/scalar/factories_test.cpp index 91057d81743e..b93704177233 100644 --- a/cpp/tests/scalar/factories_test.cpp +++ b/cpp/tests/scalar/factories_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/cpp/tests/scalar/scalar_test.cpp b/cpp/tests/scalar/scalar_test.cpp index 52fd8c684e14..45cd2f74caf2 100644 --- a/cpp/tests/scalar/scalar_test.cpp +++ b/cpp/tests/scalar/scalar_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/cpp/tests/search/search_list_test.cpp b/cpp/tests/search/search_list_test.cpp index c8bdcfe1e3e8..f45027ba52a4 100644 --- a/cpp/tests/search/search_list_test.cpp +++ b/cpp/tests/search/search_list_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/search/search_struct_test.cpp b/cpp/tests/search/search_struct_test.cpp index acaf74146bc0..70ac0e1e04f3 100644 --- a/cpp/tests/search/search_struct_test.cpp +++ b/cpp/tests/search/search_struct_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/sort/is_sorted_tests.cpp b/cpp/tests/sort/is_sorted_tests.cpp index 6d0028bb940c..9bf906ce0878 100644 --- a/cpp/tests/sort/is_sorted_tests.cpp +++ b/cpp/tests/sort/is_sorted_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include #include diff --git a/cpp/tests/sort/rank_test.cpp b/cpp/tests/sort/rank_test.cpp index 27a24033e77c..b714afbcb556 100644 --- a/cpp/tests/sort/rank_test.cpp +++ b/cpp/tests/sort/rank_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/sort/sort_nested_types_tests.cpp b/cpp/tests/sort/sort_nested_types_tests.cpp index 85b77d84b646..56d0d82115e1 100644 --- a/cpp/tests/sort/sort_nested_types_tests.cpp +++ b/cpp/tests/sort/sort_nested_types_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index e4925f99f019..d015bf00701f 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/sort/top_k_tests.cpp b/cpp/tests/sort/top_k_tests.cpp index 821eb363f33e..6a6141763aa3 100644 --- a/cpp/tests/sort/top_k_tests.cpp +++ b/cpp/tests/sort/top_k_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp b/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp index 81f68b99cad9..4159e01e531f 100644 --- a/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp +++ b/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/stream_compaction/distinct_tests.cpp b/cpp/tests/stream_compaction/distinct_tests.cpp index 32253437be8c..7514bef19cc6 100644 --- a/cpp/tests/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/stream_compaction/distinct_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/stream_compaction/stable_distinct_tests.cpp b/cpp/tests/stream_compaction/stable_distinct_tests.cpp index 120aa12dabac..352503dfd169 100644 --- a/cpp/tests/stream_compaction/stable_distinct_tests.cpp +++ b/cpp/tests/stream_compaction/stable_distinct_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/stream_compaction/unique_tests.cpp b/cpp/tests/stream_compaction/unique_tests.cpp index 2bc0480e47e4..e8affe90f212 100644 --- a/cpp/tests/stream_compaction/unique_tests.cpp +++ b/cpp/tests/stream_compaction/unique_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/copying_test.cpp b/cpp/tests/streams/copying_test.cpp index 80ac01aca25f..48624cfb1b0d 100644 --- a/cpp/tests/streams/copying_test.cpp +++ b/cpp/tests/streams/copying_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp b/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp index 3447b36ca254..3b932406eeb0 100644 --- a/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp +++ b/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/io/orc_test.cpp b/cpp/tests/streams/io/orc_test.cpp index 101e8c8034d7..0539500c0e75 100644 --- a/cpp/tests/streams/io/orc_test.cpp +++ b/cpp/tests/streams/io/orc_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/io/parquet_test.cpp b/cpp/tests/streams/io/parquet_test.cpp index 9fd8947c53a6..ee94d8e9f0e6 100644 --- a/cpp/tests/streams/io/parquet_test.cpp +++ b/cpp/tests/streams/io/parquet_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/lists_test.cpp b/cpp/tests/streams/lists_test.cpp index fd11d05aa1e7..4f6e6aefb941 100644 --- a/cpp/tests/streams/lists_test.cpp +++ b/cpp/tests/streams/lists_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/strings/combine_test.cpp b/cpp/tests/streams/strings/combine_test.cpp index c98d696d9ae0..84cbdd3ec4b1 100644 --- a/cpp/tests/streams/strings/combine_test.cpp +++ b/cpp/tests/streams/strings/combine_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/streams/strings/convert_test.cpp b/cpp/tests/streams/strings/convert_test.cpp index 863842c8c33a..9e04289d9f0d 100644 --- a/cpp/tests/streams/strings/convert_test.cpp +++ b/cpp/tests/streams/strings/convert_test.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/combine/join_list_elements_tests.cpp b/cpp/tests/strings/combine/join_list_elements_tests.cpp index df0f8b5ed58c..339d1e2b7c0e 100644 --- a/cpp/tests/strings/combine/join_list_elements_tests.cpp +++ b/cpp/tests/strings/combine/join_list_elements_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/extract_tests.cpp b/cpp/tests/strings/extract_tests.cpp index 460e73c0e05d..ada8c723ff19 100644 --- a/cpp/tests/strings/extract_tests.cpp +++ b/cpp/tests/strings/extract_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/find_multiple_tests.cpp b/cpp/tests/strings/find_multiple_tests.cpp index 2a128ebd142b..d980a1c5ad59 100644 --- a/cpp/tests/strings/find_multiple_tests.cpp +++ b/cpp/tests/strings/find_multiple_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/findall_tests.cpp b/cpp/tests/strings/findall_tests.cpp index 357b237f3ab0..6051a7ad7e63 100644 --- a/cpp/tests/strings/findall_tests.cpp +++ b/cpp/tests/strings/findall_tests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/format_lists_tests.cpp b/cpp/tests/strings/format_lists_tests.cpp index c113583b20a6..3e87c1246597 100644 --- a/cpp/tests/strings/format_lists_tests.cpp +++ b/cpp/tests/strings/format_lists_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/strings/split_tests.cpp b/cpp/tests/strings/split_tests.cpp index 74e6e03ae3ea..9878bdab43a8 100644 --- a/cpp/tests/strings/split_tests.cpp +++ b/cpp/tests/strings/split_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/structs/structs_column_tests.cpp b/cpp/tests/structs/structs_column_tests.cpp index 563ddb11ff44..016d72c5d54f 100644 --- a/cpp/tests/structs/structs_column_tests.cpp +++ b/cpp/tests/structs/structs_column_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/structs/utilities_tests.cpp b/cpp/tests/structs/utilities_tests.cpp index d8b9735ba0ab..691edcb57dd8 100644 --- a/cpp/tests/structs/utilities_tests.cpp +++ b/cpp/tests/structs/utilities_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/table/table_tests.cpp b/cpp/tests/table/table_tests.cpp index 71fda287d8e4..ce0ee70e9332 100644 --- a/cpp/tests/table/table_tests.cpp +++ b/cpp/tests/table/table_tests.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/text/minhash_tests.cpp b/cpp/tests/text/minhash_tests.cpp index df3e642f0db1..ff790b511803 100644 --- a/cpp/tests/text/minhash_tests.cpp +++ b/cpp/tests/text/minhash_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/text/ngrams_tests.cpp b/cpp/tests/text/ngrams_tests.cpp index f072c97f6fe6..da389cb97eea 100644 --- a/cpp/tests/text/ngrams_tests.cpp +++ b/cpp/tests/text/ngrams_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/text/subword_tests.cpp b/cpp/tests/text/subword_tests.cpp index c584e5e6e8d8..ac018e043323 100644 --- a/cpp/tests/text/subword_tests.cpp +++ b/cpp/tests/text/subword_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/text/tokenize_tests.cpp b/cpp/tests/text/tokenize_tests.cpp index 0da7a87e2825..45c133f039d6 100644 --- a/cpp/tests/text/tokenize_tests.cpp +++ b/cpp/tests/text/tokenize_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/transform/one_hot_encode_tests.cpp b/cpp/tests/transform/one_hot_encode_tests.cpp index fb35743938da..77fa9c35edfe 100644 --- a/cpp/tests/transform/one_hot_encode_tests.cpp +++ b/cpp/tests/transform/one_hot_encode_tests.cpp @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include diff --git a/cpp/tests/transform/row_bit_count_test.cu b/cpp/tests/transform/row_bit_count_test.cu index 20e329808f0e..3552a3592fc5 100644 --- a/cpp/tests/transform/row_bit_count_test.cu +++ b/cpp/tests/transform/row_bit_count_test.cu @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/unary/math_ops_test.cpp b/cpp/tests/unary/math_ops_test.cpp index 59d47af6ec2d..04568abf1069 100644 --- a/cpp/tests/unary/math_ops_test.cpp +++ b/cpp/tests/unary/math_ops_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index b986069f8d4b..b8f6355fcd7b 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index 89116dfd211d..98a1a4c721c8 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/cpp/tests/utilities_tests/type_check_tests.cpp b/cpp/tests/utilities_tests/type_check_tests.cpp index 74a72f7154b8..9521f3487063 100644 --- a/cpp/tests/utilities_tests/type_check_tests.cpp +++ b/cpp/tests/utilities_tests/type_check_tests.cpp @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include #include +#include #include #include From e18754f62bb5649771ab933cf4069e6fb29249fa Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 2 Sep 2026 19:12:37 +0000 Subject: [PATCH 13/21] Enable recursive lists column initialization --- .../cudf_test/lists_column_wrapper.hpp | 325 ++++++++---- cpp/tests/column/column_test.cpp | 15 +- cpp/tests/column/factories_test.cpp | 57 +- cpp/tests/copying/concatenate_tests.cpp | 221 +++----- .../copying/copy_if_else_nested_tests.cpp | 51 +- cpp/tests/copying/gather_list_tests.cpp | 5 +- cpp/tests/copying/get_value_tests.cpp | 97 ++-- cpp/tests/copying/pack_tests.cpp | 56 +- .../copying/purge_nonempty_nulls_tests.cpp | 15 +- .../copying/scatter_list_scalar_tests.cpp | 161 +++--- .../copying/scatter_struct_scalar_tests.cpp | 6 +- .../copying/segmented_gather_list_tests.cpp | 16 +- cpp/tests/copying/slice_tests.cpp | 58 +- cpp/tests/copying/split_tests.cpp | 97 ++-- cpp/tests/groupby/collect_list_tests.cpp | 11 +- cpp/tests/groupby/collect_set_tests.cpp | 4 +- cpp/tests/groupby/lists_tests.cpp | 15 +- cpp/tests/groupby/max_tests.cpp | 7 +- cpp/tests/groupby/merge_lists_tests.cpp | 119 +++-- cpp/tests/groupby/merge_sets_tests.cpp | 86 +-- cpp/tests/groupby/min_tests.cpp | 9 +- cpp/tests/groupby/nth_element_tests.cpp | 2 +- cpp/tests/groupby/replace_nulls_tests.cpp | 52 +- cpp/tests/interop/from_arrow_device_test.cpp | 10 +- cpp/tests/interop/from_arrow_host_test.cpp | 10 +- cpp/tests/interop/to_arrow_device_test.cpp | 9 +- cpp/tests/interop/to_arrow_host_test.cpp | 9 +- cpp/tests/io/json/json_test.cpp | 24 +- cpp/tests/io/json/json_writer.cpp | 2 +- cpp/tests/io/orc_chunked_reader_test.cu | 16 +- cpp/tests/io/parquet_chunked_reader_test.cu | 28 +- cpp/tests/io/parquet_chunked_writer_test.cpp | 6 +- cpp/tests/io/parquet_v2_test.cpp | 70 +-- .../concatenate_list_elements_tests.cpp | 497 +++++++++--------- .../lists/combine/concatenate_rows_tests.cpp | 472 ++++++++--------- cpp/tests/lists/contains_tests.cpp | 199 ++++--- cpp/tests/lists/count_elements_tests.cpp | 20 +- cpp/tests/lists/explode_tests.cpp | 115 ++-- cpp/tests/lists/extract_tests.cpp | 59 +-- cpp/tests/lists/reverse_tests.cpp | 41 +- cpp/tests/lists/sequences_tests.cpp | 47 +- .../difference_distinct_tests.cpp | 190 ++++--- .../set_operations/have_overlap_tests.cpp | 134 +++-- .../intersect_distinct_tests.cpp | 187 +++---- .../set_operations/union_distinct_tests.cpp | 188 ++++--- cpp/tests/lists/sort_lists_tests.cpp | 10 +- .../apply_boolean_mask_tests.cpp | 38 +- .../stream_compaction/distinct_tests.cpp | 113 ++-- cpp/tests/merge/merge_test.cpp | 28 +- cpp/tests/reductions/collect_ops_tests.cpp | 46 +- cpp/tests/reductions/list_rank_test.cpp | 20 +- cpp/tests/reductions/reduction_tests.cpp | 30 +- .../reshape/interleave_columns_tests.cpp | 485 ++++++++--------- cpp/tests/search/search_list_test.cpp | 43 +- cpp/tests/sort/is_sorted_tests.cpp | 20 +- cpp/tests/sort/sort_nested_types_tests.cpp | 2 +- cpp/tests/sort/sort_test.cpp | 43 +- cpp/tests/sort/top_k_tests.cpp | 38 +- .../stream_compaction/distinct_tests.cpp | 8 +- .../stable_distinct_tests.cpp | 5 +- cpp/tests/stream_compaction/unique_tests.cpp | 3 +- cpp/tests/streams/lists_test.cpp | 20 +- cpp/tests/streams/strings/combine_test.cpp | 5 +- cpp/tests/streams/strings/convert_test.cpp | 3 +- .../combine/join_list_elements_tests.cpp | 92 ++-- cpp/tests/strings/extract_tests.cpp | 14 +- cpp/tests/strings/find_multiple_tests.cpp | 12 +- cpp/tests/strings/findall_tests.cpp | 53 +- cpp/tests/strings/format_lists_tests.cpp | 50 +- cpp/tests/strings/split_tests.cpp | 138 ++--- cpp/tests/text/minhash_tests.cpp | 104 ++-- cpp/tests/text/ngrams_tests.cpp | 38 +- cpp/tests/text/subword_tests.cpp | 40 +- cpp/tests/text/tokenize_tests.cpp | 26 +- .../lists_column_wrapper_tests.cpp | 61 +-- .../utilities_tests/type_check_tests.cpp | 14 +- 76 files changed, 2573 insertions(+), 2847 deletions(-) diff --git a/cpp/include/cudf_test/lists_column_wrapper.hpp b/cpp/include/cudf_test/lists_column_wrapper.hpp index 9532733c25e8..90a985842d17 100644 --- a/cpp/include/cudf_test/lists_column_wrapper.hpp +++ b/cpp/include/cudf_test/lists_column_wrapper.hpp @@ -46,15 +46,10 @@ class lists_column_wrapper; * @brief Host-side recursive initializer tree for constructing list columns with an * explicit stream and memory resources at every nesting level. * - * Prefer this over brace-nested `lists_column_wrapper` constructions that pass - * `stream`/`mr` only at the outer level, which leave brace-constructed children on - * the default test resources. - * * Example: * @code{.cpp} - * using Init = cudf::test::lists_column_initializer; - * // List: [{1, 2}, {3}] - * lists_column_wrapper col{Init{{{1, 2}, {3}}}, stream, mr}; + * using LCW = cudf::test::lists_column_wrapper; + * LCW col{{{1, 2}, {3}}, stream, mr}; * @endcode * * Leaf and nested constructors accept the existing validity iterators @@ -65,6 +60,14 @@ class lists_column_wrapper; template class lists_column_initializer { public: + using value_type = T; + + struct string_element { + string_element(char const* value) : value_{value} {} + string_element(std::string value) : value_{std::move(value)} {} + + std::string value_; + }; /** * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested * empty `initializer_list` constructors. @@ -76,7 +79,39 @@ class lists_column_initializer { * * @param values Leaf element values */ - lists_column_initializer(std::initializer_list values) : values_{values} {} + template + lists_column_initializer(std::initializer_list values) + requires(!std::is_same_v && std::is_convertible_v) + : values_(values.begin(), values.end()) + { + } + + template + lists_column_initializer(First first, Rest... rest) + requires(sizeof...(Rest) > 0 && !std::is_same_v && + std::is_convertible_v && (std::is_convertible_v && ...)) + : values_{static_cast(first), static_cast(rest)...} + { + } + + lists_column_initializer(std::initializer_list values) + requires(std::is_same_v) + { + values_.reserve(values.size()); + std::transform( + values.begin(), values.end(), std::back_inserter(values_), [](auto const& value) { + return value.value_; + }); + } + + template + requires requires(InputIterator i) { + *i; + ++i; + } + lists_column_initializer(InputIterator begin, InputIterator end) : values_(begin, end) + { + } /** * @brief Construct a leaf from scalar values and a validity iterator. @@ -86,7 +121,13 @@ class lists_column_initializer { * @param v Validity iterator over `values.size()` elements */ template - lists_column_initializer(std::initializer_list values, ValidityIterator v) : values_{values} + requires requires(ValidityIterator i) { + *i; + ++i; + } + lists_column_initializer(std::initializer_list values, ValidityIterator v) + requires(!std::is_same_v) + : values_{values} { value_validity_.reserve(values_.size()); for (std::size_t i = 0; i < values_.size(); ++i) { @@ -94,6 +135,34 @@ class lists_column_initializer { } } + template + lists_column_initializer(std::initializer_list values, ValidityIterator v) + requires(std::is_same_v && requires(ValidityIterator i) { + *i; + ++i; + }) + { + values_.reserve(values.size()); + value_validity_.reserve(values.size()); + for (auto const& value : values) { + values_.push_back(value.value_); + value_validity_.push_back(static_cast(*v++)); + } + } + + lists_column_initializer(std::initializer_list values, std::initializer_list validity) + requires(!std::is_same_v) + : lists_column_initializer(values, validity.begin()) + { + } + + lists_column_initializer(std::initializer_list values, + std::initializer_list validity) + requires(std::is_same_v) + : lists_column_initializer(values, validity.begin()) + { + } + /** * @brief Construct a nested node from child initializers. * @@ -112,6 +181,18 @@ class lists_column_initializer { { } + static lists_column_initializer nested(std::initializer_list children) + { + return lists_column_initializer(children); + } + + template + static lists_column_initializer nested(std::initializer_list children, + ValidityIterator v) + { + return lists_column_initializer(children, v); + } + /** * @brief Construct a nested node from child initializers and a row-validity iterator. * @@ -123,19 +204,23 @@ class lists_column_initializer { lists_column_initializer(std::initializer_list children, ValidityIterator v) requires(std::is_same_v && std::is_convertible_v, bool>) - : nested_{true} + : nested_{true}, has_validity_{true} { children_.reserve(children.size()); for (auto const& child : children) { - if (static_cast(*v++)) { - children_.push_back(child); - } else { - children_.emplace_back(); - children_.back().valid_ = false; - } + children_.push_back(child); + children_.back().valid_ = static_cast(*v++); } } + template + lists_column_initializer(std::initializer_list children, + std::initializer_list validity) + requires(std::is_same_v) + : lists_column_initializer(children, validity.begin()) + { + } + /** * @brief True if this node holds nested child initializers rather than leaf values. * @return Whether this node is nested @@ -184,60 +269,58 @@ class lists_column_initializer { std::vector validity; children.reserve(children_.size()); validity.reserve(children_.size()); - bool any_null = false; for (auto const& child : children_) { - any_null = any_null || !child.valid(); validity.push_back(child.valid()); - if (child.valid()) { - children.emplace_back(child, stream, mr); - } else { - children.emplace_back(); // null rows are skipped during concatenate - } + children.emplace_back(child, stream, mr); } - return {std::move(children), any_null ? std::move(validity) : std::vector{}}; + return {std::move(children), has_validity_ ? std::move(validity) : std::vector{}}; } private: + template + lists_column_initializer with_validity(ValidityIterator validity) && + requires requires(ValidityIterator i) { + static_cast(*i); + ++i; + } + { + has_validity_ = true; + if (nested_) { + for (auto& child : children_) { + child.valid_ = static_cast(*validity++); + } + } else { + value_validity_.clear(); + value_validity_.reserve(values_.size()); + std::transform(validity, + validity + values_.size(), + std::back_inserter(value_validity_), + [](auto const& value) { return static_cast(value); }); + } + return std::move(*this); + } + + template + friend class lists_column_wrapper; + std::vector values_; std::vector value_validity_; std::vector children_; bool nested_{false}; bool valid_{true}; + bool has_validity_{false}; }; /** * @brief `column_wrapper` derived class for wrapping columns of lists. * - * Important note : due to the way initializer lists work, there is a - * non-obvious behavioral difference when declaring nested empty lists - * in different situations. Specifically, - * - * - When compiled inside of a templated class function (such as a TYPED_TEST - * cudf test wrapper), nested empty lists behave as they read, semantically. - * - * @code{.pseudo} - * lists_column_wrapper col{ {LCW{}} } - * This yields a List> column containing 1 row : a list - * containing an empty list. - * @endcode - * - * - When compiled under other situations (a global function, or a non - * templated class function), the behavior is different. + * Nested rows can normally be expressed directly with braces. Use `nested()` when a + * single-child initializer would otherwise make the intended depth ambiguous. * - * @code{.pseudo} - * lists_column_wrapper col{ {LCW{}} } - * This yields a List column containing 1 row that is an empty - * list. - * @endcode - * - * This only effects the initial nesting of the empty list. In summary, the - * correct way to declare an "Empty List" in the two cases are: - * - * @code{.pseudo} - * // situation 1 (cudf TYPED_TEST case) - * LCW{} - * // situation 2 (cudf TEST_F case) - * {LCW{}} + * @code{.cpp} + * using LCW = cudf::test::lists_column_wrapper; + * LCW lists{{{1}, {2}}, {}, {{3}, {4, 5}}}; + * LCW deeper{LCW::nested({{1}}), {}}; * @endcode */ template @@ -253,6 +336,20 @@ class lists_column_wrapper : public detail::column_wrapper { */ using host_element_t = std::conditional_t, std::string, SourceElementT>; + using initializer_type = lists_column_initializer; + + static initializer_type nested(std::initializer_list children) + { + return initializer_type::nested(children); + } + + template + static initializer_type nested(std::initializer_list children, + ValidityIterator validity) + { + return initializer_type::nested(children, validity); + } + /** * @brief Column wrapper type used to materialize leaf list contents. */ @@ -271,23 +368,35 @@ class lists_column_wrapper : public detail::column_wrapper { * lists_column_wrapper l{0, 1}; * @endcode * - * These leaf constructors are templates (via `requires`) so that the non-template - * nested `initializer_list` constructor is preferred for - * ambiguous cases such as `lists_column_wrapper{{}, {}}`. + * These leaf constructors are templates (via `requires`) so that recursive initializer + * construction is preferred for ambiguous cases such as + * `lists_column_wrapper{{}, {}}`. * * @param elements The list of elements * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(std::initializer_list elements, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width()) + requires(cudf::is_fixed_width() && std::is_convertible_v) : column_wrapper{} { build_from_non_nested( - fixed_width_column_wrapper(elements, stream, mr).release(), stream, mr); + fixed_width_column_wrapper(elements.begin(), elements.end(), stream, mr) + .release(), + stream, + mr); + } + + template + lists_column_wrapper(First first, Rest... rest) + requires(cudf::is_fixed_width() && (std::is_convertible_v && ... && + std::is_convertible_v)) + : lists_column_wrapper(std::initializer_list{ + static_cast(first), static_cast(rest)...}) + { } /** @@ -307,6 +416,10 @@ class lists_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column */ template + requires requires(InputIterator i) { + *i; + ++i; + } lists_column_wrapper(InputIterator begin, InputIterator end, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -333,16 +446,19 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width()) + requires(cudf::is_fixed_width() && std::is_convertible_v) : column_wrapper{} { build_from_non_nested( - fixed_width_column_wrapper(elements, v, stream, mr).release(), stream, mr); + fixed_width_column_wrapper(elements.begin(), elements.end(), v, stream, mr) + .release(), + stream, + mr); } /** @@ -365,6 +481,10 @@ class lists_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column */ template + requires requires(InputIterator i) { + *i; + ++i; + } lists_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v, @@ -389,14 +509,15 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(std::initializer_list elements, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v) + requires(std::is_same_v && std::is_constructible_v) : column_wrapper{} { - build_from_non_nested(strings_column_wrapper(elements, stream, mr).release(), stream, mr); + build_from_non_nested( + strings_column_wrapper(elements.begin(), elements.end(), stream, mr).release(), stream, mr); } /** @@ -415,15 +536,18 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template - lists_column_wrapper(std::initializer_list elements, + template + lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v) + requires(std::is_same_v && std::is_constructible_v) : column_wrapper{} { - build_from_non_nested(strings_column_wrapper(elements, v, stream, mr).release(), stream, mr); + build_from_non_nested( + strings_column_wrapper(elements.begin(), elements.end(), v, stream, mr).release(), + stream, + mr); } /** @@ -445,22 +569,18 @@ class lists_column_wrapper : public detail::column_wrapper { * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; * @endcode * - * For multi-row (and deeper) columns that should allocate with an explicit stream/mr, use - * `lists_column_initializer` so every nesting level receives those arguments: - * `using Init = cudf::test::lists_column_initializer;` - * `lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr};` + * An explicit stream and memory resource are propagated through every nesting level: + * `lists_column_wrapper l{{{0, 1}, {2, 3}, {4, 5}}, stream, mr};` * * @param elements The list of elements * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - lists_column_wrapper(std::initializer_list> elements, + lists_column_wrapper(std::initializer_list elements, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} + : lists_column_wrapper(initializer_type(elements), stream, mr) { - std::vector valids; - build_from_nested(elements, valids, stream, mr); } /** @@ -510,19 +630,12 @@ class lists_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column */ template - lists_column_wrapper(std::initializer_list> elements, + lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} + : lists_column_wrapper(initializer_type(elements, v), stream, mr) { - std::vector validity; - std::transform(elements.begin(), - elements.end(), - v, - std::back_inserter(validity), - [](lists_column_wrapper const& l, bool valid) { return valid; }); - build_from_nested(elements, validity, stream, mr); } /** @@ -534,21 +647,18 @@ class lists_column_wrapper : public detail::column_wrapper { * * Example: * @code{.cpp} - * using Init = cudf::test::lists_column_initializer; - * // List: [{0, 1}, {2, 3}, {4, 5}] - * lists_column_wrapper l{Init{{{0, 1}, {2, 3}, {4, 5}}}, stream, mr}; - * - * // List>: [{{0, 1}, {2}}, {{3}}] - * lists_column_wrapper nested{Init{{{{0, 1}, {2}}, {{3}}}}, stream, mr}; + * using LCW = cudf::test::lists_column_wrapper; + * LCW lists{{{0, 1}, {2, 3}, {4, 5}}, stream, mr}; + * LCW nested{{LCW::nested({{0, 1}, {2}}), LCW::nested({{3}})}, stream, mr}; * @endcode * * @param init Host-side nested values (and optional validity) * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - lists_column_wrapper(lists_column_initializer init, - rmm::cuda_stream_view stream, - cudf::memory_resources mr) + lists_column_wrapper(initializer_type init, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { if (!init.nested()) { @@ -561,10 +671,29 @@ class lists_column_wrapper : public detail::column_wrapper { return; } + if (init.children().empty()) { + wrapped = make_empty_lists_column(data_type{type_to_id()}); + depth = 1; + return; + } + auto [children, validity] = init.template build(stream, mr); build_from_nested(children, validity, stream, mr); } + template + lists_column_wrapper(initializer_type init, + ValidityIterator validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires requires(ValidityIterator i) { + static_cast(*i); + ++i; + } + : lists_column_wrapper(std::move(init).with_validity(validity), stream, mr) + { + } + /** * @brief Construct a list column containing a single empty, optionally null row. * diff --git a/cpp/tests/column/column_test.cpp b/cpp/tests/column/column_test.cpp index e564fd73fbe2..04e4eadf9988 100644 --- a/cpp/tests/column/column_test.cpp +++ b/cpp/tests/column/column_test.cpp @@ -540,7 +540,7 @@ TYPED_TEST(ListsColumnTest, ListsSlicedNonNestedEmpty) // Column of List LCW list{{1, 2}, {}, {3, 4}, {8, 9}}; // Column of 1 row, an empty List - LCW expect{LCW{}}; + LCW expect{{}}; auto sliced = cudf::slice(list, {1, 2}).front(); auto result = std::make_unique(sliced); @@ -554,9 +554,9 @@ TYPED_TEST(ListsColumnTest, ListsSlicedNestedEmpty) using FWCW_SZ = cudf::test::fixed_width_column_wrapper; // Column of List>, with incomplete hierarchy - LCW list{{LCW{1}, LCW{2}}, + LCW list{{{1}, {2}}, {}, // < ----------- empty List>, slice this - {LCW{3}, LCW{4, 5}}}; + {{3}, {4, 5}}}; // Make 1-row column of type List>, the row data contains 0 element. // Well-formed memory layout: @@ -586,7 +586,7 @@ TYPED_TEST(ListsColumnTest, ListsSlicedZeroSliceLengthNested) using LCW = cudf::test::lists_column_wrapper; // Column of List>, with incomplete hierarchy - LCW list{{LCW{1}, LCW{2}}, {}, {LCW{3}, LCW{4, 5}}}; + LCW list{{{1}, {2}}, {}, {{3}, {4, 5}}}; auto expect = cudf::empty_like(list); @@ -618,12 +618,9 @@ TYPED_TEST(ListsColumnTest, ListsSlicedColumnViewConstructorWithNulls) using LCW = cudf::test::lists_column_wrapper; - cudf::test::lists_column_wrapper list{ - {{{{1, 2}, {3, 4}}, valids}, LCW{}, {{{5, 6, 7}, LCW{}, {8, 9}}, valids}, LCW{}, LCW{}}, - valids}; + LCW list{{{{{1, 2}, {3, 4}}, valids}, {}, {{{5, 6, 7}, {}, {8, 9}}, valids}, {}, {}}, valids}; - cudf::test::lists_column_wrapper expect{ - {LCW{}, {{{5, 6, 7}, LCW{}, {8, 9}}, valids}, LCW{}, LCW{}}, expect_valids}; + LCW expect{{{}, {{{5, 6, 7}, {}, {8, 9}}, valids}, {}, {}}, expect_valids}; auto sliced = cudf::slice(list, {1, 5}).front(); auto result = std::make_unique(sliced); diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index 9c8a85379c1b..8b5ddd08b6e2 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -405,9 +405,9 @@ TYPED_TEST(ListsFixedWidthLeafTest, FromNonNested) auto s = cudf::make_list_scalar(FCW({1, -1, 3}, {1, 0, 1})); auto col = cudf::make_column_from_scalar(*s, 3); - auto expected = LCW{LCW({1, 2, 3}, valid_t{1, 0, 1}.begin()), - LCW({1, 2, 3}, valid_t{1, 0, 1}.begin()), - LCW({1, 2, 3}, valid_t{1, 0, 1}.begin())}; + auto expected = LCW{{{1, 2, 3}, valid_t{1, 0, 1}.begin()}, + {{1, 2, 3}, valid_t{1, 0, 1}.begin()}, + {{1, 2, 3}, valid_t{1, 0, 1}.begin()}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*col, expected); } @@ -417,12 +417,12 @@ TYPED_TEST(ListsFixedWidthLeafTest, FromNested) using valid_t = std::vector; #define row_data \ - LCW({LCW({-1, -1, 3}, valid_t{0, 0, 1}.begin()), LCW{}, LCW{}}, valid_t{1, 0, 1}.begin()) + LCW::nested({{{-1, -1, 3}, valid_t{0, 0, 1}.begin()}, {}, {}}, valid_t{1, 0, 1}.begin()) - auto s = cudf::make_list_scalar(row_data); + auto s = cudf::make_list_scalar(LCW(row_data)); auto col = cudf::make_column_from_scalar(*s, 5); - auto expected = LCW{row_data, row_data, row_data, row_data, row_data}; + auto expected = LCW({row_data, row_data, row_data, row_data, row_data}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*col, expected); #undef row_data @@ -497,10 +497,10 @@ TEST_F(ListsStringLeafTest, FromNonNested) auto s = cudf::make_list_scalar(SCW({"xx", "", "z"}, {true, false, true})); auto col = cudf::make_column_from_scalar(*s, 4); - auto expected = LCW{LCW({"xx", "", "z"}, valid_t{1, 0, 1}.begin()), - LCW({"xx", "", "z"}, valid_t{1, 0, 1}.begin()), - LCW({"xx", "", "z"}, valid_t{1, 0, 1}.begin()), - LCW({"xx", "", "z"}, valid_t{1, 0, 1}.begin())}; + auto expected = LCW{{{"xx", "", "z"}, valid_t{1, 0, 1}.begin()}, + {{"xx", "", "z"}, valid_t{1, 0, 1}.begin()}, + {{"xx", "", "z"}, valid_t{1, 0, 1}.begin()}, + {{"xx", "", "z"}, valid_t{1, 0, 1}.begin()}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*col, expected); } @@ -509,18 +509,18 @@ TEST_F(ListsStringLeafTest, FromNested) using LCW = cudf::test::lists_column_wrapper; using valid_t = std::vector; -#define row_data \ - LCW({LCW{}, \ - LCW({"@@", "rapids", "", "四", "ら"}, valid_t{1, 1, 0, 1, 1}.begin()), \ - LCW{}, \ - LCW({"hello", ""}, valid_t{1, 0}.begin())}, \ - valid_t{0, 1, 1, 1}.begin()) +#define row_data \ + LCW::nested({{}, \ + {{"@@", "rapids", "", "四", "ら"}, valid_t{1, 1, 0, 1, 1}.begin()}, \ + {}, \ + {{"hello", ""}, valid_t{1, 0}.begin()}}, \ + valid_t{0, 1, 1, 1}.begin()) - auto s = cudf::make_list_scalar(row_data); + auto s = cudf::make_list_scalar(LCW(row_data)); auto col = cudf::make_column_from_scalar(*s, 3); - auto expected = LCW{row_data, row_data, row_data}; + auto expected = LCW({row_data, row_data, row_data}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*col, expected); #undef row_data } @@ -581,12 +581,11 @@ TYPED_TEST(ListsStructsLeafTest, FromNested) using StringCW = cudf::test::strings_column_wrapper; using offset_t = cudf::test::fixed_width_column_wrapper; using valid_t = std::vector; - auto leaf = this->make_test_structs_column( - {{1, 2}, {0, 1}}, - StringCW({"étoile", "星"}, {true, true}), - LCWinner_t({LCWinner_t{}, LCWinner_t{42}}, valid_t{1, 1}.begin()), - valid_t{0, 1}.begin()); - auto mask = cudf::create_null_mask(3, cudf::mask_state::ALL_VALID); + auto leaf = this->make_test_structs_column({{1, 2}, {0, 1}}, + StringCW({"étoile", "星"}, {true, true}), + LCWinner_t({{}, {42}}, valid_t{1, 1}.begin()), + valid_t{0, 1}.begin()); + auto mask = cudf::create_null_mask(3, cudf::mask_state::ALL_VALID); cudf::set_null_mask(static_cast(mask.data()), 0, 1, false); auto data = cudf::make_lists_column(3, offset_t{0, 0, 1, 2}.release(), leaf.release(), 1, std::move(mask)); @@ -598,9 +597,7 @@ TYPED_TEST(ListsStructsLeafTest, FromNested) {{1, 2, 1, 2, 1, 2}, {0, 1, 0, 1, 0, 1}}, StringCW({"étoile", "星", "étoile", "星", "étoile", "星"}, {true, true, true, true, true, true}), - LCWinner_t( - {LCWinner_t{}, LCWinner_t{42}, LCWinner_t{}, LCWinner_t{42}, LCWinner_t{}, LCWinner_t{42}}, - valid_t{1, 1, 1, 1, 1, 1}.begin()), + LCWinner_t({{}, {42}, {}, {42}, {}, {42}}, valid_t{1, 1, 1, 1, 1, 1}.begin()), valid_t{0, 1, 0, 1, 0, 1}.begin()); auto mask2 = cudf::create_null_mask(9, cudf::mask_state::ALL_VALID); cudf::set_null_mask(static_cast(mask2.data()), 0, 1, false); @@ -650,7 +647,7 @@ TEST_F(ListsZeroLengthColumnTest, MixedTypes) } { - auto s = cudf::make_list_scalar(LCW{LCW{1, 2, 3}, LCW{}, LCW{5, 6}}); + auto s = cudf::make_list_scalar(LCW{{1, 2, 3}, {}, {5, 6}}); auto got = cudf::make_column_from_scalar(*s, 0); auto nested = cudf::make_lists_column(0, offset_t{}.release(), @@ -726,12 +723,10 @@ TEST_F(ListsZeroLengthColumnTest, SuperimposeNulls) void struct_from_scalar(bool is_valid) { - using LCW = cudf::test::lists_column_wrapper; - cudf::test::fixed_width_column_wrapper col0{1}; cudf::test::strings_column_wrapper col1{"abc"}; cudf::test::lists_column_wrapper col2{{1, 2, 3}}; - cudf::test::lists_column_wrapper col3{LCW{}}; + cudf::test::lists_column_wrapper col3{{}}; std::vector src_children({col0, col1, col2, col3}); auto value = cudf::struct_scalar(src_children, is_valid); diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index d4ca3a8b94be..e04af3bea801 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -964,14 +964,13 @@ TEST_F(StructsColumnTest, ConcatenateStructsNested) } // inner lists - using LCW = cudf::test::lists_column_wrapper; std::vector> inner_lists; { inner_lists.push_back(cudf::test::lists_column_wrapper{ - {"abc", "d"}, {"ef", "ghi", "j"}, {"klm", "no"}, LCW{}, LCW{"whee"}, {"xyz", "ab", "g"}}); + {"abc", "d"}, {"ef", "ghi", "j"}, {"klm", "no"}, {}, {"whee"}, {"xyz", "ab", "g"}}); inner_lists.push_back(cudf::test::lists_column_wrapper{ - {"er", "hyj"}, {"", "", "uvw"}, LCW{}, LCW{"oipq", "te"}, LCW{"yay", "bonk"}}); + {"er", "hyj"}, {"", "", "uvw"}, {}, {"oipq", "te"}, {"yay", "bonk"}}); } // build expected output @@ -1039,7 +1038,6 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists) // to disambiguate between {} == 0 and {} == List{0} // Also, see note about compiler issues when declaring nested // empty lists in lists_column_wrapper documentation - using LCW = cudf::test::lists_column_wrapper; { cudf::test::lists_column_wrapper a; cudf::test::lists_column_wrapper b{4, 5, 6, 7}; @@ -1061,9 +1059,9 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists) } { - cudf::test::lists_column_wrapper a{LCW{}}; + cudf::test::lists_column_wrapper a{{}}; cudf::test::lists_column_wrapper b{4, 5, 6, 7}; - cudf::test::lists_column_wrapper expected{LCW{}, {4, 5, 6, 7}}; + cudf::test::lists_column_wrapper expected{{}, {4, 5, 6, 7}}; auto result = cudf::concatenate(std::vector({a, b})); @@ -1071,9 +1069,9 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists) } { - cudf::test::lists_column_wrapper a{LCW{}}, b{LCW{}}, c{LCW{}}; + cudf::test::lists_column_wrapper a{{}}, b{{}}, c{{}}; cudf::test::lists_column_wrapper d{4, 5, 6, 7}; - cudf::test::lists_column_wrapper expected{LCW{}, LCW{}, LCW{}, {4, 5, 6, 7}}; + cudf::test::lists_column_wrapper expected{{}, {}, {}, {4, 5, 6, 7}}; auto result = cudf::concatenate(std::vector({a, b, c, d})); @@ -1082,9 +1080,9 @@ TEST_F(ListsColumnTest, ConcatenateEmptyLists) { cudf::test::lists_column_wrapper a{1, 2}; - cudf::test::lists_column_wrapper b{LCW{}}, c{LCW{}}; + cudf::test::lists_column_wrapper b{{}}, c{{}}; cudf::test::lists_column_wrapper d{4, 5, 6, 7}; - cudf::test::lists_column_wrapper expected{{1, 2}, LCW{}, LCW{}, {4, 5, 6, 7}}; + cudf::test::lists_column_wrapper expected{{1, 2}, {}, {}, {4, 5, 6, 7}}; auto result = cudf::concatenate(std::vector({a, b, c, d})); @@ -1154,10 +1152,10 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists) // empty lists in lists_column_wrapper documentation using LCW = cudf::test::lists_column_wrapper; { - cudf::test::lists_column_wrapper a{{LCW{}}, {{0, 1}, {2, 3}}}; - cudf::test::lists_column_wrapper b{{{6, 7}}, {LCW{}, {11, 12}}}; + cudf::test::lists_column_wrapper a{{{}}, {{0, 1}, {2, 3}}}; + cudf::test::lists_column_wrapper b{{{6, 7}}, {{}, {11, 12}}}; cudf::test::lists_column_wrapper expected{ - {LCW{}}, {{0, 1}, {2, 3}}, {{6, 7}}, {LCW{}, {11, 12}}}; + {{}}, {{0, 1}, {2, 3}}, {{6, 7}}, {{}, {11, 12}}}; auto result = cudf::concatenate(std::vector({a, b})); @@ -1166,24 +1164,24 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists) { cudf::test::lists_column_wrapper a{ - {{{0, 1, 2}, LCW{}}, {{5}, {6, 7}}, {{8, 9}}}, - {{LCW{}}, {{17, 18}, {19, 20}}}, - {{LCW{}}}, + {{{0, 1, 2}, {}}, {{5}, {6, 7}}, {{8, 9}}}, + {LCW::nested({{}}), {{17, 18}, {19, 20}}}, + {LCW::nested({{}})}, {{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}}}; cudf::test::lists_column_wrapper b{ - {{{21, 22}, {23, 24}}, {LCW{}, {26, 27}}, {{28, 29, 30}}}, + {{{21, 22}, {23, 24}}, {{}, {26, 27}}, {{28, 29, 30}}}, {{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}}, - {{LCW{}}}}; + {LCW::nested({{}})}}; cudf::test::lists_column_wrapper expected{ - {{{0, 1, 2}, LCW{}}, {{5}, {6, 7}}, {{8, 9}}}, - {{LCW{}}, {{17, 18}, {19, 20}}}, - {{LCW{}}}, + {{{0, 1, 2}, {}}, {{5}, {6, 7}}, {{8, 9}}}, + {LCW::nested({{}}), {{17, 18}, {19, 20}}}, + {LCW::nested({{}})}, {{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}}, - {{{21, 22}, {23, 24}}, {LCW{}, {26, 27}}, {{28, 29, 30}}}, + {{{21, 22}, {23, 24}}, {{}, {26, 27}}, {{28, 29, 30}}}, {{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}}, - {{LCW{}}}}; + {LCW::nested({{}})}}; auto result = cudf::concatenate(std::vector({a, b})); @@ -1230,24 +1228,24 @@ TEST_F(ListsColumnTest, ConcatenateMismatchedHierarchies) // empty lists in lists_column_wrapper documentation using LCW = cudf::test::lists_column_wrapper; { - cudf::test::lists_column_wrapper a{{{{LCW{}}}}}; - cudf::test::lists_column_wrapper b{{{LCW{}}}}; - cudf::test::lists_column_wrapper c{{LCW{}}}; + cudf::test::lists_column_wrapper a{{{LCW::nested({{}})}}}; + cudf::test::lists_column_wrapper b{{LCW::nested({{}})}}; + cudf::test::lists_column_wrapper c{{{}}}; EXPECT_THROW(cudf::concatenate(std::vector({a, b, c})), cudf::data_type_error); } { std::vector valids{false}; - cudf::test::lists_column_wrapper a{{{{{LCW{}}}}, valids.begin()}}; - cudf::test::lists_column_wrapper b{{{LCW{}}}}; - cudf::test::lists_column_wrapper c{{LCW{}}}; + cudf::test::lists_column_wrapper a{{{{LCW::nested({{}})}}, valids.begin()}}; + cudf::test::lists_column_wrapper b{{LCW::nested({{}})}}; + cudf::test::lists_column_wrapper c{{{}}}; EXPECT_THROW(cudf::concatenate(std::vector({a, b, c})), cudf::data_type_error); } { - cudf::test::lists_column_wrapper a{{{{LCW{}}}}}; + cudf::test::lists_column_wrapper a{{{LCW::nested({{}})}}}; cudf::test::lists_column_wrapper b{1, 2, 3}; cudf::test::lists_column_wrapper c{{3, 4, 5}}; @@ -1315,57 +1313,35 @@ TEST_F(ListsColumnTest, SlicedColumns) } { - cudf::test::lists_column_wrapper a{ - {{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, - {LCW{}, {LCW{}}, {{6, 6}, {2}}}, - {LCW{}, LCW{}}, - {LCW{}, LCW{}, {{10, 10, 10}, {11, 11}, {12, 12}}, LCW{}}}; + auto const empty = decltype(LCW::nested({})){}; + auto const a0 = + LCW::nested({{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}); + auto const a1 = LCW::nested({empty, LCW::nested({empty}), {{6, 6}, {2}}}); + auto const a2 = LCW::nested({{empty, empty}}); + auto const a3 = LCW::nested({empty, empty, {{10, 10, 10}, {11, 11}, {12, 12}}, empty}); + LCW a({a0, a1, a2, a3}); auto split_a = cudf::split(a, {2}); - cudf::test::lists_column_wrapper b{ - {{LCW{}}}, - {LCW{}, {LCW{}}}, - {{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, - {{LCW{}}}, - }; + auto const b0 = LCW::nested({LCW::nested({empty})}); + auto const b1 = LCW::nested({empty, LCW::nested({empty})}); + auto const b2 = LCW::nested({{{1, 2, 9}, empty}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}); + auto const b3 = LCW::nested({LCW::nested({empty})}); + LCW b({b0, b1, b2, b3}); auto split_b = cudf::split(b, {2}); - cudf::test::lists_column_wrapper expected0{ - {{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, - {LCW{}, {LCW{}}, {{6, 6}, {2}}}, - {{LCW{}}}, - {LCW{}, {LCW{}}}}; - + LCW expected0({a0, a1, b0, b1}); auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - cudf::test::lists_column_wrapper expected1{ - {{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, - {LCW{}, {LCW{}}, {{6, 6}, {2}}}, - {{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, - {{LCW{}}}, - }; - + LCW expected1({a0, a1, b2, b3}); auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - cudf::test::lists_column_wrapper expected2{ - {LCW{}, LCW{}}, - {LCW{}, LCW{}, {{10, 10, 10}, {11, 11}, {12, 12}}, LCW{}}, - {{LCW{}}}, - {LCW{}, {LCW{}}}}; - + LCW expected2({a2, a3, b0, b1}); auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - cudf::test::lists_column_wrapper expected3{ - {LCW{}, LCW{}}, - {LCW{}, LCW{}, {{10, 10, 10}, {11, 11}, {12, 12}}, LCW{}}, - {{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, - {{LCW{}}}, - }; - + LCW expected3({a2, a3, b2, b3}); auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } @@ -1378,112 +1354,71 @@ TEST_F(ListsColumnTest, SlicedColumnsWithNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); { - cudf::test::lists_column_wrapper a{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, - {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}}; + auto const a0 = LCW::nested({{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}); + auto const a1 = LCW::nested({{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids); + auto const a2 = LCW::nested({{7, 7, 7}, {8, 8}, {9, 9}}); + auto const a3 = LCW::nested({{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids); + LCW a({a0, a1, a2, a3}); auto split_a = cudf::split(a, {3}); - cudf::test::lists_column_wrapper b{{{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, - {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, - {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}, - {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; + auto const b0 = LCW::nested({{{-1, -1, -1, -1}, valids}, {-2}}, valids); + auto const b1 = LCW::nested({{{-3, -3, -3, -3}, valids}, {-4}}, valids); + auto const b2 = LCW::nested({{{-5, -5, -5, -5}, valids}, {-6}}, valids); + auto const b3 = LCW::nested({{{-7, -7, -7, -7}, valids}, {-8}}, valids); + LCW b({b0, b1, b2, b3}); auto split_b = cudf::split(b, {3}); - cudf::test::lists_column_wrapper expected0{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, - {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, - {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, - {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}}; - + LCW expected0({a0, a1, a2, b0, b1, b2}); auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - cudf::test::lists_column_wrapper expected1{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, - {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; - + LCW expected1({a0, a1, a2, b3}); auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - cudf::test::lists_column_wrapper expected2{ - {{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}, - {{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, - {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, - {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}}; - + LCW expected2({a3, b0, b1, b2}); auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - cudf::test::lists_column_wrapper expected3{ - {{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}, - {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; - + LCW expected3({a3, b3}); auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } { - cudf::test::lists_column_wrapper a{ - {{{{1, 1, 1}, valids}, {2, 2}}, - {{{3, 3}}, valids}, - {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, - {{LCW{}, {{LCW{}}, valids}, {{6, 6}, {2}}}, valids}, - {{{LCW{}, LCW{}}, valids}}, - {LCW{}, LCW{}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, LCW{}}}; + auto const a0 = + LCW::nested({LCW::nested({{{1, 1, 1}, valids}, {2, 2}}), + LCW::nested({{3, 3}}, valids), + LCW::nested({{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}})}); + auto const a1 = + LCW::nested({{}, LCW::nested({{}}, valids), LCW::nested({{6, 6}, {2}})}, valids); + auto const a2 = LCW::nested({LCW::nested({{}, {}}, valids)}); + auto const a3 = + LCW::nested({{}, {}, LCW::nested({{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids), {}}); + LCW a({a0, a1, a2, a3}); auto split_a = cudf::split(a, {3}); - cudf::test::lists_column_wrapper b{ - {{{LCW{}}, valids}}, - {{LCW{}, {{LCW{}}, valids}}, valids}, - {{{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, - {{LCW{}}}, - }; + auto const b0 = LCW::nested({LCW::nested({{}}, valids)}); + auto const b1 = LCW::nested({{}, LCW::nested({{}}, valids)}, valids); + auto const b2 = LCW::nested( + {LCW::nested({{1, 2, 9}, {}}), LCW::nested({{5, 6, 7, 8, 9}, {0}, {15, 17}})}, valids); + auto const b3 = LCW::nested({{}}); + LCW b({b0, b1, b2, b3}); auto split_b = cudf::split(b, {3}); - cudf::test::lists_column_wrapper expected0{ - {{{{1, 1, 1}, valids}, {2, 2}}, - {{{3, 3}}, valids}, - {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, - {{LCW{}, {{LCW{}}, valids}, {{6, 6}, {2}}}, valids}, - {{{LCW{}, LCW{}}, valids}}, - {{{LCW{}}, valids}}, - {{LCW{}, {{LCW{}}, valids}}, valids}, - {{{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, - }; - + LCW expected0({a0, a1, a2, b0, b1, b2}); auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - cudf::test::lists_column_wrapper expected1{ - {{{{1, 1, 1}, valids}, {2, 2}}, - {{{3, 3}}, valids}, - {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, - {{LCW{}, {{LCW{}}, valids}, {{6, 6}, {2}}}, valids}, - {{{LCW{}, LCW{}}, valids}}, - {{LCW{}}}, - }; - + LCW expected1({a0, a1, a2, b3}); auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - cudf::test::lists_column_wrapper expected2{ - {LCW{}, LCW{}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, LCW{}}, - {{{LCW{}}, valids}}, - {{LCW{}, {{LCW{}}, valids}}, valids}, - {{{{1, 2, 9}, LCW{}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, - }; - + LCW expected2({a3, b0, b1, b2}); auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - cudf::test::lists_column_wrapper expected3{ - {LCW{}, LCW{}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, LCW{}}, - {{LCW{}}}, - }; - + LCW expected3({a3, b3}); auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } diff --git a/cpp/tests/copying/copy_if_else_nested_tests.cpp b/cpp/tests/copying/copy_if_else_nested_tests.cpp index 59c000e20fbe..a81445ebec11 100644 --- a/cpp/tests/copying/copy_if_else_nested_tests.cpp +++ b/cpp/tests/copying/copy_if_else_nested_tests.cpp @@ -280,8 +280,8 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ListsWithNulls) auto lhs = lcw{{{0, 0}, {1, 1}, - lcw{{2, 2}, null_at_0}, - lcw{{3, 3, 3}, null_at_0}, + {{2, 2}, null_at_0}, + {{3, 3, 3}, null_at_0}, {4, 4, 4, 4}, {5, 5, 5, 5, 5}, {6, 6, 6, 6, 6, 6}}, @@ -306,8 +306,7 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ListsWithNulls) auto null_at_4_5 = nulls_at(std::vector{4, 5}); auto expected_output = - lcw{{{0, 0}, {1, 1}, {22, 22}, lcw{{3, 3, 3}, null_at_0}, {}, {}, {6, 6, 6, 6, 6, 6}}, - null_at_4_5} + lcw{{{0, 0}, {1, 1}, {22, 22}, {{3, 3, 3}, null_at_0}, {}, {}, {6, 6, 6, 6, 6, 6}}, null_at_4_5} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result_column->view(), expected_output->view()); @@ -380,7 +379,7 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ScalarListBothInvalid) auto selector_column = bools{1, 1, 0, 1, 1, 0, 1}.release(); - auto expected = lcw{{lcw{}, lcw{}, lcw{}, lcw{}, lcw{}, lcw{}, lcw{}}, all_nulls()}.release(); + auto expected = lcw{{{}, {}, {}, {}, {}, {}, {}}, all_nulls()}.release(); auto result = cudf::copy_if_else(lhs_scalar, rhs_scalar, selector_column->view()); @@ -402,13 +401,13 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ScalarListBothValid) auto expected = lcw{ - lcw{{33, 33, 33}, null_at(1)}, - lcw{{33, 33, 33}, null_at(1)}, - lcw{{22, 22}, null_at(0)}, - lcw{{33, 33, 33}, null_at(1)}, - lcw{{33, 33, 33}, null_at(1)}, - lcw{{22, 22}, null_at(0)}, - lcw{{33, 33, 33}, null_at(1)}, + {{33, 33, 33}, null_at(1)}, + {{33, 33, 33}, null_at(1)}, + {{22, 22}, null_at(0)}, + {{33, 33, 33}, null_at(1)}, + {{33, 33, 33}, null_at(1)}, + {{22, 22}, null_at(0)}, + {{33, 33, 33}, null_at(1)}, } .release(); @@ -430,20 +429,20 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ScalarListLeft) {21, 22}, {-20, -10, 0}, {-200, -100, 0, 100}, - lcw{{23, 24, 25, 26, 27, 28}, null_at(1)}, + {{23, 24, 25, 26, 27, 28}, null_at(1)}, {-400}}, null_at(2)} .release(); auto selector_column = bools{1, 1, 0, 1, 1, 0, 1}.release(); - auto expected = lcw{{lcw{{33, 33, 33}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}, + auto expected = lcw{{{{33, 33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, {-21, -22}, - lcw{{33, -33, 33}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}, - lcw{{23, -24, 25, 26, 27, 28}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}}, + {{33, -33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, + {{23, -24, 25, 26, 27, 28}, null_at(1)}, + {{33, -33, 33}, null_at(1)}}, null_at(2)} .release(); @@ -465,7 +464,7 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ScalarListRight) {21, 22}, {-20, -10, 0}, {-200, -100, 0, 100}, - lcw{{23, 24, 25, 26, 27, 28}, null_at(1)}, + {{23, 24, 25, 26, 27, 28}, null_at(1)}, {-400}}, null_at(2)} .release(); @@ -475,13 +474,13 @@ TYPED_TEST(TypedCopyIfElseNestedTest, ScalarListRight) auto selector_column = bools{0, 0, 1, 0, 0, 1, 0}.release(); auto expected = lcw{{ - lcw{{33, -33, 33}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, {-21, -22}, - lcw{{33, -33, 33}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}, - lcw{{23, -24, 25, 26, 27, 28}, null_at(1)}, - lcw{{33, -33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, + {{23, -24, 25, 26, 27, 28}, null_at(1)}, + {{33, -33, 33}, null_at(1)}, }, null_at(2)} .release(); diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 307af4687ab9..14ebac22e695 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -72,11 +72,10 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) // List { - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list{{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, stream, mr}; cudf::test::fixed_width_column_wrapper gather_map{}; - auto const list_col = LCW(list, stream, mr); - cudf::table_view source_table({list_col}); + cudf::table_view source_table({list}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); diff --git a/cpp/tests/copying/get_value_tests.cpp b/cpp/tests/copying/get_value_tests.cpp index 4968fc03d133..f3062612de84 100644 --- a/cpp/tests/copying/get_value_tests.cpp +++ b/cpp/tests/copying/get_value_tests.cpp @@ -184,7 +184,7 @@ TYPED_TEST(ListGetFixedWidthValueTest, NonNestedGetNonNullNonEmpty) { using LCW = cudf::test::lists_column_wrapper; - LCW col{LCW({1, 2, 34}, this->odds_valid()), LCW{}, LCW{1}, LCW{}}; + LCW col{{{1, 2, 34}, this->odds_valid()}, {}, {1}, {}}; cudf::test::fixed_width_column_wrapper expected_data({1, 2, 34}, this->odds_valid()); cudf::size_type index = 0; @@ -199,7 +199,7 @@ TYPED_TEST(ListGetFixedWidthValueTest, NonNestedGetNonNullEmpty) { using LCW = cudf::test::lists_column_wrapper; - LCW col{LCW{1, 2, 34}, LCW{}, LCW{1}, LCW{}}; + LCW col{{1, 2, 34}, {}, {1}, {}}; cudf::test::fixed_width_column_wrapper expected_data{}; cudf::size_type index = 1; @@ -215,7 +215,7 @@ TYPED_TEST(ListGetFixedWidthValueTest, NonNestedGetNull) using LCW = cudf::test::lists_column_wrapper; using FCW = cudf::test::fixed_width_column_wrapper; - LCW col({LCW{1, 2, 34}, LCW{}, LCW{1}, LCW{}}, this->odds_valid()); + LCW col({{1, 2, 34}, {}, {1}, {}}, this->odds_valid()); cudf::size_type index = 2; auto s = cudf::get_element(col, index); @@ -232,13 +232,13 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullNonEmpty) // clang-format off LCW col{ - LCW{LCW{1, 2}, LCW{34}}, - LCW{}, - LCW{LCW{1}}, - LCW{LCW{42}, LCW{10}} + {{1, 2}, {34}}, + {}, + LCW::nested({{1}}), + LCW::nested({{42}, {10}}) }; // clang-format on - LCW expected_data{LCW{42}, LCW{10}}; + LCW expected_data({{42}, {10}}); cudf::size_type index = 3; @@ -256,13 +256,13 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullNonEmptyPreserveNull) std::vector valid{0, 1, 1}; // clang-format off LCW col{ - LCW{LCW{1, 2}, LCW{34}}, - LCW{}, - LCW{LCW{1}}, - LCW({LCW{42}, LCW{10}, LCW({1, 3, 2}, this->nth_valid(1))}, valid.begin()) + {{1, 2}, {34}}, + {}, + LCW::nested({{1}}), + LCW::nested({{42}, {10}, {{1, 3, 2}, this->nth_valid(1)}}, valid.begin()) }; // clang-format on - LCW expected_data({LCW{42}, LCW{10}, LCW({1, 3, 2}, this->nth_valid(1))}, valid.begin()); + LCW expected_data({{42}, {10}, {{1, 3, 2}, this->nth_valid(1)}}, valid.begin()); cudf::size_type index = 3; auto s = cudf::get_element(col, index); @@ -278,10 +278,10 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullEmpty) // clang-format off LCW col{ - LCW{LCW{1, 2}, LCW{34}}, - LCW{}, - LCW{LCW{1}}, - LCW{LCW{42}, LCW{10}} + {{1, 2}, {34}}, + {}, + LCW::nested({{1}}), + LCW::nested({{42}, {10}}) }; // clang-format on LCW expected_data{}; @@ -304,10 +304,10 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNull) // clang-format off LCW col( { - LCW{LCW{1, 2}, LCW{34}}, - LCW{}, - LCW{LCW{1}}, - LCW{LCW{42}, LCW{10}} + LCW::nested({{1, 2}, {34}}), + {}, + LCW::nested({{1}}), + LCW::nested({{42}, {10}}) }, valid.begin()); // clang-format on cudf::size_type index = 1; @@ -335,7 +335,7 @@ TEST_F(ListGetStringValueTest, NonNestedGetNonNullNonEmpty) { using LCW = cudf::test::lists_column_wrapper; - LCW col{LCW({"aaa", "Héllo"}, this->odds_valid()), LCW{}, LCW{""}, LCW{"42"}}; + LCW col{{{"aaa", "Héllo"}, this->odds_valid()}, {}, {""}, {"42"}}; cudf::test::strings_column_wrapper expected_data({"", "Héllo"}, this->odds_valid()); cudf::size_type index = 0; @@ -350,7 +350,7 @@ TEST_F(ListGetStringValueTest, NonNestedGetNonNullEmpty) { using LCW = cudf::test::lists_column_wrapper; - LCW col{LCW{"aaa", "Héllo"}, LCW{}, LCW{""}, LCW{"42"}}; + LCW col{{"aaa", "Héllo"}, {}, {""}, {"42"}}; cudf::test::strings_column_wrapper expected_data{}; cudf::size_type index = 1; @@ -367,7 +367,7 @@ TEST_F(ListGetStringValueTest, NonNestedGetNull) using StringCW = cudf::test::strings_column_wrapper; std::vector valid{1, 0, 0, 1}; - LCW col({LCW{"aaa", "Héllo"}, LCW{}, LCW{""}, LCW{"42"}}, valid.begin()); + LCW col({{"aaa", "Héllo"}, {}, {""}, {"42"}}, valid.begin()); cudf::size_type index = 2; auto s = cudf::get_element(col, index); @@ -383,13 +383,13 @@ TEST_F(ListGetStringValueTest, NestedGetNonNullNonEmpty) // clang-format off LCW col{ - LCW{LCW{"aaa", "Héllo"}}, - LCW{}, - LCW{LCW{""}, LCW({"string", "str2", "xyz"}, this->nth_valid(0))}, - LCW{LCW{"42"}, LCW{"21"}} + {{"aaa", "Héllo"}}, + {}, + LCW::nested({{""}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}), + LCW::nested({{"42"}, {"21"}}) }; // clang-format on - LCW expected_data{LCW{""}, LCW({"string", "str2", "xyz"}, this->nth_valid(0))}; + LCW expected_data{{""}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}; cudf::size_type index = 2; auto s = cudf::get_element(col, index); @@ -406,14 +406,13 @@ TEST_F(ListGetStringValueTest, NestedGetNonNullNonEmptyPreserveNull) std::vector valid{0, 1, 1}; // clang-format off LCW col{ - LCW{LCW{"aaa", "Héllo"}}, - LCW{}, - LCW({LCW{""}, LCW{"cc"}, LCW({"string", "str2", "xyz"}, this->nth_valid(0))}, valid.begin()), - LCW{LCW{"42"}, LCW{"21"}} + {{"aaa", "Héllo"}}, + {}, + LCW::nested({{""}, {"cc"}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}, valid.begin()), + LCW::nested({{"42"}, {"21"}}) }; // clang-format on - LCW expected_data({LCW{""}, LCW{"cc"}, LCW({"string", "str2", "xyz"}, this->nth_valid(0))}, - valid.begin()); + LCW expected_data({{""}, {"cc"}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}, valid.begin()); cudf::size_type index = 2; auto s = cudf::get_element(col, index); @@ -429,10 +428,10 @@ TEST_F(ListGetStringValueTest, NestedGetNonNullEmpty) // clang-format off LCW col{ - LCW{LCW{"aaa", "Héllo"}}, - LCW{LCW{""}}, - LCW{LCW{"42"}, LCW{"21"}}, - LCW{} + {{"aaa", "Héllo"}}, + LCW::nested({{""}}), + LCW::nested({{"42"}, {"21"}}), + {} }; // clang-format on LCW expected_data{}; @@ -457,10 +456,10 @@ TEST_F(ListGetStringValueTest, NestedGetNull) // clang-format off LCW col( { - LCW{LCW{"aaa", "Héllo"}}, - LCW{LCW{""}}, - LCW{LCW{"42"}, LCW{"21"}}, - LCW{} + LCW::nested({{"aaa", "Héllo"}}), + LCW::nested({{""}}), + LCW::nested({{"42"}, {"21"}}), + {} }, valid.begin()); // clang-format on cudf::size_type index = 0; @@ -788,7 +787,7 @@ TYPED_TEST(StructGetValueTestTyped, mixed_types_valid) cudf::test::fixed_width_column_wrapper f1{1, 2, 3}; cudf::test::strings_column_wrapper f2{"aa", "bbb", "c"}; cudf::test::dictionary_column_wrapper f3{42, 42, 24}; - LCW f4{LCW{8, 8, 8}, LCW{9, 9}, LCW{10}}; + LCW f4{{8, 8, 8}, {9, 9}, {10}}; cudf::test::structs_column_wrapper col{f1, f2, f3, f4}; @@ -800,7 +799,7 @@ TYPED_TEST(StructGetValueTestTyped, mixed_types_valid) cudf::test::fixed_width_column_wrapper ef1{3}; cudf::test::strings_column_wrapper ef2{"c"}; cudf::test::dictionary_column_wrapper ef3{24}; - LCW ef4{LCW{10}}; + LCW ef4{{10}}; // keys need to match so dictionaries can be compared auto def3 = cudf::dictionary::set_keys(cudf::dictionary_column_view(ef3), @@ -822,7 +821,7 @@ TYPED_TEST(StructGetValueTestTyped, mixed_types_valid_with_nulls) cudf::test::strings_column_wrapper f2({"", "", "c"}, {false, false, true}); cudf::test::dictionary_column_wrapper f3( {42, 42, 24}, validity_mask_t{true, true, true}.begin()); - LCW f4({LCW{8, 8, 8}, LCW{9, 9}, LCW{10}}, validity_mask_t{false, false, false}.begin()); + LCW f4({{8, 8, 8}, {9, 9}, {10}}, validity_mask_t{false, false, false}.begin()); cudf::test::structs_column_wrapper col{f1, f2, f3, f4}; @@ -839,7 +838,7 @@ TYPED_TEST(StructGetValueTestTyped, mixed_types_valid_with_nulls) cudf::test::fixed_width_column_wrapper new_key{24}; auto ef3 = cudf::dictionary::add_keys(dict_col, new_key); - LCW ef4({LCW{10}}, validity_mask_t{false}.begin()); + LCW ef4({{10}}, validity_mask_t{false}.begin()); cudf::table_view expect_data{{ef1, ef2, *ef3, ef4}}; @@ -856,7 +855,7 @@ TYPED_TEST(StructGetValueTestTyped, mixed_types_invalid) cudf::test::fixed_width_column_wrapper f1{1, 2, 3}; cudf::test::strings_column_wrapper f2{"aa", "bbb", "c"}; cudf::test::dictionary_column_wrapper f3{42, 42, 24}; - LCW f4{LCW{8, 8, 8}, LCW{9, 9}, LCW{10}}; + LCW f4{{8, 8, 8}, {9, 9}, {10}}; cudf::test::structs_column_wrapper col({f1, f2, f3, f4}, validity_mask_t{false, true, true}.begin()); @@ -882,7 +881,7 @@ TEST_F(StructGetValueTest, multi_level_nested) using validity_mask_t = std::vector; // col fields - LCW l3({LCW{1, 1, 1}, LCW{2, 2}, LCW{3}}, validity_mask_t{false, true, true}.begin()); + LCW l3({{1, 1, 1}, {2, 2}, {3}}, validity_mask_t{false, true, true}.begin()); cudf::test::structs_column_wrapper l2{l3}; auto l1 = cudf::make_lists_column(1, cudf::test::fixed_width_column_wrapper{0, 3}.release(), diff --git a/cpp/tests/copying/pack_tests.cpp b/cpp/tests/copying/pack_tests.cpp index 7544814884c3..7c6915275a21 100644 --- a/cpp/tests/copying/pack_tests.cpp +++ b/cpp/tests/copying/pack_tests.cpp @@ -144,20 +144,20 @@ std::vector> generate_lists(bool include_validity) {6}, {{7, 8}, valids}, {9, 10, 11}, - LCW{}, - LCW{}, + {}, + {}, {{-1, -2, -3, -4, -5}, valids}, {{100, -200}, valids}}; cudf::test::lists_column_wrapper list1{{{{1, 2, 3}, valids}, {4, 5}}, - {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, - {LCW{6}}, - {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, - {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, - {LCW{}}, - {LCW{-10}, {-100, -200}}, - {{-10, -200}, LCW{}, {8, 9}}, - {LCW{8}, LCW{}, LCW{9}, {5, 6}}}; + {{{}, {}, {7, 8}, {}}, valids}, + LCW::nested({{6}}), + {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, + {{{}, {-1, -2, -3, -4, -5}}, valids}, + LCW::nested({{}}), + {{-10}, {-100, -200}}, + {{-10, -200}, {}, {8, 9}}, + {{8}, {}, {9}, {5, 6}}}; std::vector> out; out.push_back(list0.release()); @@ -166,17 +166,17 @@ std::vector> generate_lists(bool include_validity) } cudf::test::lists_column_wrapper list0{ - {1, 2, 3}, {4, 5}, {6}, {7, 8}, {9, 10, 11}, LCW{}, LCW{}, {-1, -2, -3, -4, -5}, {-100, -200}}; + {1, 2, 3}, {4, 5}, {6}, {7, 8}, {9, 10, 11}, {}, {}, {-1, -2, -3, -4, -5}, {-100, -200}}; cudf::test::lists_column_wrapper list1{{{1, 2, 3}, {4, 5}}, - {LCW{}, LCW{}, {7, 8}, LCW{}}, - {LCW{6}}, - {{7, 8}, {9, 10, 11}, LCW{}}, - {LCW{}, {-1, -2, -3, -4, -5}}, - {LCW{}}, + {{}, {}, {7, 8}, {}}, + LCW::nested({{6}}), + {{7, 8}, {9, 10, 11}, {}}, + {{}, {-1, -2, -3, -4, -5}}, + LCW::nested({{}}), {{-10}, {-100, -200}}, - {{-10, -200}, LCW{}, {8, 9}}, - {LCW{8}, LCW{}, LCW{9}, {5, 6}}}; + {{-10, -200}, {}, {8, 9}}, + {{8}, {}, {9}, {5, 6}}}; std::vector> out; out.push_back(list0.release()); @@ -240,14 +240,14 @@ std::vector> generate_struct_of_list() std::vector list_validity{true, true, true, true, true, false, true, false, true}; cudf::test::lists_column_wrapper list( {{{"abc", "d", "edf"}, {"jjj"}}, - {{"dgaer", "-7"}, LCW{}}, - {LCW{}}, + {{"dgaer", "-7"}, {}}, + LCW::nested({{}}), {{"qwerty"}, {"ral", "ort", "tal"}, {"five", "six"}}, - {LCW{}, LCW{}, {"eight", "nine"}}, - {LCW{}}, + {{}, {}, {"eight", "nine"}}, + LCW::nested({{}}), {{"fun"}, {"a", "bc", "def", "ghij", "klmno", "pqrstu"}}, - {{"seven", "zz"}, LCW{}, {"xyzzy"}}, - {LCW{"negative 3", " ", "cleveland"}}}, + {{"seven", "zz"}, {}, {"xyzzy"}}, + LCW::nested({{"negative 3", " ", "cleveland"}})}, list_validity.begin()); // Assemble struct column. @@ -517,11 +517,11 @@ TEST_F(PackUnpackTest, NestedSliced) using LCW = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col0{{{{1, 2, 3}, valids}, {4, 5}}, - {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, + {{{}, {}, {7, 8}, {}}, valids}, {{6, 12}}, - {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, - {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, - {LCW{}}, + {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, + {{{}, {-1, -2, -3, -4, -5}}, valids}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; cudf::test::strings_column_wrapper col1{ diff --git a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp index e7c6c6766dc4..1460da4092d4 100644 --- a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp +++ b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp @@ -144,10 +144,7 @@ TEST_F(PurgeNonEmptyNullsTest, SingleLevelList) // Test when gather selects unsanitized row specifically. auto const results = gather(input->view(), {2}); auto const results_lists_view = cudf::lists_column_view(*results); - auto const expected = LCW{{ - LCW{} // NULL. - }, - null_at(0)}; + auto const expected = LCW{{{}}, null_at(0)}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.offsets(), offsets_col_t{0, 0}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.child(), values_col_t{}); @@ -185,8 +182,8 @@ TEST_F(PurgeNonEmptyNullsTest, TwoLevelList) auto const results_lists_view = cudf::lists_column_view(*results); auto const expected = LCW{{ - LCW{}, // NULL, because of out of bounds. - LCW{}, // NULL, because input row was null. + {}, // NULL, because of out of bounds. + {}, // NULL, because input row was null. {{1, 2, 3}, {4, 5, 6, 7}, {8}, {9, 1}, {2}}, // i.e. input[0] {{11, 12}, {13, 14, 15}, {16, 17, 18}, {19}} // i.e. input[1] }, @@ -240,8 +237,8 @@ TEST_F(PurgeNonEmptyNullsTest, ThreeLevelList) auto const expected = LCW{ { - LCW{}, // NULL, because of out of bounds. - LCW{}, // NULL, because input row was null. + {}, // NULL, because of out of bounds. + {}, // NULL, because input row was null. {{{1, 2}, {3}}, {{4, 5}, {6, 7}}, {{8, 8}, {}}, {{9, 1}}, {{2, 3}}}, // i.e. input[0] {{{11, 12}}, {{13}, {14, 15}}, {{16, 17, 18}}, {{19, 19}, {}}} // i.e. input[1] }, @@ -444,7 +441,7 @@ TEST_F(PurgeNonEmptyNullsTest, StructOfList) auto const result = gather(structs_input->view(), gather_map); auto const expected_result = [] { auto child = LCW{{{5}, - LCW{}, //<--- Now, sanitized. + {}, //<--- Now, sanitized. {{1, 2, 3, 4}, null_at(2)}, {8, 9, 10}}, null_at(1)}; diff --git a/cpp/tests/copying/scatter_list_scalar_tests.cpp b/cpp/tests/copying/scatter_list_scalar_tests.cpp index 205d1c30773e..b954cbe58f88 100644 --- a/cpp/tests/copying/scatter_list_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_list_scalar_tests.cpp @@ -43,13 +43,13 @@ TYPED_TEST(ScatterListOfFixedWidthScalarTest, Basic) using FCW = cudf::test::fixed_width_column_wrapper; auto slr = std::make_unique(FCW({2, 2, 2}, {1, 0, 1}), true); - LCW col{LCW{1, 1, 1}, LCW{8, 8}, LCW{10, 10, 10, 10}, LCW{5}}; + LCW col{{1, 1, 1}, {8, 8}, {10, 10, 10, 10}, {5}}; size_column scatter_map{3, 1, 0}; - LCW expected{LCW({2, 2, 2}, mask_vector{1, 0, 1}.begin()), - LCW({2, 2, 2}, mask_vector{1, 0, 1}.begin()), - LCW{10, 10, 10, 10}, - LCW({2, 2, 2}, mask_vector{1, 0, 1}.begin())}; + LCW expected{{{2, 2, 2}, mask_vector{1, 0, 1}.begin()}, + {{2, 2, 2}, mask_vector{1, 0, 1}.begin()}, + {10, 10, 10, 10}, + {{2, 2, 2}, mask_vector{1, 0, 1}.begin()}}; auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); } @@ -60,15 +60,10 @@ TYPED_TEST(ScatterListOfFixedWidthScalarTest, EmptyValidScalar) using FCW = cudf::test::fixed_width_column_wrapper; auto slr = std::make_unique(FCW{}, true); - LCW col{LCW{1, 1, 1}, - LCW{8, 8}, - LCW({10, 10, 10, 10}, mask_vector{1, 0, 1, 0}.begin()), - LCW{5}, - LCW{42, 42}}; + LCW col{{1, 1, 1}, {8, 8}, {{10, 10, 10, 10}, mask_vector{1, 0, 1, 0}.begin()}, {5}, {42, 42}}; size_column scatter_map{1, 0}; - LCW expected{ - LCW{}, LCW{}, LCW({10, 10, 10, 10}, mask_vector{1, 0, 1, 0}.begin()), LCW{5}, LCW{42, 42}}; + LCW expected{{}, {}, {{10, 10, 10, 10}, mask_vector{1, 0, 1, 0}.begin()}, {5}, {42, 42}}; auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); } @@ -79,10 +74,10 @@ TYPED_TEST(ScatterListOfFixedWidthScalarTest, NullScalar) using FCW = cudf::test::fixed_width_column_wrapper; auto slr = std::make_unique(FCW{}, false); - LCW col{LCW({1, 1, 1}, mask_vector{0, 0, 1}.begin()), LCW{8, 8}, LCW{10, 10, 10, 10}, LCW{5}}; + LCW col{{{1, 1, 1}, mask_vector{0, 0, 1}.begin()}, {8, 8}, {10, 10, 10, 10}, {5}}; size_column scatter_map{3, 1}; - LCW expected({LCW({1, 1, 1}, mask_vector{0, 0, 1}.begin()), LCW{}, LCW{10, 10, 10, 10}, LCW{}}, + LCW expected({{{1, 1, 1}, mask_vector{0, 0, 1}.begin()}, {}, {10, 10, 10, 10}, {}}, mask_vector{1, 0, 1, 0}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -94,12 +89,10 @@ TYPED_TEST(ScatterListOfFixedWidthScalarTest, NullableTargetRow) using FCW = cudf::test::fixed_width_column_wrapper; auto slr = std::make_unique(FCW{9, 9}, true); - LCW col({LCW{4, 4}, LCW{}, LCW{8, 8, 8}, LCW{}, LCW{9, 9, 9}}, - mask_vector{1, 0, 1, 0, 1}.begin()); + LCW col({{4, 4}, {}, {8, 8, 8}, {}, {9, 9, 9}}, mask_vector{1, 0, 1, 0, 1}.begin()); size_column scatter_map{0, 1}; - LCW expected({LCW{9, 9}, LCW{9, 9}, LCW{8, 8, 8}, LCW{}, LCW{9, 9, 9}}, - mask_vector{1, 1, 1, 0, 1}.begin()); + LCW expected({{9, 9}, {9, 9}, {8, 8, 8}, {}, {9, 9, 9}}, mask_vector{1, 1, 1, 0, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); } @@ -115,15 +108,15 @@ TEST_F(ScatterListOfStringScalarTest, Basic) StringCW({"Hello!", "", "你好!", "صباح الخير!", "", "こんにちは!"}, {true, false, true, true, false, true}), true); - LCW col{LCW({"xx", "yy"}, mask_vector{0, 1}.begin()), LCW{""}, LCW{"a", "bab", "bacab"}}; + LCW col{{{"xx", "yy"}, mask_vector{0, 1}.begin()}, {""}, {"a", "bab", "bacab"}}; size_column scatter_map{2, 1}; - LCW expected{LCW({"xx", "yy"}, mask_vector{0, 1}.begin()), - LCW({"Hello!", "", "你好!", "صباح الخير!", "", "こんにちは!"}, - mask_vector{1, 0, 1, 1, 0, 1}.begin()), - LCW({"Hello!", "", "你好!", "صباح الخير!", "", "こんにちは!"}, - mask_vector{1, 0, 1, 1, 0, 1}.begin())}; + LCW expected{{{"xx", "yy"}, mask_vector{0, 1}.begin()}, + {{"Hello!", "", "你好!", "صباح الخير!", "", "こんにちは!"}, + mask_vector{1, 0, 1, 1, 0, 1}.begin()}, + {{"Hello!", "", "你好!", "صباح الخير!", "", "こんにちは!"}, + mask_vector{1, 0, 1, 1, 0, 1}.begin()}}; auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -136,14 +129,11 @@ TEST_F(ScatterListOfStringScalarTest, EmptyValidScalar) auto slr = std::make_unique(StringCW{}, true); - LCW col{LCW({"xx", "yy"}, mask_vector{0, 1}.begin()), - LCW{""}, - LCW{"a", "bab", "bacab"}, - LCW{"888", "777"}}; + LCW col{{{"xx", "yy"}, mask_vector{0, 1}.begin()}, {""}, {"a", "bab", "bacab"}, {"888", "777"}}; size_column scatter_map{0, 3}; - LCW expected{LCW{}, LCW{""}, LCW{"a", "bab", "bacab"}, LCW{}}; + LCW expected{{}, {""}, {"a", "bab", "bacab"}, {}}; auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -155,14 +145,11 @@ TEST_F(ScatterListOfStringScalarTest, NullScalar) using StringCW = cudf::test::strings_column_wrapper; auto slr = std::make_unique(StringCW{}, false); - LCW col{LCW{"xx", "yy"}, - LCW({""}, mask_vector{0}.begin()), - LCW{"a", "bab", "bacab"}, - LCW{"888", "777"}}; + LCW col{{"xx", "yy"}, {{""}, mask_vector{0}.begin()}, {"a", "bab", "bacab"}, {"888", "777"}}; size_column scatter_map{1, 2}; - LCW expected({LCW{"xx", "yy"}, LCW{}, LCW{}, LCW{"888", "777"}}, mask_vector{1, 0, 0, 1}.begin()); + LCW expected({{"xx", "yy"}, {}, {}, {"888", "777"}}, mask_vector{1, 0, 0, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -175,15 +162,15 @@ TEST_F(ScatterListOfStringScalarTest, NullableTargetRow) auto slr = std::make_unique( StringCW({"Hello!", "", "こんにちは!"}, {true, false, true}), true); - LCW col({LCW{"xx", "yy"}, LCW({""}, mask_vector{0}.begin()), LCW{}, LCW{"888", "777"}}, + LCW col({{"xx", "yy"}, {{""}, mask_vector{0}.begin()}, {}, {"888", "777"}}, mask_vector{1, 1, 0, 1}.begin()); size_column scatter_map{3, 2}; - LCW expected({LCW{"xx", "yy"}, - LCW({""}, mask_vector{0}.begin()), - LCW({"Hello!", "", "こんにちは!"}, mask_vector{1, 0, 1}.begin()), - LCW({"Hello!", "", "こんにちは!"}, mask_vector{1, 0, 1}.begin())}, + LCW expected({{"xx", "yy"}, + {{""}, mask_vector{0}.begin()}, + {{"Hello!", "", "こんにちは!"}, mask_vector{1, 0, 1}.begin()}, + {{"Hello!", "", "こんにちは!"}, mask_vector{1, 0, 1}.begin()}}, mask_vector{1, 1, 1, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); @@ -200,18 +187,18 @@ TYPED_TEST(ScatterListOfListScalarTest, Basic) using LCW = cudf::test::lists_column_wrapper; auto slr = std::make_unique( - LCW({LCW{1, 2, 3}, LCW{4}, LCW{}, LCW{5, 6}}, mask_vector{1, 1, 0, 1}.begin()), true); - LCW col({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW{LCW{66}, LCW{}, LCW({77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin())}, - LCW{LCW{55, 55}, LCW{}, LCW{10, 10, 10}}, - LCW{LCW{44, 44}}}); + LCW({{1, 2, 3}, {4}, {}, {5, 6}}, mask_vector{1, 1, 0, 1}.begin()), true); + LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, + {{55, 55}, {}, {10, 10, 10}}, + LCW::nested({{44, 44}})}); size_column scatter_map{1, 2, 3}; - LCW expected({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW({LCW{1, 2, 3}, LCW{4}, LCW{}, LCW{5, 6}}, mask_vector{1, 1, 0, 1}.begin()), - LCW({LCW{1, 2, 3}, LCW{4}, LCW{}, LCW{5, 6}}, mask_vector{1, 1, 0, 1}.begin()), - LCW({LCW{1, 2, 3}, LCW{4}, LCW{}, LCW{5, 6}}, mask_vector{1, 1, 0, 1}.begin())}); + LCW expected({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{{1, 2, 3}, {4}, {}, {5, 6}}, mask_vector{1, 1, 0, 1}.begin()}, + {{{1, 2, 3}, {4}, {}, {5, 6}}, mask_vector{1, 1, 0, 1}.begin()}, + {{{1, 2, 3}, {4}, {}, {5, 6}}, mask_vector{1, 1, 0, 1}.begin()}}); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -222,17 +209,17 @@ TYPED_TEST(ScatterListOfListScalarTest, EmptyValidScalar) using LCW = cudf::test::lists_column_wrapper; auto slr = std::make_unique(LCW{}, true); - LCW col({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW{LCW{66}, LCW{}, LCW({77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin())}, - LCW{LCW{55, 55}, LCW{}, LCW{10, 10, 10}}, - LCW{LCW{44, 44}}}); + LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, + {{55, 55}, {}, {10, 10, 10}}, + LCW::nested({{44, 44}})}); size_column scatter_map{3, 0}; - LCW expected({LCW{}, - LCW{LCW{66}, LCW{}, LCW({77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin())}, - LCW{LCW{55, 55}, LCW{}, LCW{10, 10, 10}}, - LCW{}}); + LCW expected({{}, + {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, + {{55, 55}, {}, {10, 10, 10}}, + {}}); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -243,13 +230,13 @@ TYPED_TEST(ScatterListOfListScalarTest, NullScalar) using LCW = cudf::test::lists_column_wrapper; auto slr = std::make_unique(LCW{}, false); - LCW col({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW{LCW{66}, LCW{}, LCW({77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin())}, - LCW{LCW{44, 44}}}); + LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, + LCW::nested({{44, 44}})}); size_column scatter_map{1, 0}; - LCW expected({LCW{}, LCW{}, LCW{LCW{44, 44}}}, mask_vector{0, 0, 1}.begin()); + LCW expected({{}, {}, LCW::nested({{44, 44}})}, mask_vector{0, 0, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -260,18 +247,18 @@ TYPED_TEST(ScatterListOfListScalarTest, NullableTargetRows) using LCW = cudf::test::lists_column_wrapper; auto slr = std::make_unique( - LCW({LCW{1, 1, 1}, LCW{3, 3}, LCW{}, LCW{4}}, mask_vector{1, 1, 0, 1}.begin()), true); + LCW({{1, 1, 1}, {3, 3}, {}, {4}}, mask_vector{1, 1, 0, 1}.begin()), true); - LCW col({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW{LCW{66}, LCW{}, LCW({77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin())}, - LCW{LCW{44, 44}}}, + LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, + LCW::nested({{44, 44}})}, mask_vector{1, 0, 1}.begin()); size_column scatter_map{1}; - LCW expected({LCW({LCW{88, 88}, LCW{}, LCW{9, 9, 9}}, mask_vector{1, 0, 1}.begin()), - LCW({LCW{1, 1, 1}, LCW{3, 3}, LCW{}, LCW{4}}, mask_vector{1, 1, 0, 1}.begin()), - LCW{LCW{44, 44}}}, + LCW expected({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, + {{{1, 1, 1}, {3, 3}, {}, {4}}, mask_vector{1, 1, 0, 1}.begin()}, + LCW::nested({{44, 44}})}, mask_vector{1, 1, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); @@ -298,18 +285,16 @@ TYPED_TEST(ScatterListOfStructScalarTest, Basic) using LCW = cudf::test::lists_column_wrapper; using offset_t = cudf::test::fixed_width_column_wrapper; - auto data = - this->make_test_structs({{42, 42, 42}, {1, 0, 1}}, - {{"hello", "你好!", "bonjour!"}, {false, true, true}}, - LCW({LCW{88}, LCW{}, LCW{99, 99}}, mask_vector{1, 0, 1}.begin()), - {1, 1, 0}); - auto slr = std::make_unique(data, true); + auto data = this->make_test_structs({{42, 42, 42}, {1, 0, 1}}, + {{"hello", "你好!", "bonjour!"}, {false, true, true}}, + LCW({{88}, {}, {99, 99}}, mask_vector{1, 0, 1}.begin()), + {1, 1, 0}); + auto slr = std::make_unique(data, true); auto child = this->make_test_structs( {{1, 1, 2, 3, 3, 3}, {0, 1, 1, 1, 0, 0}}, {{"x", "x", "yy", "", "zzz", "zzz"}, {true, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{10}, LCW{20, 20}, LCW{}, LCW{30, 30}}, - mask_vector{1, 0, 1, 1, 0, 1}.begin()), + LCW({{10, 10}, {}, {10}, {20, 20}, {}, {30, 30}}, mask_vector{1, 0, 1, 1, 0, 1}.begin()), {1, 1, 0, 0, 1, 1}); offset_t offsets{0, 2, 2, 3, 6}; auto col = @@ -321,7 +306,7 @@ TYPED_TEST(ScatterListOfStructScalarTest, Basic) {{1, 1, 42, 42, 42, 2, 42, 42, 42}, {0, 1, 1, 0, 1, 1, 1, 0, 1}}, {{"x", "x", "hello", "你好!", "bonjour!", "yy", "hello", "你好!", "bonjour!"}, {true, true, false, true, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{88}, LCW{}, LCW{99, 99}, LCW{10}, LCW{88}, LCW{}, LCW{99, 99}}, + LCW({{10, 10}, {}, {88}, {}, {99, 99}, {10}, {88}, {}, {99, 99}}, mask_vector{1, 0, 1, 0, 1, 1, 1, 0, 1}.begin()), {1, 1, 1, 1, 0, 0, 1, 1, 0}); offset_t ex_offsets{0, 2, 5, 6, 9}; @@ -343,8 +328,7 @@ TYPED_TEST(ScatterListOfStructScalarTest, EmptyValidScalar) auto child = this->make_test_structs( {{1, 1, 2, 3, 3, 3}, {0, 1, 1, 1, 0, 0}}, {{"x", "x", "yy", "", "zzz", "zzz"}, {true, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{10}, LCW{20, 20}, LCW{}, LCW{30, 30}}, - mask_vector{1, 0, 1, 1, 0, 1}.begin()), + LCW({{10, 10}, {}, {10}, {20, 20}, {}, {30, 30}}, mask_vector{1, 0, 1, 1, 0, 1}.begin()), {1, 1, 0, 0, 1, 1}); offset_t offsets{0, 2, 2, 3, 6}; auto col = @@ -355,7 +339,7 @@ TYPED_TEST(ScatterListOfStructScalarTest, EmptyValidScalar) auto ex_child = this->make_test_structs({{3, 3, 3}, {1, 0, 0}}, {{"", "zzz", "zzz"}, {false, true, true}}, - LCW({LCW{20, 20}, LCW{}, LCW{30, 30}}, mask_vector{1, 0, 1}.begin()), + LCW({{20, 20}, {}, {30, 30}}, mask_vector{1, 0, 1}.begin()), {0, 1, 1}); offset_t ex_offsets{0, 0, 0, 0, 3}; auto expected = @@ -376,8 +360,7 @@ TYPED_TEST(ScatterListOfStructScalarTest, NullScalar) auto child = this->make_test_structs( {{1, 1, 2, 3, 3, 3}, {0, 1, 1, 1, 0, 0}}, {{"x", "x", "yy", "", "zzz", "zzz"}, {true, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{10}, LCW{20, 20}, LCW{}, LCW{30, 30}}, - mask_vector{1, 0, 1, 1, 0, 1}.begin()), + LCW({{10, 10}, {}, {10}, {20, 20}, {}, {30, 30}}, mask_vector{1, 0, 1, 1, 0, 1}.begin()), {1, 1, 1, 0, 1, 1}); offset_t offsets{0, 2, 2, 3, 6}; auto col = @@ -402,18 +385,16 @@ TYPED_TEST(ScatterListOfStructScalarTest, NullableTargetRow) using LCW = cudf::test::lists_column_wrapper; using offset_t = cudf::test::fixed_width_column_wrapper; - auto data = - this->make_test_structs({{42, 42, 42}, {1, 0, 1}}, - {{"hello", "你好!", "bonjour!"}, {false, true, true}}, - LCW({LCW{88}, LCW{}, LCW{99, 99}}, mask_vector{1, 0, 1}.begin()), - {1, 1, 0}); - auto slr = std::make_unique(data, true); + auto data = this->make_test_structs({{42, 42, 42}, {1, 0, 1}}, + {{"hello", "你好!", "bonjour!"}, {false, true, true}}, + LCW({{88}, {}, {99, 99}}, mask_vector{1, 0, 1}.begin()), + {1, 1, 0}); + auto slr = std::make_unique(data, true); auto child = this->make_test_structs( {{1, 1, 2, 3, 3, 3}, {0, 1, 1, 1, 0, 0}}, {{"x", "x", "yy", "", "zzz", "zzz"}, {true, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{10}, LCW{20, 20}, LCW{}, LCW{30, 30}}, - mask_vector{1, 0, 1, 1, 0, 1}.begin()), + LCW({{10, 10}, {}, {10}, {20, 20}, {}, {30, 30}}, mask_vector{1, 0, 1, 1, 0, 1}.begin()), {1, 1, 1, 0, 1, 1}); offset_t offsets{0, 2, 2, 3, 6}; auto null_mask = cudf::create_null_mask(4, cudf::mask_state::ALL_VALID); @@ -427,7 +408,7 @@ TYPED_TEST(ScatterListOfStructScalarTest, NullableTargetRow) {{1, 1, 42, 42, 42, 42, 42, 42}, {0, 1, 1, 0, 1, 1, 0, 1}}, {{"x", "x", "hello", "你好!", "bonjour!", "hello", "你好!", "bonjour!"}, {true, true, false, true, true, false, true, true}}, - LCW({LCW{10, 10}, LCW{}, LCW{88}, LCW{}, LCW{99, 99}, LCW{88}, LCW{}, LCW{99, 99}}, + LCW({{10, 10}, {}, {88}, {}, {99, 99}, {88}, {}, {99, 99}}, mask_vector{1, 0, 1, 0, 1, 1, 0, 1}.begin()), {1, 1, 1, 1, 0, 1, 1, 0}); offset_t ex_offsets{0, 2, 2, 5, 8}; diff --git a/cpp/tests/copying/scatter_struct_scalar_tests.cpp b/cpp/tests/copying/scatter_struct_scalar_tests.cpp index abfede8587e1..db46f276cc3d 100644 --- a/cpp/tests/copying/scatter_struct_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_struct_scalar_tests.cpp @@ -241,13 +241,11 @@ TYPED_TEST(TypedStructScalarScatterTest, StructOfLists) cudf::test::fixed_width_column_wrapper scatter_map{0, 1, 4}; // Target column - LCW field0({LCW{XXX}, LCW{22}, LCW{33, 44}, LCW{null}, LCW{55}}, - cudf::test::iterators::null_at(3)); + LCW field0({{XXX}, {22}, {33, 44}, {null}, {55}}, cudf::test::iterators::null_at(3)); structs_col target({field0}, cudf::test::iterators::null_at(0)); // Expect column - LCW ef0({LCW{777}, LCW{777}, LCW{33, 44}, LCW{null}, LCW{777}}, - cudf::test::iterators::null_at(3)); + LCW ef0({{777}, {777}, {33, 44}, {null}, {777}}, cudf::test::iterators::null_at(3)); structs_col expected{ef0}; auto got = scatter_single_scalar(*slr, scatter_map, target); diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 2de5030cb98d..8312d44b3bd7 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -102,21 +102,21 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) // List { I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; - auto const gather_map = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; + auto const gather_map = LCW{{}, {}, {}, {}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - auto const expected = LCW{LCW{}, LCW{}, LCW{}, LCW{}}; + auto const expected = LCW{{}, {}, {}, {}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List> { I32Init list{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {I32Init{}, {8, 9, 10}}}; - auto const gather_map = LCW{LCW{}, LCW{}, LCW{}}; + auto const gather_map = LCW{{}, {}, {}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, @@ -134,7 +134,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) // List>> { I32Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; - auto const gather_map = LCW{LCW{}, LCW{}}; + auto const gather_map = LCW{{}, {}}; auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, @@ -526,15 +526,17 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const stream = this->stream(); auto const mr = this->resources(); - I32Init list{{{2, 3}, I32Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {I32Init{}}}; + auto const list = I32Init::nested( + {{{2, 3}, I32Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, I32Init::nested({I32Init{}})}); // Per-row singleton lists: brace LCWs (I32Init{{0},{0},{0}} flattens to one list of three). - auto const gather_map = LCW{LCW{0}, LCW{0}, LCW{0}}; + auto const gather_map = LCW({{0}, {0}, {0}}); auto results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{2, 3}}, {{6, 7, 8}}, {I32Init{}}}; // skip one null, gather one null. + auto const expected = I32Init::nested( + {{{2, 3}}, {{6, 7, 8}}, I32Init::nested({I32Init{}})}); // skip one null, gather one null. CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), LCW(expected, stream, mr), cudf::test::debug_output_level::FIRST_ERROR, diff --git a/cpp/tests/copying/slice_tests.cpp b/cpp/tests/copying/slice_tests.cpp index 89dff78a243c..0c1d3b000603 100644 --- a/cpp/tests/copying/slice_tests.cpp +++ b/cpp/tests/copying/slice_tests.cpp @@ -167,8 +167,8 @@ TEST_F(SliceListTest, Lists) {6}, {7, 8}, {9, 10, 11}, - LCW{}, - LCW{}, + {}, + {}, {-1, -2, -3, -4, -5}, {-10}, {-100, -200}}; @@ -178,8 +178,7 @@ TEST_F(SliceListTest, Lists) std::vector> expected; expected.push_back(LCW{{4, 5}, {6}}); expected.push_back(LCW{{6}, {7, 8}}); - expected.push_back( - LCW{{4, 5}, {6}, {7, 8}, {9, 10, 11}, LCW{}, LCW{}, {-1, -2, -3, -4, -5}, {-10}}); + expected.push_back(LCW{{4, 5}, {6}, {7, 8}, {9, 10, 11}, {}, {}, {-1, -2, -3, -4, -5}, {-10}}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); @@ -191,18 +190,19 @@ TEST_F(SliceListTest, Lists) { cudf::test::lists_column_wrapper list{{{1, 2, 3}, {4, 5}}, - {LCW{}, LCW{}, {7, 8}, LCW{}}, - {{{6}}}, // NOLINT - {{7, 8}, {9, 10, 11}, LCW{}}, - {LCW{}, {-1, -2, -3, -4, -5}}, - {LCW{}}, + {{}, {}, {7, 8}, {}}, + LCW::nested({{6}}), + {{7, 8}, {9, 10, 11}, {}}, + {{}, {-1, -2, -3, -4, -5}}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; std::vector indices{1, 3, 3, 6}; std::vector> expected; - expected.push_back(LCW{{LCW{}, LCW{}, {7, 8}, LCW{}}, {{{6}}}}); // NOLINT - expected.push_back(LCW{{{7, 8}, {9, 10, 11}, LCW{}}, {LCW{}, {-1, -2, -3, -4, -5}}, {LCW{}}}); + expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); + expected.push_back( + LCW{{{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, LCW::nested({{}})}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); @@ -225,8 +225,8 @@ TEST_F(SliceListTest, ListsWithNulls) {6}, {{7, 8}, valids}, {9, 10, 11}, - LCW{}, - LCW{}, + {}, + {}, {{-1, -2, -3, -4, -5}, valids}, {-10}, {{-100, -200}, valids}}; @@ -236,14 +236,8 @@ TEST_F(SliceListTest, ListsWithNulls) std::vector> expected; expected.push_back(LCW{{4, 5}, {6}}); expected.push_back(LCW{{6}, {{7, 8}, valids}}); - expected.push_back(LCW{{4, 5}, - {6}, - {{7, 8}, valids}, - {9, 10, 11}, - LCW{}, - LCW{}, - {{-1, -2, -3, -4, -5}, valids}, - {-10}}); + expected.push_back(LCW{ + {4, 5}, {6}, {{7, 8}, valids}, {9, 10, 11}, {}, {}, {{-1, -2, -3, -4, -5}, valids}, {-10}}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); @@ -255,20 +249,20 @@ TEST_F(SliceListTest, ListsWithNulls) { cudf::test::lists_column_wrapper list{{{{1, 2, 3}, valids}, {4, 5}}, - {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, - {{{6}}}, // NOLINT - {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, - {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, - {LCW{}}, + {{{}, {}, {7, 8}, {}}, valids}, + LCW::nested({{6}}), + {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, + {{{}, {-1, -2, -3, -4, -5}}, valids}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; std::vector indices{1, 3, 3, 6}; std::vector> expected; - expected.push_back(LCW{{{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, {{{6}}}}); // NOLINT - expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, - {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, - {LCW{}}}); + expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); + expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, + {{{}, {-1, -2, -3, -4, -5}}, valids}, + LCW::nested({{}})}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); @@ -524,8 +518,6 @@ TEST_F(SliceTableCornerCases, MiscOffset) TEST_F(SliceTableCornerCases, PreSlicedInputs) { { - using LCW = cudf::test::lists_column_wrapper; - cudf::test::fixed_width_column_wrapper a{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {true, true, false, true, true, true, false, false, true, false}}; @@ -553,7 +545,7 @@ TEST_F(SliceTableCornerCases, PreSlicedInputs) cudf::test::fixed_width_column_wrapper e0_b({-4}, {false}); cudf::test::strings_column_wrapper e0_c({""}, {false}); std::vector e0_list_validity{true}; - cudf::test::lists_column_wrapper e0_d({LCW{7, 7}}, e0_list_validity.begin()); + cudf::test::lists_column_wrapper e0_d({{7, 7}}, e0_list_validity.begin()); cudf::table_view expected0({e0_a, e0_b, e0_c, e0_d}); CUDF_TEST_EXPECT_TABLES_EQUAL(result[0], expected0); diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index 8ddc4edbfd61..c782c18f1a3c 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -745,8 +745,8 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) {6}, {7, 8}, {9, 10, 11}, - LCW{}, - LCW{}, + {}, + {}, {-1, -2, -3, -4, -5}, {-10}, {-100, -200}}; @@ -759,8 +759,8 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) expected.push_back(LCW{{1, 2, 3}}); expected.push_back(LCW{{4, 5}, {6}, {7, 8}}); expected.push_back(LCW{{9, 10, 11}}); - expected.push_back(LCW{LCW{}}); - expected.push_back(LCW{LCW{}, {-1, -2, -3, -4, -5}, {-10}}); + expected.push_back(LCW{{}}); + expected.push_back(LCW{{}, {-1, -2, -3, -4, -5}, {-10}}); expected.push_back(LCW{{-100, -200}}); auto result = Split(list, splits); @@ -778,11 +778,11 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) { cudf::test::lists_column_wrapper list{{{1, 2, 3}, {4, 5}}, - {LCW{}, LCW{}, {7, 8}, LCW{}}, - {LCW{6}}, - {{7, 8}, {9, 10, 11}, LCW{}}, - {LCW{}, {-1, -2, -3, -4, -5}}, - {LCW{}}, + {{}, {}, {7, 8}, {}}, + LCW::nested({{6}}), + {{7, 8}, {9, 10, 11}, {}}, + {{}, {-1, -2, -3, -4, -5}}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; if (split) { @@ -790,9 +790,9 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) std::vector> expected; expected.push_back(LCW{{{1, 2, 3}, {4, 5}}}); - expected.push_back(LCW{{LCW{}, LCW{}, {7, 8}, LCW{}}, {LCW{6}}}); - expected.push_back(LCW{{{7, 8}, {9, 10, 11}, LCW{}}}); - expected.push_back(LCW{{LCW{}, {-1, -2, -3, -4, -5}}, {LCW{}}, {{-10}, {-100, -200}}}); + expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); + expected.push_back(LCW{{{7, 8}, {9, 10, 11}, {}}}); + expected.push_back(LCW{{{}, {-1, -2, -3, -4, -5}}, LCW::nested({{}}), {{-10}, {-100, -200}}}); auto result = Split(list, splits); EXPECT_EQ(expected.size(), result.size()); @@ -821,8 +821,8 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t {6}, {{7, 8}, valids}, {9, 10, 11}, - LCW{}, - LCW{}, + {}, + {}, {{-1, -2, -3, -4, -5}, valids}, {-10}, {{-100, -200}, valids}}; @@ -835,8 +835,8 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t expected.push_back(LCW{{1, 2, 3}}); expected.push_back(LCW{{4, 5}, {6}, {{7, 8}, valids}}); expected.push_back(LCW{{9, 10, 11}}); - expected.push_back(LCW{LCW{}}); - expected.push_back(LCW{LCW{}, {{-1, -2, -3, -4, -5}, valids}, {-10}}); + expected.push_back(LCW{{}}); + expected.push_back(LCW{{}, {{-1, -2, -3, -4, -5}, valids}, {-10}}); expected.push_back(LCW{{{-100, -200}, valids}}); auto result = Split(list, splits); @@ -854,11 +854,11 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t { cudf::test::lists_column_wrapper list{{{{1, 2, 3}, valids}, {4, 5}}, - {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, - {{{6}}}, - {{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}, - {{LCW{}, {-1, -2, -3, -4, -5}}, valids}, - {LCW{}}, + {{{}, {}, {7, 8}, {}}, valids}, + LCW::nested({{6}}), + {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, + {{{}, {-1, -2, -3, -4, -5}}, valids}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; if (split) { @@ -866,10 +866,10 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t std::vector> expected; expected.push_back(LCW{{{{1, 2, 3}, valids}, {4, 5}}}); - expected.push_back(LCW{{{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, {{{6}}}}); - expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, LCW{}}, valids}}); + expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); + expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}}); expected.push_back( - LCW{{{LCW{}, {-1, -2, -3, -4, -5}}, valids}, {LCW{}}, {{-10}, {-100, -200}}}); + LCW{{{{}, {-1, -2, -3, -4, -5}}, valids}, LCW::nested({{}}), {{-10}, {-100, -200}}}); auto result = Split(list, splits); EXPECT_EQ(expected.size(), result.size()); @@ -1074,14 +1074,14 @@ void split_nested_struct_of_list(SplitFunc Split, CompareFunc Compare, bool spli // 3. List column std::vector list_validity{true, true, true, true, true, false, true, false, true}; cudf::test::lists_column_wrapper list({{{1, 2, 3}, {4}}, - {{-1, -2}, LCW{}}, - LCW{}, + {{-1, -2}, {}}, + {}, {{10}, {20, 30, 40}, {100, -100}}, - {LCW{}, LCW{}, {8, 9}}, - LCW{}, + {{}, {}, {8, 9}}, + {}, {{8}, {10, 9, 8, 7, 6, 5}}, - {{5, 6}, LCW{}, {8}}, - {LCW{-3, 4, -5}}}, + {{5, 6}, {}, {8}}, + LCW::nested({{-3, 4, -5}})}, list_validity.begin()); // Assemble struct column. @@ -1098,15 +1098,15 @@ void split_nested_struct_of_list(SplitFunc Split, CompareFunc Compare, bool spli auto expected_ages = create_expected_columns_for_splits(splits, ages, ages_validity); std::vector> expected_lists; expected_lists.push_back(LCW({{{1, 2, 3}, {4}}})); - expected_lists.push_back(LCW({{{-1, -2}, LCW{}}, LCW{}})); + expected_lists.push_back(LCW({{{-1, -2}, {}}, {}})); std::vector ex_v{true, true, false, true, false}; expected_lists.push_back(LCW({{{10}, {20, 30, 40}, {100, -100}}, - {LCW{}, LCW{}, {8, 9}}, - LCW{}, + {{}, {}, {8, 9}}, + {}, {{8}, {10, 9, 8, 7, 6, 5}}, - {{5, 6}, LCW{}, {8}}}, + {{5, 6}, {}, {8}}}, ex_v.begin())); - expected_lists.push_back(LCW({{LCW{-3, 4, -5}}})); + expected_lists.push_back(LCW({LCW::nested({{-3, 4, -5}})})); auto expected_struct_validity = create_expected_validity(splits, struct_validity); EXPECT_EQ(expected_names.size(), result.size()); @@ -1127,7 +1127,6 @@ template void split_nested_list_of_structs(SplitFunc Split, CompareFunc Compare, bool split = true) { // List> - using LCW = cudf::test::lists_column_wrapper; // 1. String "names" column. std::vector names{"Vimes", @@ -1212,22 +1211,22 @@ void split_nested_list_of_structs(SplitFunc Split, CompareFunc Compare, bool spl true}; cudf::test::lists_column_wrapper list( {{"ab", "cd", "ef"}, - LCW{"gh"}, + {"gh"}, {"ijk", "lmn"}, - LCW{}, - LCW{"o"}, + {}, + {"o"}, {"pqr", "stu", "vwx"}, {"yz", "aaaa"}, - LCW{"bbbb"}, + {"bbbb"}, {"cccc", "ddd", "eee", "fff", "ggg", "hh"}, {"b", "cdr", "efh", "um"}, - LCW{"gh", "iu"}, + {"gh", "iu"}, {"lmn"}, - LCW{"org"}, - LCW{}, + {"org"}, + {}, {"stu", "vwx"}, {"yz", "aaaa", "kem"}, - LCW{"bbbb"}, + {"bbbb"}, {"cccc", "eee", "faff", "jiea", "fff", "ggg", "hh"}}, list_validity.begin()); @@ -2139,11 +2138,11 @@ TEST_F(ContiguousSplitTableCornerCases, PreSplitTable) using LCW = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col0{{{1, 2, 3}, {4, 5}}, - {{LCW{}, LCW{}, {7, 8}, LCW{}}, valids}, - {{{6}}}, // NOLINT - {{{7, 8}, LCW{}, {{9, 10, 11}, valids}}, valids}, - {{{-1, -2, -3, -4, -5}, LCW{}}, valids}, - {LCW{}}, + {{{}, {}, {7, 8}, {}}, valids}, + LCW::nested({{6}}), + {{{7, 8}, {}, {{9, 10, 11}, valids}}, valids}, + {{{-1, -2, -3, -4, -5}, {}}, valids}, + LCW::nested({{}}), {{-10}, {-100, -200}}}; cudf::test::strings_column_wrapper col1{ diff --git a/cpp/tests/groupby/collect_list_tests.cpp b/cpp/tests/groupby/collect_list_tests.cpp index 2a7ca950ff52..4217c5030d37 100644 --- a/cpp/tests/groupby/collect_list_tests.cpp +++ b/cpp/tests/groupby/collect_list_tests.cpp @@ -92,16 +92,13 @@ TYPED_TEST(groupby_collect_list_test, CollectLists) using K = int32_t; using V = TypeParam; - using LCW = cudf::test::lists_column_wrapper; - cudf::test::fixed_width_column_wrapper keys{1, 1, 2, 2, 3, 3}; - cudf::test::lists_column_wrapper values{ - {1, 2}, {3, 4}, {5, 6, 7}, LCW{}, {9, 10}, {11}}; + cudf::test::lists_column_wrapper values{{1, 2}, {3, 4}, {5, 6, 7}, {}, {9, 10}, {11}}; cudf::test::fixed_width_column_wrapper expect_keys{1, 2, 3}; cudf::test::lists_column_wrapper expect_vals{ - {{1, 2}, {3, 4}}, {{5, 6, 7}, LCW{}}, {{9, 10}, {11}}}; + {{1, 2}, {3, 4}}, {{5, 6, 7}, {}}, {{9, 10}, {11}}}; auto agg = cudf::make_collect_list_aggregation(); test_single_agg(keys, values, expect_keys, expect_vals, std::move(agg)); @@ -116,12 +113,12 @@ TYPED_TEST(groupby_collect_list_test, CollectListsWithNullExclusion) cudf::test::fixed_width_column_wrapper keys{1, 1, 2, 2, 3, 3, 4, 4}; std::array const validity_mask{true, false, false, true, true, true, false, false}; - LCW values{{{1, 2}, {3, 4}, {5, 6, 7}, LCW{}, {9, 10}, {11}, {20, 30, 40}, LCW{}}, + LCW values{{{1, 2}, {3, 4}, {5, 6, 7}, {}, {9, 10}, {11}, {20, 30, 40}, {}}, validity_mask.data()}; cudf::test::fixed_width_column_wrapper expect_keys{1, 2, 3, 4}; - LCW expect_vals{{{1, 2}}, {LCW{}}, {{9, 10}, {11}}, {}}; + LCW expect_vals{{{1, 2}}, LCW::nested({{}}), {{9, 10}, {11}}, {}}; auto agg = cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE); diff --git a/cpp/tests/groupby/collect_set_tests.cpp b/cpp/tests/groupby/collect_set_tests.cpp index ddcedc49e22d..4e3018571baa 100644 --- a/cpp/tests/groupby/collect_set_tests.cpp +++ b/cpp/tests/groupby/collect_set_tests.cpp @@ -106,7 +106,7 @@ TYPED_TEST(CollectSetTypedTest, TrivialInput) keys_col keys{1}; vals_col vals{10}; keys_col keys_expected{1}; - lists_col vals_expected{lists_col{10}}; + lists_col vals_expected({{10}}); auto const [out_keys, out_lists] = groupby_collect_set(keys, vals, CollectSetTest::collect_set()); @@ -119,7 +119,7 @@ TYPED_TEST(CollectSetTypedTest, TrivialInput) keys_col keys{2, 1}; vals_col vals{20, 10}; keys_col keys_expected{1, 2}; - lists_col vals_expected{lists_col{10}, lists_col{20}}; + lists_col vals_expected({{10}, {20}}); auto const [out_keys, out_lists] = groupby_collect_set(keys, vals, CollectSetTest::collect_set()); diff --git a/cpp/tests/groupby/lists_tests.cpp b/cpp/tests/groupby/lists_tests.cpp index 12e011e46323..c4bfebec43e0 100644 --- a/cpp/tests/groupby/lists_tests.cpp +++ b/cpp/tests/groupby/lists_tests.cpp @@ -81,16 +81,15 @@ TYPED_TEST(groupby_lists_test, lists_with_nulls) TYPED_TEST(groupby_lists_test, lists_with_null_elements) { - auto keys = - lcw{{lcw{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, - lcw{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, - lcw{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, - lcw{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}}, - nulls_at({2, 3})}; + auto keys = lcw{{{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, + {{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, + {{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}, + {{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}}, + nulls_at({2, 3})}; auto values = fwcw{1, 2, 4, 5}; - auto expected_keys = lcw{ - {{}, lcw{{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}}, null_at(0)}; + auto expected_keys = + lcw{{{}, {{{1, 2, 3}, {}, {4, 5}, {}, {6, 0}}, nulls_at({1, 3})}}, null_at(0)}; auto expected_values = fwcw{9, 3}; test_sum_agg(keys, values, expected_keys, expected_values); diff --git a/cpp/tests/groupby/max_tests.cpp b/cpp/tests/groupby/max_tests.cpp index 52f57d08e299..4bfd3c1b40df 100644 --- a/cpp/tests/groupby/max_tests.cpp +++ b/cpp/tests/groupby/max_tests.cpp @@ -483,12 +483,7 @@ TEST_F(groupby_max_list_test, null_keys_and_values) // Null child element. { - auto const vals = lists{lists{{0, null}, null_at(1)}, - lists{1, 2}, - lists{3, 4}, - lists{5, 6, 7}, - lists{0, 8}, - lists{9, 10}}; + auto const vals = lists{{{0, null}, null_at(1)}, {1, 2}, {3, 4}, {5, 6, 7}, {0, 8}, {9, 10}}; auto const expect_vals = lists{{0, 8}, {9, 10}, {3, 4}}; test_single_agg(keys, vals, diff --git a/cpp/tests/groupby/merge_lists_tests.cpp b/cpp/tests/groupby/merge_lists_tests.cpp index 24b28f8509f1..a58dbeb09106 100644 --- a/cpp/tests/groupby/merge_lists_tests.cpp +++ b/cpp/tests/groupby/merge_lists_tests.cpp @@ -57,7 +57,7 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InvalidInput) auto const keys = keys_col{1, 2, 3}; // The input lists column must NOT be nullable. - auto const lists = lists_col{{lists_col{1}, lists_col{} /*NULL*/, lists_col{2}}, null_at(1)}; + auto const lists = lists_col{{{1}, {} /*NULL*/, {2}}, null_at(1)}; EXPECT_THROW(merge_lists({keys}, {lists}), cudf::logic_error); // The input column must be a lists column. @@ -132,27 +132,27 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNulls) // Note that the null elements here are not sorted, while the results from current collect_list // are sorted. auto const lists1 = lists_col{ - lists_col{{1, null, 3}, null_at(1)}, // key = 1 - lists_col{4, 5, 6} // key = 2 + {{1, null, 3}, null_at(1)}, // key = 1 + {4, 5, 6} // key = 2 }; auto const lists2 = lists_col{ - lists_col{10, 11}, // key = 1 - lists_col{{null, null, null}, all_nulls()} // key = 3 + {10, 11}, // key = 1 + {{null, null, null}, all_nulls()} // key = 3 }; auto const lists3 = lists_col{ - lists_col{20, 21, 22}, // key = 2 - lists_col{{null, 24, null}, nulls_at({0, 2})}, // key = 3 - lists_col{{24, 25, 26}, no_nulls()} // key = 4 + {20, 21, 22}, // key = 2 + {{null, 24, null}, nulls_at({0, 2})}, // key = 3 + {{24, 25, 26}, no_nulls()} // key = 4 }; auto const [out_keys, out_lists] = merge_lists(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_lists = lists_col{ - lists_col{{1, null, 3, 10, 11}, null_at(1)}, // key = 1 - lists_col{4, 5, 6, 20, 21, 22}, // key = 2 - lists_col{{null, null, null, null, 24, null}, nulls_at({0, 1, 2, 3, 5})}, // key = 3 - lists_col{24, 25, 26} // key = 4 + {{1, null, 3, 10, 11}, null_at(1)}, // key = 1 + {4, 5, 6, 20, 21, 22}, // key = 2 + {{null, null, null, null, 24, null}, nulls_at({0, 1, 2, 3, 5})}, // key = 3 + {24, 25, 26} // key = 4 }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); @@ -208,29 +208,29 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasNullsAndEmptyLists) // Note that the null elements here are not sorted, while the results from current collect_list // are sorted. auto const lists1 = lists_col{ - lists_col{{1, null, 3}, null_at(1)}, // key = 1 - lists_col{}, // key = 2 - lists_col{4, 5} // key = 3 + {{1, null, 3}, null_at(1)}, // key = 1 + {}, // key = 2 + {4, 5} // key = 3 }; auto const lists2 = lists_col{ - lists_col{10, 11}, // key = 1 - lists_col{{null, null, null}, all_nulls()}, // key = 3 - lists_col{} // key = 4 + {10, 11}, // key = 1 + {{null, null, null}, all_nulls()}, // key = 3 + {} // key = 4 }; auto const lists3 = lists_col{ - lists_col{20, 21, 22}, // key = 2 - lists_col{{null, 24, null}, nulls_at({0, 2})}, // key = 3 - lists_col{{24, 25, 26}, no_nulls()} // key = 4 + {20, 21, 22}, // key = 2 + {{null, 24, null}, nulls_at({0, 2})}, // key = 3 + {{24, 25, 26}, no_nulls()} // key = 4 }; auto const [out_keys, out_lists] = merge_lists(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_lists = lists_col{ - lists_col{{1, null, 3, 10, 11}, null_at(1)}, // key = 1 - lists_col{20, 21, 22}, // key = 2 - lists_col{{4, 5, null, null, null, null, 24, null}, nulls_at({2, 3, 4, 5, 7})}, // key = 3 - lists_col{24, 25, 26} // key = 4 + {{1, null, 3, 10, 11}, null_at(1)}, // key = 1 + {20, 21, 22}, // key = 2 + {{4, 5, null, null, null, null, 24, null}, nulls_at({2, 3, 4, 5, 7})}, // key = 3 + {24, 25, 26} // key = 4 }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); @@ -247,28 +247,27 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasListsOfLists) auto const keys3 = keys_col{2, 3, 4}; auto const lists1 = lists_col{ - lists_col{lists_col{1, 2, 3}, lists_col{4}, lists_col{5, 6}}, // key = 1 - lists_col{lists_col{}, lists_col{7}} // key = 2 + {{1, 2, 3}, {4}, {5, 6}}, // key = 1 + {{}, {7}} // key = 2 }; auto const lists2 = lists_col{ - lists_col{lists_col{}, lists_col{8, 9}}, // key = 1 - lists_col{lists_col{11}, lists_col{12, 13}} // key = 3 + {{}, {8, 9}}, // key = 1 + {{11}, {12, 13}} // key = 3 }; auto const lists3 = lists_col{ - lists_col{lists_col{14}, lists_col{15, 16, 17, 18}}, // key = 2 - lists_col{lists_col{}}, // key = 3 - lists_col{lists_col{17, 18, 19, 20, 21}, lists_col{18, 19, 20}} // key = 4 + {{14}, {15, 16, 17, 18}}, // key = 2 + lists_col::nested({{}}), // key = 3 + {{17, 18, 19, 20, 21}, {18, 19, 20}} // key = 4 }; auto const [out_keys, out_lists] = merge_lists(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_lists = lists_col{ - lists_col{ - lists_col{1, 2, 3}, lists_col{4}, lists_col{5, 6}, lists_col{}, lists_col{8, 9}}, // key = 1 - lists_col{lists_col{}, lists_col{7}, lists_col{14}, lists_col{15, 16, 17, 18}}, // key = 2 - lists_col{lists_col{11}, lists_col{12, 13}, lists_col{}}, // key = 3 - lists_col{lists_col{17, 18, 19, 20, 21}, lists_col{18, 19, 20}} // key = 4 + {{1, 2, 3}, {4}, {5, 6}, {}, {8, 9}}, // key = 1 + {{}, {7}, {14}, {15, 16, 17, 18}}, // key = 2 + {{11}, {12, 13}, {}}, // key = 3 + {{17, 18, 19, 20, 21}, {18, 19, 20}} // key = 4 }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); @@ -335,39 +334,39 @@ TEST_F(GroupbyMergeListsTest, StringsColumnInput) auto const keys3 = strings_col{"apple", "dog", "water melon"}; auto const lists1 = lists_col{ - lists_col{"Poodle", "Golden Retriever", "Corgi"}, // key = "dog" - lists_col{{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)} // key = "unknown" + {"Poodle", "Golden Retriever", "Corgi"}, // key = "dog" + {{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)} // key = "unknown" }; auto const lists2 = lists_col{ - lists_col{"Green", "Yellow"}, // key = "banana" - lists_col{}, // key = "unknown" - lists_col{{"" /*NULL*/, "" /*NULL*/}, all_nulls()} // key = "dog" + {"Green", "Yellow"}, // key = "banana" + {}, // key = "unknown" + {{"" /*NULL*/, "" /*NULL*/}, all_nulls()} // key = "dog" }; auto const lists3 = lists_col{ - lists_col{"Fuji", "Red Delicious"}, // key = "apple" - lists_col{{"" /*NULL*/, "German Shepherd", "" /*NULL*/}, nulls_at({0, 2})}, // key = "dog" - lists_col{{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" + {"Fuji", "Red Delicious"}, // key = "apple" + {{"" /*NULL*/, "German Shepherd", "" /*NULL*/}, nulls_at({0, 2})}, // key = "dog" + {{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" }; auto const [out_keys, out_lists] = merge_lists(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = strings_col{"apple", "banana", "dog", "unknown", "water melon"}; auto const expected_lists = lists_col{ - lists_col{"Fuji", "Red Delicious"}, // key = "apple" - lists_col{"Green", "Yellow"}, // key = "banana" - lists_col{{ - "Poodle", - "Golden Retriever", - "Corgi", - "" /*NULL*/, - "" /*NULL*/, - "" /*NULL*/, - "German Shepherd", - "" /*NULL*/ - }, - nulls_at({3, 4, 5, 7})}, // key = "dog" - lists_col{{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)}, // key = "unknown" - lists_col{{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" + {"Fuji", "Red Delicious"}, // key = "apple" + {"Green", "Yellow"}, // key = "banana" + {{ + "Poodle", + "Golden Retriever", + "Corgi", + "" /*NULL*/, + "" /*NULL*/, + "" /*NULL*/, + "German Shepherd", + "" /*NULL*/ + }, + nulls_at({3, 4, 5, 7})}, // key = "dog" + {{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)}, // key = "unknown" + {{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); diff --git a/cpp/tests/groupby/merge_sets_tests.cpp b/cpp/tests/groupby/merge_sets_tests.cpp index 17a28dd6a458..6ffd9f794a63 100644 --- a/cpp/tests/groupby/merge_sets_tests.cpp +++ b/cpp/tests/groupby/merge_sets_tests.cpp @@ -76,7 +76,7 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InvalidInput) auto const keys = keys_col{1, 2, 3}; // The input lists column must NOT be nullable. - auto const lists = lists_col{{lists_col{1}, lists_col{} /*NULL*/, lists_col{2}}, null_at(1)}; + auto const lists = lists_col{{{1}, {} /*NULL*/, {2}}, null_at(1)}; EXPECT_THROW(merge_sets({keys}, {lists}), cudf::logic_error); // The input column must be a lists column. @@ -149,27 +149,27 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNulls) auto const keys3 = keys_col{2, 3, 4}; auto const lists1 = lists_col{ - lists_col{{1, null, null, null, 5, 6}, nulls_at({1, 2, 3})}, // key = 1 - lists_col{10, 11, 12, 13, 14, 15} // key = 2 + {{1, null, null, null, 5, 6}, nulls_at({1, 2, 3})}, // key = 1 + {10, 11, 12, 13, 14, 15} // key = 2 }; auto const lists2 = lists_col{ - lists_col{{null, null, 6, 7, 8, 9}, nulls_at({0, 1})}, // key = 1 - lists_col{{null, 21, 22, 23, 24, 25}, null_at(0)} // key = 3 + {{null, null, 6, 7, 8, 9}, nulls_at({0, 1})}, // key = 1 + {{null, 21, 22, 23, 24, 25}, null_at(0)} // key = 3 }; auto const lists3 = lists_col{ - lists_col{11, 12}, // key = 2 - lists_col{23, 24, 25, 26, 27, 28}, // key = 3 - lists_col{{30, null, 32}, null_at(1)} // key = 4 + {11, 12}, // key = 2 + {23, 24, 25, 26, 27, 28}, // key = 3 + {{30, null, 32}, null_at(1)} // key = 4 }; auto const [out_keys, out_lists] = merge_sets(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_lists = lists_col{ - lists_col{{1, 5, 6, 7, 8, 9, null}, null_at(6)}, // key = 1 - lists_col{10, 11, 12, 13, 14, 15}, // key = 2 - lists_col{{21, 22, 23, 24, 25, 26, 27, 28, null}, null_at(8)}, // key = 3 - lists_col{{30, 32, null}, null_at(2)} // key = 4 + {{1, 5, 6, 7, 8, 9, null}, null_at(6)}, // key = 1 + {10, 11, 12, 13, 14, 15}, // key = 2 + {{21, 22, 23, 24, 25, 26, 27, 28, null}, null_at(8)}, // key = 3 + {{30, 32, null}, null_at(2)} // key = 4 }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); @@ -223,29 +223,29 @@ TYPED_TEST(GroupbyMergeSetsTypedTest, InputHasNullsAndEmptyLists) auto const keys3 = keys_col{2, 3, 4}; auto const lists1 = lists_col{ - lists_col{{null, 1, 2, 3}, null_at(0)}, // key = 1 - lists_col{}, // key = 2 - lists_col{} // key = 3 + {{null, 1, 2, 3}, null_at(0)}, // key = 1 + {}, // key = 2 + {} // key = 3 }; auto const lists2 = lists_col{ - lists_col{0, 1, 2, 3, 4, 5}, // key = 1 - lists_col{{null, 11, null, 12, 12, 12, 12, 12}, nulls_at({0, 2})}, // key = 3 - lists_col{20} // key = 4 + {0, 1, 2, 3, 4, 5}, // key = 1 + {{null, 11, null, 12, 12, 12, 12, 12}, nulls_at({0, 2})}, // key = 3 + {20} // key = 4 }; auto const lists3 = lists_col{ - lists_col{}, // key = 2 - lists_col{}, // key = 3 - lists_col{{24, 25, null, null, null, 26}, nulls_at({2, 3, 4})} // key = 4 + {}, // key = 2 + {}, // key = 3 + {{24, 25, null, null, null, 26}, nulls_at({2, 3, 4})} // key = 4 }; auto const [out_keys, out_lists] = merge_sets(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = keys_col{1, 2, 3, 4}; auto const expected_lists = lists_col{ - lists_col{{0, 1, 2, 3, 4, 5, null}, null_at(6)}, // key = 1 - lists_col{}, // key = 2 - lists_col{{11, 12, null}, null_at(2)}, // key = 3 - lists_col{{20, 24, 25, 26, null}, null_at(4)} // key = 4 + {{0, 1, 2, 3, 4, 5, null}, null_at(6)}, // key = 1 + {}, // key = 2 + {{11, 12, null}, null_at(2)}, // key = 3 + {{20, 24, 25, 26, null}, null_at(4)} // key = 4 }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); @@ -312,34 +312,34 @@ TEST_F(GroupbyMergeSetsTest, StringsColumnInput) auto const keys3 = strings_col{"apple", "dog", "water melon"}; auto const lists1 = lists_col{ - lists_col{"Fuji", "Honey Bee"}, // key = "apple" - lists_col{"Poodle", "Golden Retriever", "Corgi"}, // key = "dog" - lists_col{{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)} // key = "unknown" + {"Fuji", "Honey Bee"}, // key = "apple" + {"Poodle", "Golden Retriever", "Corgi"}, // key = "dog" + {{"Whale", "" /*NULL*/, "Polar Bear"}, null_at(1)} // key = "unknown" }; auto const lists2 = lists_col{ - lists_col{"Green", "Yellow"}, // key = "banana" - lists_col{}, // key = "unknown" - lists_col{{"" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, all_nulls()} // key = "dog" + {"Green", "Yellow"}, // key = "banana" + {}, // key = "unknown" + {{"" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, all_nulls()} // key = "dog" }; auto const lists3 = lists_col{ - lists_col{"Fuji", "Red Delicious"}, // key = "apple" - lists_col{{"" /*NULL*/, "Corgi", "German Shepherd", "" /*NULL*/, "Golden Retriever"}, - nulls_at({0, 3})}, // key = "dog" - lists_col{{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" + {"Fuji", "Red Delicious"}, // key = "apple" + {{"" /*NULL*/, "Corgi", "German Shepherd", "" /*NULL*/, "Golden Retriever"}, + nulls_at({0, 3})}, // key = "dog" + {{"Seeedless", "Mini"}, no_nulls()} // key = "water melon" }; auto const [out_keys, out_lists] = merge_sets(vcol_views{keys1, keys2, keys3}, vcol_views{lists1, lists2, lists3}); auto const expected_keys = strings_col{"apple", "banana", "dog", "unknown", "water melon"}; auto const expected_lists = lists_col{ - lists_col{"Fuji", "Honey Bee", "Red Delicious"}, // key = "apple" - lists_col{"Green", "Yellow"}, // key = "banana" - lists_col{{ - "Corgi", "German Shepherd", "Golden Retriever", "Poodle", "" /*NULL*/ - }, - null_at(4)}, // key = "dog" - lists_col{{"Polar Bear", "Whale", "" /*NULL*/}, null_at(2)}, // key = "unknown" - lists_col{{"Mini", "Seeedless"}, no_nulls()} // key = "water melon" + {"Fuji", "Honey Bee", "Red Delicious"}, // key = "apple" + {"Green", "Yellow"}, // key = "banana" + {{ + "Corgi", "German Shepherd", "Golden Retriever", "Poodle", "" /*NULL*/ + }, + null_at(4)}, // key = "dog" + {{"Polar Bear", "Whale", "" /*NULL*/}, null_at(2)}, // key = "unknown" + {{"Mini", "Seeedless"}, no_nulls()} // key = "water melon" }; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_keys, *out_keys, verbosity); diff --git a/cpp/tests/groupby/min_tests.cpp b/cpp/tests/groupby/min_tests.cpp index 13fc11774eef..75c4c2e75517 100644 --- a/cpp/tests/groupby/min_tests.cpp +++ b/cpp/tests/groupby/min_tests.cpp @@ -475,13 +475,8 @@ TEST_F(groupby_min_list_test, null_keys_and_values) // Null child element. { - auto const vals = lists{lists{{0, null}, null_at(1)}, - lists{1, 2}, - lists{3, 4}, - lists{5, 6, 7}, - lists{0, 8}, - lists{9, 10}}; - auto const expect_vals = lists{lists{{0, null}, null_at(1)}, {1, 2}, {3, 4}}; + auto const vals = lists{{{0, null}, null_at(1)}, {1, 2}, {3, 4}, {5, 6, 7}, {0, 8}, {9, 10}}; + auto const expect_vals = lists{{{0, null}, null_at(1)}, {1, 2}, {3, 4}}; test_single_agg(keys, vals, expect_keys, diff --git a/cpp/tests/groupby/nth_element_tests.cpp b/cpp/tests/groupby/nth_element_tests.cpp index 48fb58c5d7a0..40bca1d85de9 100644 --- a/cpp/tests/groupby/nth_element_tests.cpp +++ b/cpp/tests/groupby/nth_element_tests.cpp @@ -378,7 +378,7 @@ TYPED_TEST(groupby_nth_element_lists_test, Basics) using lists = cudf::test::lists_column_wrapper; auto keys = cudf::test::fixed_width_column_wrapper{1, 1, 2, 2, 3, 3}; - auto values = lists{{1, 2}, {3, 4}, {5, 6, 7}, lists{}, {9, 10}, {11}}; + auto values = lists{{1, 2}, {3, 4}, {5, 6, 7}, {}, {9, 10}, {11}}; auto expected_keys = cudf::test::fixed_width_column_wrapper{1, 2, 3}; auto expected_values = lists{{1, 2}, {5, 6, 7}, {9, 10}}; diff --git a/cpp/tests/groupby/replace_nulls_tests.cpp b/cpp/tests/groupby/replace_nulls_tests.cpp index fe2106ff3cdf..e11177c997b6 100644 --- a/cpp/tests/groupby/replace_nulls_tests.cpp +++ b/cpp/tests/groupby/replace_nulls_tests.cpp @@ -223,25 +223,25 @@ TYPED_TEST(GroupbyReplaceNullsListsTest, PrecedingFillNested) // clang-format off LCW val({{}, - LCW({LCW({1, -1, 3}, Mask_t{1, 0, 1}.begin()), {}}, Mask_t{1, 0}.begin()), - LCW({LCW{}, LCW({102, -1}, Mask_t{1, 0}.begin())}, Mask_t{0, 1}.begin()), + {{{{1, -1, 3}, Mask_t{1, 0, 1}.begin()}, {}}, Mask_t{1, 0}.begin()}, + {{{}, {{102, -1}, Mask_t{1, 0}.begin()}}, Mask_t{0, 1}.begin()}, {}, {}, - {LCW({{}}, Mask_t{0}.begin()), LCW{}}, - {LCW({-1, 202}, Mask_t{0, 1}.begin()), LCW{}}}, + {{{{}}, Mask_t{0}.begin()}, {}}, + {{{-1, 202}, Mask_t{0, 1}.begin()}, {}}}, Mask_t{0, 1, 1, 0, 0, 1, 1}.begin()); // clang-format on cudf::test::fixed_width_column_wrapper expect_key{0, 0, 0, 1, 1, 1, 1}; // clang-format off - LCW expect_val({LCW({LCW({1, -1, 3}, Mask_t{1, 0, 1}.begin()), {}}, Mask_t{1, 0}.begin()), - LCW({LCW({1, -1, 3}, Mask_t{1, 0, 1}.begin()), {}}, Mask_t{1, 0}.begin()), - {LCW({{}}, Mask_t{0}.begin()), LCW{}}, + LCW expect_val({{{{{1, -1, 3}, Mask_t{1, 0, 1}.begin()}, {}}, Mask_t{1, 0}.begin()}, + {{{{1, -1, 3}, Mask_t{1, 0, 1}.begin()}, {}}, Mask_t{1, 0}.begin()}, + {{{{}}, Mask_t{0}.begin()}, {}}, {}, - LCW({LCW{}, LCW({102, -1}, Mask_t{1, 0}.begin())}, Mask_t{0, 1}.begin()), - LCW({LCW{}, LCW({102, -1}, Mask_t{1, 0}.begin())}, Mask_t{0, 1}.begin()), - {LCW({-1, 202}, Mask_t{0, 1}.begin()), LCW{}}}, + {{{}, {{102, -1}, Mask_t{1, 0}.begin()}}, Mask_t{0, 1}.begin()}, + {{{}, {{102, -1}, Mask_t{1, 0}.begin()}}, Mask_t{0, 1}.begin()}, + {{{-1, 202}, Mask_t{0, 1}.begin()}, {}}}, Mask_t{1, 1, 1, 0, 1 ,1 ,1}.begin()); // clang-format on @@ -270,12 +270,12 @@ TYPED_TEST(GroupbyReplaceNullsListsTest, FollowingFillNested) cudf::test::fixed_width_column_wrapper key{1, 0, 1, 1, 0, 0, 1}; // clang-format off - LCW val({LCW({LCW{}, LCW({102, -1}, Mask_t{1, 0}.begin())}, Mask_t{0, 1}.begin()), - LCW({LCW({1, -1, 3}, Mask_t{1, 0, 1}.begin()), {}}, Mask_t{1, 0}.begin()), + LCW val({{{{}, {{102, -1}, Mask_t{1, 0}.begin()}}, Mask_t{0, 1}.begin()}, + {{{{1, -1, 3}, Mask_t{1, 0, 1}.begin()}, {}}, Mask_t{1, 0}.begin()}, {}, - {LCW({-1, 202}, Mask_t{0, 1}.begin()), LCW{}}, + {{{-1, 202}, Mask_t{0, 1}.begin()}, {}}, {}, - {LCW({{}}, Mask_t{0}.begin()), LCW{}}, + {{{{}}, Mask_t{0}.begin()}, {}}, {}}, Mask_t{1, 1, 0, 1, 0, 1, 0}.begin()); // clang-format on @@ -283,12 +283,12 @@ TYPED_TEST(GroupbyReplaceNullsListsTest, FollowingFillNested) cudf::test::fixed_width_column_wrapper expect_key{0, 0, 0, 1, 1, 1, 1}; // clang-format off - LCW expect_val({LCW({LCW({1, -1, 3}, Mask_t{1, 0, 1}.begin()), {}}, Mask_t{1, 0}.begin()), - {LCW({{}}, Mask_t{0}.begin()), LCW{}}, - {LCW({{}}, Mask_t{0}.begin()), LCW{}}, - LCW({LCW{}, LCW({102, -1}, Mask_t{1, 0}.begin())}, Mask_t{0, 1}.begin()), - {LCW({-1, 202}, Mask_t{0, 1}.begin()), LCW{}}, - {LCW({-1, 202}, Mask_t{0, 1}.begin()), LCW{}}, + LCW expect_val({{{{{1, -1, 3}, Mask_t{1, 0, 1}.begin()}, {}}, Mask_t{1, 0}.begin()}, + {{{{}}, Mask_t{0}.begin()}, {}}, + {{{{}}, Mask_t{0}.begin()}, {}}, + {{{}, {{102, -1}, Mask_t{1, 0}.begin()}}, Mask_t{0, 1}.begin()}, + {{{-1, 202}, Mask_t{0, 1}.begin()}, {}}, + {{{-1, 202}, Mask_t{0, 1}.begin()}, {}}, {}}, Mask_t{1, 1, 1, 1, 1, 1, 0}.begin()); // clang-format on @@ -327,7 +327,7 @@ TEST_F(GroupbyReplaceNullsStructsTest, PrecedingFill) SCW expect_val = this->data( {{-1, -1, -1, 1, 1, -1, -1}, {false, false, false, true, true, false, false}}, {{"yy", "yy", "", "x", "x", "zz", "zz"}, {true, true, false, true, true, true, true}}, - LCW({LCW{-1}, {-1}, {42}, {1, 2, 3}, {1, 2, 3}, {}, {}}, Mask_t{1, 1, 1, 1, 1, 0, 0}.begin()), + LCW({{-1}, {-1}, {42}, {1, 2, 3}, {1, 2, 3}, {}, {}}, Mask_t{1, 1, 1, 1, 1, 0, 0}.begin()), {1, 1, 1, 1, 1, 1, 1}); TestReplaceNullsGroupbySingle(key, val, expect_key, expect_val, cudf::replace_policy::PRECEDING); @@ -349,11 +349,11 @@ TEST_F(GroupbyReplaceNullsStructsTest, FollowingFill) cudf::test::fixed_width_column_wrapper expect_key{0, 0, 0, 1, 1, 1, 1}; - SCW expect_val = this->data( - {{-1, -1, -1, 1, -1, -1, -1}, {false, false, false, true, false, false, false}}, - {{"yy", "", "", "x", "zz", "zz", ""}, {true, false, false, true, true, true, false}}, - LCW({LCW{-1}, {42}, {42}, {1, 2, 3}, {}, {}, {}}, Mask_t{1, 1, 1, 1, 0, 0, 0}.begin()), - {1, 1, 1, 1, 1, 1, 0}); + SCW expect_val = + this->data({{-1, -1, -1, 1, -1, -1, -1}, {false, false, false, true, false, false, false}}, + {{"yy", "", "", "x", "zz", "zz", ""}, {true, false, false, true, true, true, false}}, + LCW({{-1}, {42}, {42}, {1, 2, 3}, {}, {}, {}}, Mask_t{1, 1, 1, 1, 0, 0, 0}.begin()), + {1, 1, 1, 1, 1, 1, 0}); TestReplaceNullsGroupbySingle(key, val, expect_key, expect_val, cudf::replace_policy::FOLLOWING); } diff --git a/cpp/tests/interop/from_arrow_device_test.cpp b/cpp/tests/interop/from_arrow_device_test.cpp index a4c991c6ee78..e2faa0b24b9c 100644 --- a/cpp/tests/interop/from_arrow_device_test.cpp +++ b/cpp/tests/interop/from_arrow_device_test.cpp @@ -223,8 +223,8 @@ TYPED_TEST(FromArrowDeviceTestDurationsTest, DurationTable) TEST_F(FromArrowDeviceTest, NestedList) { auto valids = cudf::test::iterators::nulls_at_multiples_of(3); - auto col = cudf::test::lists_column_wrapper( - {{{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids}); + using LCW = cudf::test::lists_column_wrapper; + auto col = LCW({{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids); cudf::table_view expected_table_view({col}); nanoarrow::UniqueSchema input_schema; @@ -275,7 +275,6 @@ TEST_F(FromArrowDeviceTest, NestedList) } namespace { - // A fixed_size_list array has only a validity buffer; there is no offsets buffer to wire up. void populate_fixed_size_list_from_col(ArrowArray* arr, cudf::lists_column_view view) { @@ -536,9 +535,8 @@ TEST_F(FromArrowDeviceTest, StructColumn) auto int_col2 = cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); - auto list_col = cudf::test::lists_column_wrapper( - {{{1, 2}, {3, 4}, {5}}, {{{6}}}, {{7}, {8, 9}}}) // NOLINT - .release(); + using LCW = cudf::test::lists_column_wrapper; + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/from_arrow_host_test.cpp b/cpp/tests/interop/from_arrow_host_test.cpp index 70d094e78e1b..03391e52a96d 100644 --- a/cpp/tests/interop/from_arrow_host_test.cpp +++ b/cpp/tests/interop/from_arrow_host_test.cpp @@ -561,8 +561,8 @@ TYPED_TEST(FromArrowHostDeviceTestDecimalsTest, FixedPointTableLargeNulls) TEST_F(FromArrowHostDeviceTest, NestedList) { auto valids = cudf::test::iterators::nulls_at_multiples_of(3); - auto col = cudf::test::lists_column_wrapper( - {{{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids}); + using LCW = cudf::test::lists_column_wrapper; + auto col = LCW({{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids); cudf::table_view expected_table_view({col}); nanoarrow::UniqueSchema input_schema; @@ -634,7 +634,6 @@ TEST_F(FromArrowHostDeviceTest, NestedList) } namespace { - ArrowDeviceArray as_host_device_array(nanoarrow::UniqueArray const& array) { ArrowDeviceArray input{}; @@ -859,9 +858,8 @@ TEST_F(FromArrowHostDeviceTest, StructColumn) auto int_col2 = cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); - auto list_col = cudf::test::lists_column_wrapper( - {{{1, 2}, {3, 4}, {5}}, {{{6}}}, {{7}, {8, 9}}}) // NOLINT - .release(); + using LCW = cudf::test::lists_column_wrapper; + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/to_arrow_device_test.cpp b/cpp/tests/interop/to_arrow_device_test.cpp index 75c429aedf77..52582f039ace 100644 --- a/cpp/tests/interop/to_arrow_device_test.cpp +++ b/cpp/tests/interop/to_arrow_device_test.cpp @@ -492,8 +492,8 @@ TYPED_TEST(ToArrowDeviceTestDurationsTest, DurationTable) TEST_F(ToArrowDeviceTest, NestedList) { auto valids = cudf::test::iterators::nulls_at_multiples_of(3); - auto col = cudf::test::lists_column_wrapper( - {{{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids}); + using LCW = cudf::test::lists_column_wrapper; + auto col = LCW({{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids); std::vector> cols; cols.emplace_back(col.release()); @@ -566,9 +566,8 @@ TEST_F(ToArrowDeviceTest, StructColumn) auto int_col2 = cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); - auto list_col = cudf::test::lists_column_wrapper( - {{{1, 2}, {3, 4}, {5}}, {{{6}}}, {{7}, {8, 9}}}) // NOLINT - .release(); + using LCW = cudf::test::lists_column_wrapper; + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/to_arrow_host_test.cpp b/cpp/tests/interop/to_arrow_host_test.cpp index a136d453b6df..542ff6ed9d23 100644 --- a/cpp/tests/interop/to_arrow_host_test.cpp +++ b/cpp/tests/interop/to_arrow_host_test.cpp @@ -494,8 +494,8 @@ TYPED_TEST(ToArrowHostDeviceTestDurationsTest, DurationTable) TEST_F(ToArrowHostDeviceTest, NestedList) { auto valids = cudf::test::iterators::nulls_at_multiples_of(3); - auto col = cudf::test::lists_column_wrapper( - {{{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids}); + using LCW = cudf::test::lists_column_wrapper; + auto col = LCW({{{{1, 2}, valids}, {{3, 4}, valids}, {5}}, {{6}, {{7, 8, 9}, valids}}}, valids); cudf::table_view input_view({col}); nanoarrow::UniqueSchema expected_schema; @@ -584,9 +584,8 @@ TEST_F(ToArrowHostDeviceTest, StructColumn) auto int_col2 = cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); - auto list_col = cudf::test::lists_column_wrapper( - {{{1, 2}, {3, 4}, {5}}, {{{6}}}, {{7}, {8, 9}}}) // NOLINT - .release(); + using LCW = cudf::test::lists_column_wrapper; + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/io/json/json_test.cpp b/cpp/tests/io/json/json_test.cpp index 0f9731dd2011..440d8049a69a 100644 --- a/cpp/tests/io/json/json_test.cpp +++ b/cpp/tests/io/json/json_test.cpp @@ -2361,7 +2361,6 @@ TEST_F(JsonReaderTest, ValueValidation) TEST_F(JsonReaderTest, MixedTypes) { using LCWS = cudf::test::lists_column_wrapper; - using LCWI = cudf::test::lists_column_wrapper; using valid_t = std::vector; { // Simple test for mixed types @@ -2469,7 +2468,7 @@ TEST_F(JsonReaderTest, MixedTypes) { "a": [1,2,3] } { "a": null } )", - cudf::test::lists_column_wrapper{{LCWI{1L, 2L, 3L}, LCWI{4L, 5L}}, valid_t{1, 0}.begin()}); + cudf::test::lists_column_wrapper({{1L, 2L, 3L}, {4L, 5L}}, valid_t{1, 0}.begin())); // All mixed: // LIST + STRUCT + STR, STRUCT + LIST + STR, STR + STRUCT + LIST, STRUCT + LIST + null @@ -2523,17 +2522,14 @@ TEST_F(JsonReaderTest, MixedTypes) // max_rowoffsets is generated based on parent col id, // so, even if mixed types are present, their row offset will be correct. - cudf::test::lists_column_wrapper expected_list{ - { - cudf::test::lists_column_wrapper({LCWS({"1", "2", "3"}), LCWS({"4", "5", "6"})}), - cudf::test::lists_column_wrapper({LCWS()}), - cudf::test::lists_column_wrapper({LCWS()}), // null - cudf::test::lists_column_wrapper({LCWS()}), // null - cudf::test::lists_column_wrapper({LCWS({"{\"c\": -1}"}), LCWS({"5"})}), - cudf::test::lists_column_wrapper({LCWS({"7"}), LCWS({"8", "9"})}), - cudf::test::lists_column_wrapper({LCWS()}), // null - }, - valid_t{1, 1, 0, 0, 1, 1, 0}.begin()}; + LCWS expected_list({LCWS::nested({{"1", "2", "3"}, {"4", "5", "6"}}), + LCWS::nested({{}}), + LCWS::nested({{}}), // null + LCWS::nested({{}}), // null + LCWS::nested({{"{\"c\": -1}"}, {"5"}}), + LCWS::nested({{"7"}, {"8", "9"}}), + LCWS::nested({{}})}, // null + valid_t{1, 1, 0, 0, 1, 1, 0}.begin()); test_fn(R"( {"b": [ [1, 2, 3], [ 4, 5, 6] ]} {"b": [[]]} @@ -3990,7 +3986,7 @@ TEST_F(JsonReaderTest, MalformedStructuralCharsInValues) EXPECT_EQ(tbl.tbl->get_column(0).null_count(), 1); // Column "b": list [[10,20], null, [50,60]]. using LCWI = cudf::test::lists_column_wrapper; - LCWI expected_b{{LCWI{10, 20}, LCWI{}, LCWI{50, 60}}, std::vector{1, 0, 1}.begin()}; + LCWI expected_b{{{10, 20}, {}, {50, 60}}, std::vector{1, 0, 1}.begin()}; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(tbl.tbl->view().column(1), expected_b); } diff --git a/cpp/tests/io/json/json_writer.cpp b/cpp/tests/io/json/json_writer.cpp index aba9ed5ffc86..aca97abd4cd3 100644 --- a/cpp/tests/io/json/json_writer.cpp +++ b/cpp/tests/io/json/json_writer.cpp @@ -253,7 +253,7 @@ TEST_F(JsonWriterTest, WriteReadNested) cudf::test::fixed_width_column_wrapper e{{0, 0, 4, 9}, nulls_at({0, 1})}; cudf::test::structs_column_wrapper c{{d, e}}; cudf::test::fixed_width_column_wrapper f{5.5, 10.5, 5.5, 10.5}; - LCW g{{LCW{1}, LCW{0}, LCW{{2, 0}, null_at(1)}, LCW{3, 4, 5}}, null_at(1)}; + LCW g{{{1}, {0}, {{2, 0}, null_at(1)}, {3, 4, 5}}, null_at(1)}; cudf::table_view tbl_view{{a, b, c, f, g}}; cudf::io::table_metadata mt{{{"a"}, {"b"}, {"c"}, {"f"}, {"g"}}}; mt.schema_info[2].children = {{"d"}, {"e"}}; diff --git a/cpp/tests/io/orc_chunked_reader_test.cu b/cpp/tests/io/orc_chunked_reader_test.cu index c867f919a794..36fbd5931c01 100644 --- a/cpp/tests/io/orc_chunked_reader_test.cu +++ b/cpp/tests/io/orc_chunked_reader_test.cu @@ -631,8 +631,7 @@ TEST_F(OrcChunkedReaderTest, TestChunkedReadWithListsNoNulls) // // However, `segmented_row_bit_count` used in chunked reader returns 200000, // thus we consider as having only 200000 bytes in total. - auto const template_lists = int32s_lists_col{ - int32s_lists_col{}, int32s_lists_col{0}, int32s_lists_col{1, 2}, int32s_lists_col{3, 4, 5}}; + auto const template_lists = int32s_lists_col{{}, {0}, {1, 2}, {3, 4, 5}}; auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) -> int32_t { return i % 4; }); @@ -717,10 +716,10 @@ TEST_F(OrcChunkedReaderTest, TestChunkedReadWithListsHavingNulls) // thus we consider as having only 142500 bytes in total. auto const template_lists = int32s_lists_col{// these will all be null - int32s_lists_col{}, - int32s_lists_col{0}, - int32s_lists_col{1, 2}, - int32s_lists_col{3, 4, 5, 6, 7, 8, 9} /* this list will be nullified out */}; + {}, + {0}, + {1, 2}, + {3, 4, 5, 6, 7, 8, 9} /* this list will be nullified out */}; auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) -> int32_t { return i % 4; }); auto const gather_iter = gather_values.begin(); @@ -809,9 +808,8 @@ TEST_F(OrcChunkedReaderTest, TestChunkedReadWithStructsOfLists) auto const str_iter = str_values.begin(); child_columns.emplace_back(strings_col{str_iter, str_iter + num_rows}.release()); - auto const template_lists = int32s_lists_col{ - int32s_lists_col{}, int32s_lists_col{0}, int32s_lists_col{0, 1}, int32s_lists_col{0, 1, 2}}; - auto const gather_values = std::views::iota(int32_t{0}) | + auto const template_lists = int32s_lists_col{{}, {0}, {0, 1}, {0, 1, 2}}; + auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) -> int32_t { return i % 4; }); auto const gather_iter = gather_values.begin(); auto const gather_map = int32s_col(gather_iter, gather_iter + num_rows); diff --git a/cpp/tests/io/parquet_chunked_reader_test.cu b/cpp/tests/io/parquet_chunked_reader_test.cu index b280b82b3506..944635c243df 100644 --- a/cpp/tests/io/parquet_chunked_reader_test.cu +++ b/cpp/tests/io/parquet_chunked_reader_test.cu @@ -746,8 +746,7 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadWithListsNoNulls) // 20001 offsets : 80004 bytes // 30000 ints : 120000 bytes // total : 200004 bytes - auto const template_lists = int32s_lists_col{ - int32s_lists_col{}, int32s_lists_col{0}, int32s_lists_col{1, 2}, int32s_lists_col{3, 4, 5}}; + auto const template_lists = int32s_lists_col{{}, {0}, {1, 2}, {3, 4, 5}}; auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) { return i % 4; }); @@ -756,10 +755,7 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadWithListsNoNulls) input_columns.emplace_back( std::move(cudf::gather(cudf::table_view{{template_lists}}, gather_map)->release().front())); - auto const bools_lists = bools_lists_col{bools_lists_col{}, - bools_lists_col{false}, - bools_lists_col{false, true}, - bools_lists_col{true, true, false}}; + auto const bools_lists = bools_lists_col{{}, {false}, {false, true}, {true, true, false}}; input_columns.emplace_back( std::move(cudf::gather(cudf::table_view{{bools_lists}}, gather_map)->release().front())); @@ -836,10 +832,10 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadWithListsHavingNulls) // total : 142504 bytes auto const template_lists = int32s_lists_col{// these will all be null - int32s_lists_col{}, - int32s_lists_col{0}, - int32s_lists_col{1, 2}, - int32s_lists_col{3, 4, 5, 6, 7, 8, 9} /* this list will be nullified out */}; + {}, + {0}, + {1, 2}, + {3, 4, 5, 6, 7, 8, 9} /* this list will be nullified out */}; auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) { return i % 4; }); auto const gather_iter = gather_values.begin(); @@ -849,11 +845,10 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadWithListsHavingNulls) auto const bools_lists = bools_lists_col{ // these will all be null - bools_lists_col{}, - bools_lists_col{false}, - bools_lists_col{false, true}, - bools_lists_col{ - true, true, false, true, true, false, false} /* this list will be nullified out */}; + {}, + {false}, + {false, true}, + {true, true, false, true, true, false, false} /* this list will be nullified out */}; input_columns.emplace_back( std::move(cudf::gather(cudf::table_view{{bools_lists}}, gather_map)->release().front())); @@ -937,8 +932,7 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadWithStructsOfLists) auto const str_iter = str_values.begin(); child_columns.emplace_back(strings_col{str_iter, str_iter + num_rows}.release()); - auto const template_lists = int32s_lists_col{ - int32s_lists_col{}, int32s_lists_col{0}, int32s_lists_col{0, 1}, int32s_lists_col{0, 1, 2}}; + auto const template_lists = int32s_lists_col{{}, {0}, {0, 1}, {0, 1, 2}}; auto const gather_values = std::views::iota(int32_t{0}) | std::views::transform([&](int32_t i) { return i % 4; }); auto const gather_iter = gather_values.begin(); diff --git a/cpp/tests/io/parquet_chunked_writer_test.cpp b/cpp/tests/io/parquet_chunked_writer_test.cpp index 66ea0c2e9687..27b3c7a208de 100644 --- a/cpp/tests/io/parquet_chunked_writer_test.cpp +++ b/cpp/tests/io/parquet_chunked_writer_test.cpp @@ -280,7 +280,7 @@ TEST_F(ParquetChunkedWriterTest, ListOfStructOfStructOfListOfList) // [[1, 2, 3], [], [4, 5], [], [0, 6, 0]] // [[7, 8], []] // [[]] - lcw flats_1{lcw{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, lcw{lcw{}}}; + lcw flats_1{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, lcw::nested({{}})}; auto weight_1 = cudf::test::fixed_width_column_wrapper{{57.5, 51.1, 15.3, 1.1}}; auto ages_1 = cudf::test::fixed_width_column_wrapper{{30, 27, 5, 31}}; @@ -305,7 +305,7 @@ TEST_F(ParquetChunkedWriterTest, ListOfStructOfStructOfListOfList) // [[]] // [[], [], []] - lcw flats_2{lcw{lcw{}}, lcw{lcw{}, lcw{}, lcw{}}}; + lcw flats_2{{{}}, {{}, {}, {}}}; auto weight_2 = cudf::test::fixed_width_column_wrapper{{-1.0, -1.0}}; auto ages_2 = cudf::test::fixed_width_column_wrapper{{351, 351}, {true, false}}; @@ -430,7 +430,7 @@ TEST_F(ParquetChunkedWriterTest, MismatchedStructureList) // [[7, 8]] // [] // [[]] - lcw col01{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, lcw{}, lcw{lcw{}}}; + lcw col01{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; // COL2 (non-nested columns to test proper schema construction) size_t num_rows = static_cast(col00).size(); diff --git a/cpp/tests/io/parquet_v2_test.cpp b/cpp/tests/io/parquet_v2_test.cpp index 2907cd1a4512..2c000b4f02f2 100644 --- a/cpp/tests/io/parquet_v2_test.cpp +++ b/cpp/tests/io/parquet_v2_test.cpp @@ -295,12 +295,12 @@ TEST_P(ParquetV2Test, SlicedTable) lcw col4{{ {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - {{lcw{lcw{}}, lcw{}, lcw{}, lcw{lcw{}}}, valids}, - lcw{lcw{lcw{}}}, + {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, + lcw::nested({lcw::nested({{}})}), {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - lcw{lcw{lcw{}}}, - {{lcw{lcw{}}, lcw{}, lcw{}, lcw{lcw{}}}, valids}, + lcw::nested({lcw::nested({{}})}), + {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, }, valids2}; @@ -331,13 +331,13 @@ TEST_P(ParquetV2Test, SlicedTable) // [[], [], []] // [[10]] // [[13, 14], [15]] - lcw flats{lcw{}, + lcw flats{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, - lcw{lcw{}}, - lcw{lcw{}}, - lcw{lcw{}, lcw{}, lcw{}}, - {lcw{10}}, + lcw::nested({{}}), + lcw::nested({{}}), + {{}, {}, {}}, + lcw::nested({{10}}), {{13, 14}, {15}}}; auto struct_1 = cudf::test::structs_column_wrapper{land, flats}; @@ -398,13 +398,13 @@ TEST_P(ParquetV2Test, ListColumn) // [[7, 8]] // [] // [[]] - lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, lcw{}, lcw{lcw{}}}; + lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] // [[7, 8]] // [] // [[]] - lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, valids2}, {{7, 8}}, lcw{}, lcw{lcw{}}}; + lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, valids2}, {{7, 8}}, {}, lcw::nested({{}})}; // [[1, 2, 3], [], [4, 5], NULL, [NULL, 6, NULL]] // [[7, 8]] @@ -413,8 +413,8 @@ TEST_P(ParquetV2Test, ListColumn) using dlcw = cudf::test::lists_column_wrapper; dlcw col3{{{{1., 2., 3.}, {}, {4., 5.}, {}, {{0., 6., 0.}, valids}}, valids2}, {{7., 8.}}, - dlcw{}, - dlcw{dlcw{}}}; + {}, + dlcw::nested({{}})}; // TODO: uint16_t lists are not read properly in parquet reader // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -431,15 +431,15 @@ TEST_P(ParquetV2Test, ListColumn) // [] // NULL lcw col5{ - {{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, valids}}, valids2}, {{7, 8}}, lcw{}, lcw{lcw{}}}, + {{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, valids}}, valids2}, {{7, 8}}, {}, lcw::nested({{}})}, valids2}; using strlcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col6{ {{"Monday", "Monday", "Friday"}, {}, {"Monday", "Friday"}, {}, {"Sunday", "Funday"}}, {{"bee", "sting"}}, - strlcw{}, - strlcw{strlcw{}}}; + {}, + strlcw::nested({{}})}; // [[[NULL,2,NULL,4]], [[NULL,6,NULL], [8,9]]] // [NULL, [[13],[14,15,16]], NULL] @@ -448,8 +448,8 @@ TEST_P(ParquetV2Test, ListColumn) lcw col7{{ {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - {{lcw{lcw{}}, lcw{}, lcw{}, lcw{lcw{}}}, valids}, - lcw{lcw{lcw{}}}, + {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, + lcw::nested({lcw::nested({{}})}), }, valids2}; @@ -517,12 +517,12 @@ TEST_P(ParquetV2Test, StructOfList) // [[]] // [[]] // [[], [], []] - lcw flats{lcw{}, + lcw flats{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, - lcw{lcw{}}, - lcw{lcw{}}, - lcw{lcw{}, lcw{}, lcw{}}}; + lcw::nested({{}}), + lcw::nested({{}}), + {{}, {}, {}}}; auto struct_1 = cudf::test::structs_column_wrapper{{weights_col, ages_col, land_unit, flats}, {true, true, true, true, false, true}}; @@ -1189,7 +1189,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // [[]] // def histogram [1, 3, 10] // rep histogram [4, 4, 6] - lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, lcw{}, lcw{lcw{}}}; + lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; // 4 nulls // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -1198,7 +1198,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // [[]] // def histogram [1, 1, 2, 10] // rep histogram [4, 4, 6] - lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, lcw{}, lcw{lcw{}}}; + lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, lcw::nested({{}})}; // 6 nulls // [[1, 2, 3], [], [4, 5], NULL, [NULL, 6, NULL]] @@ -1210,8 +1210,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) using dlcw = cudf::test::lists_column_wrapper; dlcw col3{{{{1., 2., 3.}, {}, {4., 5.}, {}, {{0., 6., 0.}, nulls_at({0, 2})}}, null_at(3)}, {{7., 8.}}, - dlcw{}, - dlcw{dlcw{}}}; + {}, + dlcw::nested({{}})}; // 4 nulls // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -1222,7 +1222,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // rep histogram [4, 4, 6] using ui16lcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col4{ - {{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, ui16lcw{}, ui16lcw{ui16lcw{}}}, + {{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, ui16lcw::nested({{}})}, null_at(3)}; // 6 nulls @@ -1234,8 +1234,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // rep histogram [4, 4, 6] lcw col5{{{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, nulls_at({0, 2})}}, null_at(3)}, {{7, 8}}, - lcw{}, - lcw{lcw{}}}, + {}, + lcw::nested({{}})}, null_at(3)}; // 4 nulls @@ -1245,8 +1245,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) cudf::test::lists_column_wrapper col6{ {{"Monday", "Monday", "Friday"}, {}, {"Monday", "Friday"}, {}, {"Sunday", "Funday"}}, {{"bee", "sting"}}, - strlcw{}, - strlcw{strlcw{}}}; + {}, + strlcw::nested({{}})}; // 5 nulls // def histogram [1, 3, 1, 8] @@ -1258,8 +1258,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) {}, {"Sunday", "Funday"}}, {{"bee", "sting"}}, - strlcw{}, - strlcw{strlcw{}}}; + {}, + strlcw::nested({{}})}; // 11 nulls // D 5 6 5 6 5 6 5 6 6 @@ -1279,8 +1279,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) lcw col8{{ {{{{1, 2, 3, 4}, nulls_at({0, 2})}}, {{{5, 6, 7}, nulls_at({0, 2})}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, nulls_at({0, 2})}, - {{lcw{lcw{}}, lcw{}, lcw{}, lcw{lcw{}}}, nulls_at({0, 2})}, - lcw{lcw{lcw{}}}, + {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, nulls_at({0, 2})}, + lcw::nested({lcw::nested({{}})}), }, null_at(3)}; diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index e2347681433f..c88bb49499e8 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -24,9 +24,9 @@ constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_leve constexpr int32_t null{0}; template -auto build_lists_col(T& list, Ts&... lists) +auto build_lists_init(T const& list, Ts const&... lists) { - return T(std::initializer_list{std::move(list), std::move(lists)...}); + return T::nested({list, lists...}); } } // namespace @@ -60,12 +60,12 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row1 = ListsCol{ListsCol{}}; - auto row2 = ListsCol{{7, 8}, {9, 10}}; - auto const col = build_lists_col(row0, row1, row2); + auto row0 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row1 = ListsCol::nested({{}}); + auto row2 = ListsCol::nested({{7, 8}, {9, 10}}); + auto const col = ListsCol(build_lists_init(row0, row1, row2)); auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = ListsCol{{1, 2, 3, 4, 5, 6}, {}, {7, 8, 9, 10}}; + auto const expected = ListsCol({{1, 2, 3, 4, 5, 6}, {}, {7, 8, 9, 10}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -73,80 +73,73 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto row00 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row01 = ListsCol{ListsCol{}}; - auto row02 = ListsCol{{7, 8}, {9, 10}}; - auto row0 = build_lists_col(row00, row01, row02); + auto row00 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row01 = ListsCol::nested({{}}); + auto row02 = ListsCol::nested({{7, 8}, {9, 10}}); + auto row0 = build_lists_init(row00, row01, row02); - auto row10 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row11 = ListsCol{ListsCol{}}; - auto row12 = ListsCol{{7, 8}, {9, 10}}; - auto row1 = build_lists_col(row10, row11, row12); + auto row10 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row11 = ListsCol::nested({{}}); + auto row12 = ListsCol::nested({{7, 8}, {9, 10}}); + auto row1 = build_lists_init(row10, row11, row12); - auto row20 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row21 = ListsCol{ListsCol{}}; - auto row22 = ListsCol{{7, 8}, {9, 10}}; - auto row2 = build_lists_col(row20, row21, row22); + auto row20 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row21 = ListsCol::nested({{}}); + auto row22 = ListsCol::nested({{7, 8}, {9, 10}}); + auto row2 = build_lists_init(row20, row21, row22); - auto const col = build_lists_col(row0, row1, row2); + auto const col = ListsCol(build_lists_init(row0, row1, row2)); auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = ListsCol{ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, - ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, - ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}}; + auto const expected = ListsCol({{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, + {{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, + {{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnNoNull) { - auto row0 = StrListsCol{StrListsCol{"Tomato", "Apple"}, StrListsCol{"Orange"}}; - auto row1 = StrListsCol{StrListsCol{"Banana", "Kiwi", "Cherry"}, StrListsCol{"Lemon", "Peach"}}; - auto row2 = StrListsCol{StrListsCol{"Coconut"}, StrListsCol{}}; - auto const col = build_lists_col(row0, row1, row2); + auto row0 = StrListsCol::nested({{"Tomato", "Apple"}, {"Orange"}}); + auto row1 = StrListsCol::nested({{"Banana", "Kiwi", "Cherry"}, {"Lemon", "Peach"}}); + auto row2 = StrListsCol::nested({{"Coconut"}, {}}); + auto const col = StrListsCol(build_lists_init(row0, row1, row2)); auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{StrListsCol{"Tomato", "Apple", "Orange"}, - StrListsCol{"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, - StrListsCol{"Coconut"}}; + auto const expected = StrListsCol( + {{"Tomato", "Apple", "Orange"}, {"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, {"Coconut"}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol{{ListsCol{{1, null, 3, 4}, null_at(1)}, - ListsCol{{10, 11, 12, null}, null_at(3)}, - ListsCol{} /*NULL*/}, - null_at(2)}; - auto row1 = ListsCol{ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{{13, 14, 15, 16, 17, null}, null_at(5)}, - ListsCol{{20, null}, null_at(1)}}; - auto row2 = ListsCol{{ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 21, null, null}, nulls_at({0, 2, 3})}}, - null_at(1)}; - auto row3 = ListsCol{{ListsCol{} /*NULL*/, ListsCol{{null, 18}, null_at(0)}}, null_at(0)}; - auto row4 = ListsCol{ListsCol{{1, 2, null, 4}, null_at(2)}, - ListsCol{{19, 20, null}, null_at(2)}, - ListsCol{22, 23, 24, 25}}; - auto row5 = ListsCol{ListsCol{{1, 2, 3, null}, null_at(3)}, - ListsCol{{null}, null_at(0)}, - ListsCol{{null, null, null, null, null}, all_nulls()}}; - auto row6 = - ListsCol{{ListsCol{} /*NULL*/, ListsCol{} /*NULL*/, ListsCol{} /*NULL*/}, all_nulls()}; - auto const col = build_lists_col(row0, row1, row2, row3, row4, row5, row6); + auto row0 = ListsCol::nested( + {{{1, null, 3, 4}, null_at(1)}, {{10, 11, 12, null}, null_at(3)}, {} /*NULL*/}, null_at(2)); + auto row1 = ListsCol::nested({{{null, 2, 3, 4}, null_at(0)}, + {{13, 14, 15, 16, 17, null}, null_at(5)}, + {{20, null}, null_at(1)}}); + auto row2 = ListsCol::nested( + {{{null, 2, 3, 4}, null_at(0)}, {} /*NULL*/, {{null, 21, null, null}, nulls_at({0, 2, 3})}}, + null_at(1)); + auto row3 = ListsCol::nested({{} /*NULL*/, {{null, 18}, null_at(0)}}, null_at(0)); + auto row4 = ListsCol::nested( + {{{1, 2, null, 4}, null_at(2)}, {{19, 20, null}, null_at(2)}, {22, 23, 24, 25}}); + auto row5 = ListsCol::nested({{{1, 2, 3, null}, null_at(3)}, + {{null}, null_at(0)}, + {{null, null, null, null, null}, all_nulls()}}); + auto row6 = ListsCol::nested({{} /*NULL*/, {} /*NULL*/, {} /*NULL*/}, all_nulls()); + auto const col = ListsCol(build_lists_init(row0, row1, row2, row3, row4, row5, row6)); // Ignore null list elements. { - auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = - ListsCol{{ListsCol{{1, null, 3, 4, 10, 11, 12, null}, nulls_at({1, 7})}, - ListsCol{{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, - ListsCol{{null, 2, 3, 4, null, 21, null, null}, nulls_at({0, 4, 6, 7})}, - ListsCol{{null, 18}, null_at(0)}, - ListsCol{{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, - ListsCol{{1, 2, 3, null, null, null, null, null, null, null}, - nulls_at({3, 4, 5, 6, 7, 8, 9})}, - ListsCol{} /*NULL*/}, - null_at(6)}; + auto const results = cudf::lists::concatenate_list_elements(col); + auto const expected = ListsCol( + {{{1, null, 3, 4, 10, 11, 12, null}, nulls_at({1, 7})}, + {{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, + {{null, 2, 3, 4, null, 21, null, null}, nulls_at({0, 4, 6, 7})}, + {{null, 18}, null_at(0)}, + {{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, + {{1, 2, 3, null, null, null, null, null, null, null}, nulls_at({3, 4, 5, 6, 7, 8, 9})}, + {} /*NULL*/}, + null_at(6)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -154,16 +147,15 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) { auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = - ListsCol{{ListsCol{} /*NULL*/, - ListsCol{{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, - ListsCol{} /*NULL*/, - ListsCol{} /*NULL*/, - ListsCol{{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, - ListsCol{{1, 2, 3, null, null, null, null, null, null, null}, - nulls_at({3, 4, 5, 6, 7, 8, 9})}, - ListsCol{} /*NULL*/}, - nulls_at({0, 2, 3, 6})}; + auto const expected = ListsCol( + {{} /*NULL*/, + {{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, + {} /*NULL*/, + {} /*NULL*/, + {{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, + {{1, 2, 3, null, null, null, null, null, null, null}, nulls_at({3, 4, 5, 6, 7, 8, 9})}, + {} /*NULL*/}, + nulls_at({0, 2, 3, 6})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -172,30 +164,30 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull { using ListsCol = cudf::test::lists_column_wrapper; - auto row00 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row01 = ListsCol{ListsCol{}}; /*NULL*/ - auto row02 = ListsCol{{7, 8}, {9, 10}}; - auto row0 = ListsCol{{std::move(row00), std::move(row01), std::move(row02)}, null_at(1)}; + auto row00 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row01 = ListsCol::nested({{}}); /*NULL*/ + auto row02 = ListsCol::nested({{7, 8}, {9, 10}}); + auto row0 = ListsCol::nested({std::move(row00), std::move(row01), std::move(row02)}, null_at(1)); - auto row10 = ListsCol{{{1, 2}, {3}, {4, 5, 6} /*NULL*/}, null_at(2)}; - auto row11 = ListsCol{ListsCol{}}; - auto row12 = ListsCol{{7, 8}, {9, 10}}; - auto row1 = build_lists_col(row10, row11, row12); + auto row10 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6} /*NULL*/}, null_at(2)); + auto row11 = ListsCol::nested({{}}); + auto row12 = ListsCol::nested({{7, 8}, {9, 10}}); + auto row1 = build_lists_init(row10, row11, row12); - auto row20 = ListsCol{{1, 2}, {3}, {4, 5, 6}}; - auto row21 = ListsCol{ListsCol{}}; - auto row22 = ListsCol{ListsCol{{null, 8}, null_at(0)}, {9, 10}}; - auto row2 = build_lists_col(row20, row21, row22); + auto row20 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); + auto row21 = ListsCol::nested({{}}); + auto row22 = ListsCol::nested({{{null, 8}, null_at(0)}, {9, 10}}); + auto row2 = build_lists_init(row20, row21, row22); - auto const col = build_lists_col(row0, row1, row2); + auto const col = ListsCol(build_lists_init(row0, row1, row2)); // Ignore null list elements. { auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = - ListsCol{ListsCol{{1, 2}, {3}, {4, 5, 6}, {7, 8}, {9, 10}}, - ListsCol{{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, - ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, ListsCol{{null, 8}, null_at(0)}, {9, 10}}}; + ListsCol({{{1, 2}, {3}, {4, 5, 6}, {7, 8}, {9, 10}}, + {{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, + {{1, 2}, {3}, {4, 5, 6}, {}, {{null, 8}, null_at(0)}, {9, 10}}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -203,36 +195,34 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull { auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = - ListsCol{{ListsCol{ListsCol{}}, /*NULL*/ - ListsCol{{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, - ListsCol{{1, 2}, {3}, {4, 5, 6}, {}, ListsCol{{null, 8}, null_at(0)}, {9, 10}}}, - null_at(0)}; + auto const expected = ListsCol({ListsCol::nested({{}}), /*NULL*/ + {{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, + {{1, 2}, {3}, {4, 5, 6}, {}, {{null, 8}, null_at(0)}, {9, 10}}}, + null_at(0)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) { - auto row0 = StrListsCol{ - StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}; - auto row1 = StrListsCol{ - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Lemon", "Peach"}}; - auto row2 = StrListsCol{{StrListsCol{"Coconut"}, StrListsCol{} /*NULL*/}, null_at(1)}; - auto const col = build_lists_col(row0, row1, row2); + auto row0 = StrListsCol::nested( + {{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}); + auto row1 = StrListsCol::nested( + {{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Lemon", "Peach"}}); + auto row2 = StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1)); + auto const col = StrListsCol(build_lists_init(row0, row1, row2)); // Ignore null list elements. { auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{ - StrListsCol{{"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" - /*NULL*/}, - nulls_at({1, 4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, - nulls_at({1, 4})}, - StrListsCol{"Coconut"}}; + auto const expected = StrListsCol( + {{{"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" + /*NULL*/}, + nulls_at({1, 4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, nulls_at({1, 4})}, + {"Coconut"}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -240,36 +230,31 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) { auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = StrListsCol{ - {StrListsCol{ - {"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, - nulls_at({1, 4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, - nulls_at({1, 4})}, - StrListsCol{} /*NULL*/}, - null_at(2)}; + auto const expected = StrListsCol( + {{{"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, + nulls_at({1, 4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, nulls_at({1, 4})}, + {} /*NULL*/}, + null_at(2)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndNulls) { - auto row0 = StrListsCol{ - StrListsCol{"", "", ""}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}}; - auto row1 = StrListsCol{ - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{""}}; - auto row2 = StrListsCol{{StrListsCol{"Coconut"}, StrListsCol{} /*NULL*/}, null_at(1)}; - auto const col = build_lists_col(row0, row1, row2); + auto row0 = StrListsCol::nested( + {{"", "", ""}, {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}}); + auto row1 = StrListsCol::nested( + {{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, {""}}); + auto row2 = StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1)); + auto const col = StrListsCol(build_lists_init(row0, row1, row2)); // Ignore null list elements. { auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{ - StrListsCol{{"", "", "", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, - nulls_at({4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}}; + auto const expected = StrListsCol( + {{{"", "", "", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, + {"Coconut"}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -277,12 +262,11 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndN { auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = StrListsCol{ - {StrListsCol{{"", "", "", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, - nulls_at({4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, - StrListsCol{} /*NULL*/}, - null_at(2)}; + auto const expected = StrListsCol( + {{{"", "", "", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, ""}, nulls_at({1, 4})}, + {} /*NULL*/}, + null_at(2)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -291,36 +275,36 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col_original = ListsCol{ListsCol{{1, 2, 3}, {2, 3}}, - ListsCol{{3, 4, 5, 6}, {5, 6}, {}, {7}}, - ListsCol{{7, 7, 7}, {7, 8, 1, 0}, {1}}, - ListsCol{{9, 10, 11}}, - ListsCol{}, - ListsCol{{12, 13, 14, 15}, {16}, {17}}}; + auto const col_original = ListsCol({{{1, 2, 3}, {2, 3}}, + {{3, 4, 5, 6}, {5, 6}, {}, {7}}, + {{7, 7, 7}, {7, 8, 1, 0}, {1}}, + {{9, 10, 11}}, + {}, + {{12, 13, 14, 15}, {16}, {17}}}); { auto const col = cudf::slice(col_original, {0, 3})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = - ListsCol{{1, 2, 3, 2, 3}, {3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}}; + ListsCol({{1, 2, 3, 2, 3}, {3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 4})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = ListsCol{{3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}}; + auto const expected = ListsCol({{3, 4, 5, 6, 5, 6, 7}, {7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 5})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = ListsCol{{7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}, {}}; + auto const expected = ListsCol({{7, 7, 7, 7, 8, 1, 0, 1}, {9, 10, 11}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {3, 6})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = ListsCol{{9, 10, 11}, {}, {12, 13, 14, 15, 16, 17}}; + auto const expected = ListsCol({{9, 10, 11}, {}, {12, 13, 14, 15, 16, 17}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -329,156 +313,154 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol{ListsCol{{null, 2, 3}, null_at(0)}, ListsCol{2, 3}}; - auto row1 = ListsCol{ListsCol{{3, null, null, 6}, nulls_at({1, 2})}, - ListsCol{{5, 6, null}, null_at(2)}, - ListsCol{}, - ListsCol{{7, null}, null_at(1)}}; - auto row2 = ListsCol{ListsCol{7, 7, 7}, ListsCol{{7, 8, null, 0}, null_at(2)}, ListsCol{1}}; - auto row3 = ListsCol{ListsCol{9, 10, 11}}; - auto row4 = ListsCol{ListsCol{}}; - auto row5 = ListsCol{ListsCol{{12, null, 14, 15}, null_at(1)}, ListsCol{16}, ListsCol{17}}; - auto const col_original = build_lists_col(row0, row1, row2, row3, row4, row5); + auto row0 = ListsCol::nested({{{null, 2, 3}, null_at(0)}, {2, 3}}); + auto row1 = ListsCol::nested({{{3, null, null, 6}, nulls_at({1, 2})}, + {{5, 6, null}, null_at(2)}, + {}, + {{7, null}, null_at(1)}}); + auto row2 = ListsCol::nested({{7, 7, 7}, {{7, 8, null, 0}, null_at(2)}, {1}}); + auto row3 = ListsCol::nested({{9, 10, 11}}); + auto row4 = ListsCol::nested({{}}); + auto row5 = ListsCol::nested({{{12, null, 14, 15}, null_at(1)}, {16}, {17}}); + auto const col_original = ListsCol(build_lists_init(row0, row1, row2, row3, row4, row5)); { auto const col = cudf::slice(col_original, {0, 3})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = - ListsCol{ListsCol{{null, 2, 3, 2, 3}, null_at(0)}, - ListsCol{{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, - ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}}; + ListsCol({{{null, 2, 3, 2, 3}, null_at(0)}, + {{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, + {{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 4})[0]; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = - ListsCol{ListsCol{{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, - ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, - ListsCol{9, 10, 11}}; + ListsCol({{{3, null, null, 6, 5, 6, null, 7, null}, nulls_at({1, 2, 6, 8})}, + {{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, + {9, 10, 11}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { - auto const col = cudf::slice(col_original, {2, 5})[0]; - auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = - ListsCol{ListsCol{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, ListsCol{9, 10, 11}, ListsCol{}}; + auto const col = cudf::slice(col_original, {2, 5})[0]; + auto const results = cudf::lists::concatenate_list_elements(col); + auto const expected = ListsCol({{{7, 7, 7, 7, 8, null, 0, 1}, null_at(5)}, {9, 10, 11}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { - auto const col = cudf::slice(col_original, {3, 6})[0]; - auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = - ListsCol{ListsCol{9, 10, 11}, ListsCol{}, ListsCol{{12, null, 14, 15, 16, 17}, null_at(1)}}; + auto const col = cudf::slice(col_original, {3, 6})[0]; + auto const results = cudf::lists::concatenate_list_elements(col); + auto const expected = ListsCol({{9, 10, 11}, {}, {{12, null, 14, 15, 16, 17}, null_at(1)}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) { - auto row0 = StrListsCol{ - StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}}; - auto row1 = StrListsCol{ - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}; - auto row2 = StrListsCol{ - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}}; - auto row3 = StrListsCol{ - {StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{} /*NULL*/}, - null_at(2)}; - auto const col_original = build_lists_col(row0, row1, row2, row3); + auto row0 = StrListsCol::nested( + {{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}}); + auto row1 = StrListsCol::nested( + {{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}, + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}); + auto row2 = StrListsCol::nested( + {{"Coconut"}, + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}}); + auto row3 = StrListsCol::nested( + {{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {} /*NULL*/}, + null_at(2)); + auto const col_original = StrListsCol(build_lists_init(row0, row1, row2, row3)); { auto const col = cudf::slice(col_original, {0, 2})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{StrListsCol{{"Tomato", - "" /*NULL*/, - "Apple", - "Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut"}, - nulls_at({1, 4, 7})}, - StrListsCol{{"Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "" /*NULL*/}, - nulls_at({1, 4, 7, 8, 9})}}; + auto const expected = StrListsCol({{{"Tomato", + "" /*NULL*/, + "Apple", + "Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut"}, + nulls_at({1, 4, 7})}, + {{"Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "" /*NULL*/}, + nulls_at({1, 4, 7, 8, 9})}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {1, 3})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{StrListsCol{{"Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "" /*NULL*/}, - nulls_at({1, 4, 7, 8, 9})}, - StrListsCol{{"Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({2, 3, 4})}}; + auto const expected = StrListsCol({{{"Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "" /*NULL*/}, + nulls_at({1, 4, 7, 8, 9})}, + {{"Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({2, 3, 4})}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 4})[0]; auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = StrListsCol{StrListsCol{{"Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({2, 3, 4})}, - StrListsCol{{"Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({1, 2, 3})}}; + auto const expected = StrListsCol({{{"Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({2, 3, 4})}, + {{"Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({1, 2, 3})}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } { auto const col = cudf::slice(col_original, {2, 4})[0]; auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = StrListsCol{{StrListsCol{{"Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({2, 3, 4})}, - StrListsCol{} /*NULL*/}, - null_at(1)}; + auto const expected = StrListsCol({{{"Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({2, 3, 4})}, + {} /*NULL*/}, + null_at(1)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } } @@ -807,11 +789,12 @@ TEST_F(ConcatenateListElementsTest, EmptyInnerListColumnChildSizeOne) { // list> with 1 outer row containing 1 empty inner list: [[]] // child.size() == 1; the new guard does not apply here. - // Use build_lists_col to create a proper list> (2-level nesting). - auto inner = IntListsCol{IntListsCol{}}; // list with 1 empty row - auto const col = build_lists_col(inner); // list> with 1 outer row: [[]] + // Use build_lists_init to create a proper list> (2-level nesting). + auto inner = IntListsCol::nested({{}}); // list with 1 empty row + auto const col = + IntListsCol(build_lists_init(inner)); // list> with 1 outer row: [[]] auto const results = cudf::lists::concatenate_list_elements(col); - auto const expected = IntListsCol{IntListsCol{}}; // list with 1 empty row: [[]] → [] + auto const expected = IntListsCol{{}}; // list with 1 empty row: [[]] → [] CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } @@ -828,7 +811,7 @@ TEST_F(ConcatenateListElementsTest, EmptyInnerListColumnChildSizeZero) auto const col = cudf::make_lists_column(1, offsets.release(), std::move(inner_col), 0, {}); auto const results = cudf::lists::concatenate_list_elements(*col); - auto const expected = IntListsCol{IntListsCol{}}; + auto const expected = IntListsCol{{}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); } diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index f26a27f16d47..042e5a13bb5b 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -79,12 +79,10 @@ TYPED_TEST(ListConcatenateRowsTypedTest, ConcatenateOneColumnWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col = ListsCol{{ListsCol{{1, 2, null}, null_at(2)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 3, 4, 4, 4, 4}, null_at(0)}, - ListsCol{5, 6}}, - null_at(1)} - .release(); + auto const col = + ListsCol{{{{1, 2, null}, null_at(2)}, {} /*NULL*/, {{null, 3, 4, 4, 4, 4}, null_at(0)}, {5, 6}}, + null_at(1)} + .release(); auto const results = cudf::lists::concatenate_rows(TView{{col->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } @@ -94,7 +92,7 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputNoNull) using ListsCol = cudf::test::lists_column_wrapper; auto const col1 = ListsCol{{1, 2}, {3, 4}, {5, 6}}.release(); - auto const empty_lists = ListsCol{ListsCol{}, ListsCol{}, ListsCol{}}.release(); + auto const empty_lists = ListsCol{{}, {}, {}}.release(); auto const col2 = ListsCol{{7, 8}, {9, 10}, {11, 12}}.release(); auto const expected = ListsCol{{1, 2, 7, 8}, {3, 4, 9, 10}, {5, 6, 11, 12}}.release(); auto const results = @@ -106,11 +104,11 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNullableChild) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1 = ListsCol{{1, 2}, ListsCol{{null}, null_at(0)}, {5, 6}}.release(); - auto const empty_lists = ListsCol{{ListsCol{}, ListsCol{}, ListsCol{}}, null_at(2)}.release(); + auto const col1 = ListsCol{{1, 2}, {{null}, null_at(0)}, {5, 6}}.release(); + auto const empty_lists = ListsCol({{}, {}, {}}, null_at(2)).release(); auto const col2 = ListsCol{{7, 8}, {9, 10}, {11, 12}}.release(); auto const expected = - ListsCol{{1, 2, 7, 8}, ListsCol{{null, 9, 10}, null_at(0)}, {5, 6, 11, 12}}.release(); + ListsCol{{1, 2, 7, 8}, {{null, 9, 10}, null_at(0)}, {5, 6, 11, 12}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), empty_lists->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -118,35 +116,26 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNullableChild) TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsNoNull) { - auto const col1 = StrListsCol{StrListsCol{"Tomato", "Apple"}, - StrListsCol{"Banana", "Kiwi", "Cherry"}, - StrListsCol{"Coconut"}} - .release(); - auto const col2 = - StrListsCol{StrListsCol{"Orange"}, StrListsCol{"Lemon", "Peach"}, StrListsCol{}}.release(); - auto const expected = StrListsCol{StrListsCol{"Tomato", "Apple", "Orange"}, - StrListsCol{"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, - StrListsCol{"Coconut"}} - .release(); + auto const col1 = + StrListsCol{{"Tomato", "Apple"}, {"Banana", "Kiwi", "Cherry"}, {"Coconut"}}.release(); + auto const col2 = StrListsCol{{"Orange"}, {"Lemon", "Peach"}, {}}.release(); + auto const expected = + StrListsCol{ + {"Tomato", "Apple", "Orange"}, {"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, {"Coconut"}} + .release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNullableChild) { - auto const col1 = StrListsCol{StrListsCol{"Tomato", "Apple"}, - StrListsCol{"Banana", "Kiwi", "Cherry"}, - StrListsCol{"Coconut"}} - .release(); - auto const col2 = StrListsCol{ - StrListsCol{"Orange"}, - StrListsCol{{"Lemon", "Peach"}, null_at(1)}, - StrListsCol{}}.release(); - auto const expected = - StrListsCol{StrListsCol{"Tomato", "Apple", "Orange"}, - StrListsCol{{"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, null_at(4)}, - StrListsCol{"Coconut"}} - .release(); + auto const col1 = + StrListsCol{{"Tomato", "Apple"}, {"Banana", "Kiwi", "Cherry"}, {"Coconut"}}.release(); + auto const col2 = StrListsCol{{"Orange"}, {{"Lemon", "Peach"}, null_at(1)}, {}}.release(); + auto const expected = StrListsCol{{"Tomato", "Apple", "Orange"}, + {{"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, null_at(4)}, + {"Coconut"}} + .release(); auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -155,31 +144,31 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1 = ListsCol{{ListsCol{{1, null, 3, 4}, null_at(1)}, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{} /*NULL*/, - ListsCol{{1, 2, null, 4}, null_at(2)}, - ListsCol{{1, 2, 3, null}, null_at(3)}, - ListsCol{} /*NULL*/}, + auto const col1 = ListsCol{{{{1, null, 3, 4}, null_at(1)}, + {{null, 2, 3, 4}, null_at(0)}, + {{null, 2, 3, 4}, null_at(0)}, + {} /*NULL*/, + {{1, 2, null, 4}, null_at(2)}, + {{1, 2, 3, null}, null_at(3)}, + {} /*NULL*/}, nulls_at({3, 6})} .release(); - auto const col2 = ListsCol{{ListsCol{{10, 11, 12, null}, null_at(3)}, - ListsCol{{13, 14, 15, 16, 17, null}, null_at(5)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 18}, null_at(0)}, - ListsCol{{19, 20, null}, null_at(2)}, - ListsCol{{null}, null_at(0)}, - ListsCol{} /*NULL*/}, + auto const col2 = ListsCol{{{{10, 11, 12, null}, null_at(3)}, + {{13, 14, 15, 16, 17, null}, null_at(5)}, + {} /*NULL*/, + {{null, 18}, null_at(0)}, + {{19, 20, null}, null_at(2)}, + {{null}, null_at(0)}, + {} /*NULL*/}, nulls_at({2, 6})} .release(); - auto const col3 = ListsCol{{ListsCol{} /*NULL*/, - ListsCol{{20, null}, null_at(1)}, - ListsCol{{null, 21, null, null}, nulls_at({0, 2, 3})}, - ListsCol{}, - ListsCol{22, 23, 24, 25}, - ListsCol{{null, null, null, null, null}, all_nulls()}, - ListsCol{} /*NULL*/}, + auto const col3 = ListsCol{{{} /*NULL*/, + {{20, null}, null_at(1)}, + {{null, 21, null, null}, nulls_at({0, 2, 3})}, + {}, + {22, 23, 24, 25}, + {{null, null, null, null, null}, all_nulls()}, + {} /*NULL*/}, nulls_at({0, 6})} .release(); @@ -188,15 +177,15 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view(), col3->view()}}); auto const expected = - ListsCol{{ListsCol{{1, null, 3, 4, 10, 11, 12, null}, nulls_at({1, 7})}, - ListsCol{{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, - ListsCol{{null, 2, 3, 4, null, 21, null, null}, nulls_at({0, 4, 6, 7})}, - ListsCol{{null, 18}, null_at(0)}, - ListsCol{{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, - ListsCol{{1, 2, 3, null, null, null, null, null, null, null}, - nulls_at({3, 4, 5, 6, 7, 8, 9})}, - ListsCol{} /*NULL*/}, - null_at(6)} + ListsCol{ + {{{1, null, 3, 4, 10, 11, 12, null}, nulls_at({1, 7})}, + {{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, + {{null, 2, 3, 4, null, 21, null, null}, nulls_at({0, 4, 6, 7})}, + {{null, 18}, null_at(0)}, + {{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, + {{1, 2, 3, null, null, null, null, null, null, null}, nulls_at({3, 4, 5, 6, 7, 8, 9})}, + {} /*NULL*/}, + null_at(6)} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -207,15 +196,15 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) cudf::lists::concatenate_rows(TView{{col1->view(), col2->view(), col3->view()}}, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); auto const expected = - ListsCol{{ListsCol{} /*NULL*/, - ListsCol{{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, - ListsCol{} /*NULL*/, - ListsCol{} /*NULL*/, - ListsCol{{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, - ListsCol{{1, 2, 3, null, null, null, null, null, null, null}, - nulls_at({3, 4, 5, 6, 7, 8, 9})}, - ListsCol{} /*NULL*/}, - nulls_at({0, 2, 3, 6})} + ListsCol{ + {{} /*NULL*/, + {{null, 2, 3, 4, 13, 14, 15, 16, 17, null, 20, null}, nulls_at({0, 9, 11})}, + {} /*NULL*/, + {} /*NULL*/, + {{1, 2, null, 4, 19, 20, null, 22, 23, 24, 25}, nulls_at({2, 6})}, + {{1, 2, 3, null, null, null, null, null, null, null}, nulls_at({3, 4, 5, 6, 7, 8, 9})}, + {} /*NULL*/}, + nulls_at({0, 2, 3, 6})} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -224,18 +213,15 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SimpleInputWithNulls) TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) { auto const col1 = - StrListsCol{ - StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}} + StrListsCol{{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}} .release(); auto const col2 = - StrListsCol{ - {StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, - nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ - null_at(2)} + StrListsCol{{{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ + null_at(2)} .release(); // Ignore null list elements @@ -243,12 +229,11 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view()}}); auto const expected = StrListsCol{ - StrListsCol{ - {"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, - nulls_at({1, 4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, - nulls_at({1, 4})}, - StrListsCol{"Coconut"}} + {{"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, + nulls_at({1, 4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, + nulls_at({1, 4})}, + {"Coconut"}} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -260,12 +245,11 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); auto const expected = StrListsCol{ - {StrListsCol{ - {"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, - nulls_at({1, 4, 5, 6})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, - nulls_at({1, 4})}, - StrListsCol{""} /*NULL*/}, + {{{"Tomato", "" /*NULL*/, "Apple", "Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, + nulls_at({1, 4, 5, 6})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/, "Lemon", "Peach"}, + nulls_at({1, 4})}, + {""} /*NULL*/}, null_at(2)} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -274,23 +258,18 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithNulls) TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithEmptyLists) { - auto const col1 = - StrListsCol{StrListsCol{{"" /*NULL*/}, null_at(0)}, StrListsCol{"One"}}.release(); - auto const col2 = - StrListsCol{StrListsCol{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, StrListsCol{"Two"}} - .release(); - auto const col3 = - StrListsCol{{StrListsCol{"Lemon", "Peach"}, StrListsCol{"Three"} /*NULL*/}, null_at(1)} - .release(); + auto const col1 = StrListsCol{{{"" /*NULL*/}, null_at(0)}, {"One"}}.release(); + auto const col2 = StrListsCol{{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, {"Two"}}.release(); + auto const col3 = StrListsCol({{"Lemon", "Peach"}, {"Three"} /*NULL*/}, null_at(1)).release(); // Ignore null list elements { auto const results = cudf::lists::concatenate_rows(TView{{col1->view(), col2->view(), col3->view()}}); auto const expected = - StrListsCol{StrListsCol{{"" /*NULL*/, "Tomato", "" /*NULL*/, "Apple", "Lemon", "Peach"}, - nulls_at({0, 2})}, - StrListsCol{"One", "Two"}} + StrListsCol{ + {{"" /*NULL*/, "Tomato", "" /*NULL*/, "Apple", "Lemon", "Peach"}, nulls_at({0, 2})}, + {"One", "Two"}} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -301,10 +280,10 @@ TEST_F(ListConcatenateRowsTest, SimpleInputStringsColumnsWithEmptyLists) cudf::lists::concatenate_rows(TView{{col1->view(), col2->view(), col3->view()}}, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); auto const expected = - StrListsCol{{StrListsCol{{"" /*NULL*/, "Tomato", "" /*NULL*/, "Apple", "Lemon", "Peach"}, - nulls_at({0, 2})}, - StrListsCol{""} /*NULL*/}, - null_at(1)} + StrListsCol( + {{{"" /*NULL*/, "Tomato", "" /*NULL*/, "Apple", "Lemon", "Peach"}, nulls_at({0, 2})}, + {""} /*NULL*/}, + null_at(1)) .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -330,13 +309,13 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col_original = ListsCol{{ListsCol{{null, 2, 3}, null_at(0)}, - ListsCol{2, 3}, /*NULL*/ - ListsCol{{3, null, 5, 6}, null_at(1)}, - ListsCol{5, 6}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{7}, - ListsCol{8, 9, 10}}, + auto const col_original = ListsCol{{{{null, 2, 3}, null_at(0)}, + {2, 3}, /*NULL*/ + {{3, null, 5, 6}, null_at(1)}, + {5, 6}, /*NULL*/ + {}, /*NULL*/ + {7}, + {8, 9, 10}}, nulls_at({1, 3, 4})} .release(); auto const col1 = cudf::slice(col_original->view(), {0, 3})[0]; @@ -345,10 +324,10 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputWithNulls) auto const col4 = cudf::slice(col_original->view(), {3, 6})[0]; auto const col5 = cudf::slice(col_original->view(), {4, 7})[0]; auto const expected = ListsCol{ - ListsCol{{null, 2, 3, 3, null, 5, 6}, nulls_at({0, 4})}, - ListsCol{{3, null, 5, 6, 7}, null_at(1)}, - ListsCol{{3, null, 5, 6, 7, 8, 9, 10}, - null_at(1)}}.release(); + {{null, 2, 3, 3, null, 5, 6}, nulls_at({0, 4})}, + {{3, null, 5, 6, 7}, null_at(1)}, + {{3, null, 5, 6, 7, 8, 9, 10}, + null_at(1)}}.release(); auto const results = cudf::lists::concatenate_rows(TView{{col1, col2, col3, col4, col5}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -356,16 +335,13 @@ TYPED_TEST(ListConcatenateRowsTypedTest, SlicedColumnsInputWithNulls) TEST_F(ListConcatenateRowsTest, SlicedStringsColumnsInputWithNulls) { auto const col = - StrListsCol{ - {StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, - nulls_at({1, 4})}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, - nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ - null_at(5)} + StrListsCol{{{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}, + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ + null_at(5)} .release(); auto const col1 = cudf::slice(col->view(), {0, 3})[0]; auto const col2 = cudf::slice(col->view(), {1, 4})[0]; @@ -374,78 +350,78 @@ TEST_F(ListConcatenateRowsTest, SlicedStringsColumnsInputWithNulls) { auto const results = cudf::lists::concatenate_rows(TView{{col1, col2, col3, col4}}); - auto const expected = StrListsCol{StrListsCol{{"Tomato", - "" /*NULL*/, - "Apple", - "Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "" /*NULL*/}, - nulls_at({1, 4, 7, 10, 11, 12})}, - StrListsCol{{"Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({1, 4, 7, 8, 9})}, - StrListsCol{{ - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach", - }, - nulls_at({2, 3, 4})}} - .release(); + auto const expected = StrListsCol{ + {{"Tomato", + "" /*NULL*/, + "Apple", + "Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "" /*NULL*/}, + nulls_at({1, 4, 7, 10, 11, 12})}, + {{"Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({1, 4, 7, 8, 9})}, + {{ + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach", + }, + nulls_at({2, 3, 4})}}.release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } { auto const results = cudf::lists::concatenate_rows( TView{{col1, col2, col3, col4}}, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = StrListsCol{{StrListsCol{{"Tomato", - "" /*NULL*/, - "Apple", - "Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "" /*NULL*/}, - nulls_at({1, 4, 7, 10, 11, 12})}, - StrListsCol{{"Banana", - "" /*NULL*/, - "Kiwi", - "Cherry", - "" /*NULL*/, - "Coconut", - "Orange", - "" /*NULL*/, - "" /*NULL*/, - "", /*NULL*/ - "Lemon", - "Peach"}, - nulls_at({1, 4, 7, 8, 9})}, - StrListsCol{} /*NULL*/}, + auto const expected = StrListsCol{{{{"Tomato", + "" /*NULL*/, + "Apple", + "Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "" /*NULL*/}, + nulls_at({1, 4, 7, 10, 11, 12})}, + {{"Banana", + "" /*NULL*/, + "Kiwi", + "Cherry", + "" /*NULL*/, + "Coconut", + "Orange", + "" /*NULL*/, + "" /*NULL*/, + "", /*NULL*/ + "Lemon", + "Peach"}, + nulls_at({1, 4, 7, 8, 9})}, + {} /*NULL*/}, null_at(2)} .release(); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -456,9 +432,9 @@ TEST_F(ListConcatenateRowsTest, StringsColumnsWithEmptyListTest) { auto const col1 = StrListsCol{{"1", "2", "3", "4"}}.release(); auto const col2 = StrListsCol{{"a", "b", "c"}}.release(); - auto const col3 = StrListsCol{StrListsCol{}}.release(); + auto const col3 = StrListsCol{{}}.release(); auto const col4 = StrListsCol{{"x", "y", "" /*NULL*/, "z"}, null_at(2)}.release(); - auto const col5 = StrListsCol{{StrListsCol{}}, null_at(0)}.release(); + auto const col5 = StrListsCol{{{}}, null_at(0)}.release(); auto const expected = StrListsCol{{"1", "2", "3", "4", "a", "b", "c", "x", "y", "" /*NULL*/, "z"}, null_at(9)} .release(); @@ -536,34 +512,32 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) // clang-format off // col 0 - cudf::test::lists_column_wrapper - l0{ { - {{{"whee", "yay", "bananas"}, nulls_at({1})}, {}}, - {{}}, - {{{"abc"}, {"def", "g", "xyw", "ijk"}, {"x", "y", "", "column"}}, nulls_at({0, 2})}, - {{"f", "tesla"}}, - {{"phone"}, {"hack", "table", "car"}} - }, nulls_at({3, 4}) }; + StrListsCol l0({{{{"whee", "yay", "bananas"}, nulls_at({1})}, {}}, + StrListsCol::nested({{}}), + {{{"abc"}, {"def", "g", "xyw", "ijk"}, {"x", "y", "", "column"}}, + nulls_at({0, 2})}, + {{"f", "tesla"}}, + {{"phone"}, {"hack", "table", "car"}}}, + nulls_at({3, 4})); // col1 - cudf::test::lists_column_wrapper - l1{ { - {{}}, - {{"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}}, - {{{{"", "hhh"}, nulls_at({0})}, {"www"}}, nulls_at({1})}, - {{"warp", "donuts", "parking"}, { "", "apply", "twelve", "mouse", "bbb"}, {"bbb", "pom"}, {}}, - {{}} - }, nulls_at({4}) }; + StrListsCol l1({StrListsCol::nested({{}}), + {{"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}}, + {{{{"", "hhh"}, nulls_at({0})}, {"www"}}, nulls_at({1})}, + {{"warp", "donuts", "parking"}, + {"", "apply", "twelve", "mouse", "bbb"}, + {"bbb", "pom"}, + {}}, + StrListsCol::nested({{}})}, + nulls_at({4})); // col2 - cudf::test::lists_column_wrapper - l2{ { - {{"monitor", "sugar"}}, - {{"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, - {{"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}, - {{}, {"ram", "cpu", "disk"}, {}}, - {{"round"}, {"square"}} - }, nulls_at({0, 4}) }; + StrListsCol l2({StrListsCol::nested({{"monitor", "sugar"}}), + StrListsCol::nested({{"spurs", "garlic"}, {"onion", "shallot", "carrot"}}), + StrListsCol::nested({{"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}), + StrListsCol::nested({{}, {"ram", "cpu", "disk"}, {}}), + StrListsCol::nested({{"round"}, {"square"}})}, + nulls_at({0, 4})); // concatenate_policy::IGNORE_NULLS { @@ -572,16 +546,26 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) auto result = cudf::lists::concatenate_rows(t, cudf::lists::concatenate_null_policy::IGNORE); // expected - cudf::test::lists_column_wrapper - expected{ { - {{{"whee", "yay", "bananas"}, nulls_at({1})}, {}, {}}, - {{}, {"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}, {"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, - {{{"abc"}, {"def", "g", "xyw", "ijk"}, {"x", "y", "", "column"}, - {{"", "hhh"}, nulls_at({0})}, {"www"}, {"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}, - nulls_at({0, 2, 4}) }, - {{"warp", "donuts", "parking"}, { "", "apply", "twelve", "mouse", "bbb"}, {"bbb", "pom"}, {}, {}, {"ram", "cpu", "disk"}, {}}, - {{}} - }, nulls_at({4}) }; + StrListsCol expected({{{{"whee", "yay", "bananas"}, nulls_at({1})}, {}, {}}, + {{}, {"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}, {"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, + {{{"abc"}, + {"def", "g", "xyw", "ijk"}, + {"x", "y", "", "column"}, + {{"", "hhh"}, nulls_at({0})}, + {"www"}, + {"cars", "trucks", "planes"}, + {"abc"}, + {"mno", "pqr"}}, + nulls_at({0, 2, 4})}, + {{"warp", "donuts", "parking"}, + {"", "apply", "twelve", "mouse", "bbb"}, + {"bbb", "pom"}, + {}, + {}, + {"ram", "cpu", "disk"}, + {}}, + StrListsCol::nested({{}})}, + nulls_at({4})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, expected); } @@ -593,16 +577,20 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) auto result = cudf::lists::concatenate_rows(t, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); // expected - cudf::test::lists_column_wrapper - expected{ { - {{}}, - {{}, {"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}, {"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, - {{{"abc"}, {"def", "g", "xyw", "ijk"}, {"x", "y", "", "column"}, - {{"", "hhh"}, nulls_at({0})}, {"www"}, {"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}, - nulls_at({0, 2, 4}) }, - {{}}, - {{}} - }, nulls_at({0, 3, 4}) }; + StrListsCol expected({StrListsCol::nested({{}}), + {{}, {"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}, {"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, + {{{"abc"}, + {"def", "g", "xyw", "ijk"}, + {"x", "y", "", "column"}, + {{"", "hhh"}, nulls_at({0})}, + {"www"}, + {"cars", "trucks", "planes"}, + {"abc"}, + {"mno", "pqr"}}, + nulls_at({0, 2, 4})}, + StrListsCol::nested({{}}), + StrListsCol::nested({{}})}, + nulls_at({0, 3, 4})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, expected); } diff --git a/cpp/tests/lists/contains_tests.cpp b/cpp/tests/lists/contains_tests.cpp index b6d96026b9f6..6c562699bef4 100644 --- a/cpp/tests/lists/contains_tests.cpp +++ b/cpp/tests/lists/contains_tests.cpp @@ -1553,29 +1553,29 @@ TYPED_TEST(TypedListContainsTest, ScalarKeyLists) using tdata_col = cudf::test::fixed_width_column_wrapper; using lists_col = cudf::test::lists_column_wrapper; - auto const lists_no_nulls = lists_col{lists_col{{0, 1, 2}, // list0 - {3, 4, 5}, - {0, 1, 2}, - {9, 0, 1, 3, 1}}, - lists_col{{2, 3, 4}, // list1 - {3, 4, 5}, - {8, 9, 0}, - {}}, - lists_col{{0, 2, 1}, // list2 - {}}}; - - auto const lists_have_nulls = lists_col{lists_col{{{0, 1, 2}, // list0 - {} /*NULL*/, - {0, 1, 2}, - {9, 0, 1, 3, 1}}, - null_at(1)}, - lists_col{{{} /*NULL*/, // list1 - {3, 4, 5}, - {8, 9, 0}, - {}}, - null_at(0)}, - lists_col{{0, 2, 1}, // list2 - {}}}; + auto const lists_no_nulls = lists_col{{{0, 1, 2}, // list0 + {3, 4, 5}, + {0, 1, 2}, + {9, 0, 1, 3, 1}}, + {{2, 3, 4}, // list1 + {3, 4, 5}, + {8, 9, 0}, + {}}, + {{0, 2, 1}, // list2 + {}}}; + + auto const lists_have_nulls = lists_col{{{{0, 1, 2}, // list0 + {} /*NULL*/, + {0, 1, 2}, + {9, 0, 1, 3, 1}}, + null_at(1)}, + {{{} /*NULL*/, // list1 + {3, 4, 5}, + {8, 9, 0}, + {}}, + null_at(0)}, + {{0, 2, 1}, // list2 + {}}}; auto const key = [] { auto const child = tdata_col{0, 1, 2}; @@ -1618,53 +1618,53 @@ TYPED_TEST(TypedListContainsTest, SlicedListsColumn) using tdata_col = cudf::test::fixed_width_column_wrapper; using lists_col = cudf::test::lists_column_wrapper; - auto const lists_no_nulls_original = lists_col{lists_col{{0, 0, 0}, // list-2 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}, - lists_col{{0, 0, 0}, // list-1 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}, - lists_col{{0, 1, 2}, // list0 - {3, 4, 5}, - {0, 1, 2}, - {9, 0, 1, 3, 1}}, - lists_col{{2, 3, 4}, // list1 - {3, 4, 5}, - {8, 9, 0}, - {}}, - lists_col{{0, 2, 1}, // list2 - {}}, - lists_col{{0, 0, 0}, // list3 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}, - lists_col{{0, 0, 0}, // list4 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}}; - - auto const lists_have_nulls_original = lists_col{lists_col{{0, 0, 0}, // list-1 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}, - lists_col{{{0, 1, 2}, // list0 - {} /*NULL*/, - {0, 1, 2}, - {9, 0, 1, 3, 1}}, - null_at(1)}, - lists_col{{{} /*NULL*/, // list1 - {3, 4, 5}, - {8, 9, 0}, - {}}, - null_at(0)}, - lists_col{{0, 2, 1}, // list2 - {}}, - lists_col{{0, 0, 0}, // list3 (don't care) - {0, 1, 2}, - {0, 1, 2}, - {0, 0, 0}}}; + auto const lists_no_nulls_original = lists_col{{{0, 0, 0}, // list-2 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}, + {{0, 0, 0}, // list-1 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}, + {{0, 1, 2}, // list0 + {3, 4, 5}, + {0, 1, 2}, + {9, 0, 1, 3, 1}}, + {{2, 3, 4}, // list1 + {3, 4, 5}, + {8, 9, 0}, + {}}, + {{0, 2, 1}, // list2 + {}}, + {{0, 0, 0}, // list3 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}, + {{0, 0, 0}, // list4 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}}; + + auto const lists_have_nulls_original = lists_col{{{0, 0, 0}, // list-1 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}, + {{{0, 1, 2}, // list0 + {} /*NULL*/, + {0, 1, 2}, + {9, 0, 1, 3, 1}}, + null_at(1)}, + {{{} /*NULL*/, // list1 + {3, 4, 5}, + {8, 9, 0}, + {}}, + null_at(0)}, + {{0, 2, 1}, // list2 + {}}, + {{0, 0, 0}, // list3 (don't care) + {0, 1, 2}, + {0, 1, 2}, + {0, 0, 0}}}; auto const lists_no_nulls = cudf::slice(lists_no_nulls_original, {2, 5})[0]; auto const lists_have_nulls = cudf::slice(lists_have_nulls_original, {1, 4})[0]; @@ -1710,36 +1710,35 @@ TYPED_TEST(TypedListContainsTest, ColumnKeyLists) using lists_col = cudf::test::lists_column_wrapper; auto constexpr null = int32_t{0}; - auto const lists_no_nulls = lists_col{lists_col{{0, 0, 2}, // list0 - {3, 4, 5}, - {0, 0, 2}, - {9, 0, 1, 3, 1}}, - lists_col{{2, 3, 4}, // list1 - {3, 4, 5}, - {2, 3, 4}, - {}}, - lists_col{{0, 2, 0}, // list2 - {0, 2, 0}, - {3, 4, 5}, - {}}}; - - auto const lists_have_nulls = lists_col{lists_col{{lists_col{{0, null, 2}, null_at(1)}, // list0 - lists_col{} /*NULL*/, - lists_col{{0, null, 2}, null_at(1)}, - lists_col{9, 0, 1, 3, 1}}, - null_at(1)}, - lists_col{{lists_col{} /*NULL*/, // list1 - lists_col{3, 4, 5}, - lists_col{2, 3, 4}, - lists_col{}}, - null_at(0)}, - lists_col{lists_col{0, 2, 1}, // list2 - lists_col{{0, 2, null}, null_at(2)}, - lists_col{3, 4, 5}, - lists_col{}}}; - - auto const key = lists_col{ - lists_col{{0, null, 2}, null_at(1)}, lists_col{2, 3, 4}, lists_col{{0, 2, null}, null_at(2)}}; + auto const lists_no_nulls = lists_col{{{0, 0, 2}, // list0 + {3, 4, 5}, + {0, 0, 2}, + {9, 0, 1, 3, 1}}, + {{2, 3, 4}, // list1 + {3, 4, 5}, + {2, 3, 4}, + {}}, + {{0, 2, 0}, // list2 + {0, 2, 0}, + {3, 4, 5}, + {}}}; + + auto const lists_have_nulls = lists_col{{{{{0, null, 2}, null_at(1)}, // list0 + {} /*NULL*/, + {{0, null, 2}, null_at(1)}, + {9, 0, 1, 3, 1}}, + null_at(1)}, + {{{} /*NULL*/, // list1 + {3, 4, 5}, + {2, 3, 4}, + {}}, + null_at(0)}, + {{0, 2, 1}, // list2 + {{0, 2, null}, null_at(2)}, + {3, 4, 5}, + {}}}; + + auto const key = lists_col{{{0, null, 2}, null_at(1)}, {2, 3, 4}, {{0, 2, null}, null_at(2)}}; auto const do_test = [&](auto const& lists, bool has_nulls) { { diff --git a/cpp/tests/lists/count_elements_tests.cpp b/cpp/tests/lists/count_elements_tests.cpp index 40ab2a8cf93c..6c1ec1dcbea8 100644 --- a/cpp/tests/lists/count_elements_tests.cpp +++ b/cpp/tests/lists/count_elements_tests.cpp @@ -28,7 +28,7 @@ TYPED_TEST(ListsElementsNumericsTest, CountElements) auto validity = cudf::detail::make_counting_transform_iterator(cudf::size_type{0}, [](auto i) { return i != 1; }); using LCW = cudf::test::lists_column_wrapper; - LCW input({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}}, validity); + LCW input({{3, 2, 1}, {}, {30, 20, 10, 50}, {100, 120}, {0}}, validity); auto result = cudf::lists::count_elements(cudf::lists_column_view(input)); cudf::test::fixed_width_column_wrapper expected({3, 0, 4, 2, 1}, @@ -41,9 +41,8 @@ TEST_F(ListsElementsTest, CountElementsStrings) auto validity = cudf::detail::make_counting_transform_iterator(cudf::size_type{0}, [](auto i) { return i != 1; }); using LCW = cudf::test::lists_column_wrapper; - LCW input( - {LCW{"", "Héllo", "thesé"}, LCW{}, LCW{"are", "some", "", "z"}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW input({{"", "Héllo", "thesé"}, {}, {"are", "some", "", "z"}, {"tést", "String"}, {""}}, + validity); auto result = cudf::lists::count_elements(cudf::lists_column_view(input)); cudf::test::fixed_width_column_wrapper expected({3, 0, 4, 2, 1}, @@ -56,9 +55,8 @@ TEST_F(ListsElementsTest, CountElementsSliced) auto validity = cudf::detail::make_counting_transform_iterator(cudf::size_type{0}, [](auto i) { return i != 1; }); using LCW = cudf::test::lists_column_wrapper; - LCW input( - {LCW{"", "Héllo", "thesé"}, LCW{}, LCW{"are", "some", "", "z"}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW input({{"", "Héllo", "thesé"}, {}, {"are", "some", "", "z"}, {"tést", "String"}, {""}}, + validity); auto sliced = cudf::slice(input, {1, 4}).front(); auto result = cudf::lists::count_elements(cudf::lists_column_view(sliced)); @@ -70,10 +68,10 @@ TYPED_TEST(ListsElementsNumericsTest, CountElementsNestedLists) { std::vector validity{1, 0, 1, 1}; using LCW = cudf::test::lists_column_wrapper; - LCW list({LCW{LCW{2, 3}, LCW{4, 5}}, - LCW{LCW{}}, - LCW{LCW{6, 7, 8}, LCW{9, 10, 11}, LCW({12, 13, 14}, validity.begin())}, - LCW{LCW{15, 16}, LCW{17, 18}, LCW{19, 20}, LCW{21, 22}, LCW{23, 24}}}, + LCW list({{{2, 3}, {4, 5}}, + LCW::nested({{}}), + {{6, 7, 8}, {9, 10, 11}, {{12, 13, 14}, validity.begin()}}, + {{15, 16}, {17, 18}, {19, 20}, {21, 22}, {23, 24}}}, validity.begin()); auto result = cudf::lists::count_elements(cudf::lists_column_view(list)); diff --git a/cpp/tests/lists/explode_tests.cpp b/cpp/tests/lists/explode_tests.cpp index f10c45083615..a827b0a8559f 100644 --- a/cpp/tests/lists/explode_tests.cpp +++ b/cpp/tests/lists/explode_tests.cpp @@ -63,7 +63,7 @@ TEST_F(ExplodeTest, Basics) // 300 [0, 3] string2 FCW a{100, 200, 300}; - LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}}; + LCW b{{1, 2, 7}, {5, 6}, {0, 3}}; cudf::test::strings_column_wrapper c{"string0", "string1", "string2"}; FCW expected_a{100, 100, 100, 200, 200, 300, 300}; @@ -97,7 +97,7 @@ TEST_F(ExplodeTest, SingleNull) auto first_invalid = cudf::test::iterators::null_at(0); - LCW a({LCW{null}, LCW{5, 6}, LCW{}, LCW{0, 3}}, first_invalid); + LCW a({{null}, {5, 6}, {}, {0, 3}}, first_invalid); FCW b({100, 200, 300, 400}); FCW expected_a{5, 6, 0, 3}; @@ -129,7 +129,7 @@ TEST_F(ExplodeTest, Nulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); auto always_valid = cudf::test::iterators::no_nulls(); - LCW a({LCW{1, 2, 7}, LCW{null}, LCW{0, 3}}, valids); + LCW a({{1, 2, 7}, {null}, {0, 3}}, valids); FCW b({100, 200, 300}, valids); FCW expected_a({1, 2, 7, 0, 3}); @@ -161,8 +161,7 @@ TEST_F(ExplodeTest, NullsInList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{ - LCW({1, null, 7}, valids), LCW({5, null, 0, null}, valids), LCW{}, LCW({0, null, 8}, valids)}; + LCW a{{{1, null, 7}, valids}, {{5, null, 0, null}, valids}, {}, {{0, null, 8}, valids}}; FCW b{100, 200, 300, 400}; FCW expected_a({1, null, 7, 5, null, 0, null, 0, null, 8}, @@ -190,10 +189,10 @@ TEST_F(ExplodeTest, Nested) // [[5, 6]] 200 // [[0, 3],[],[5],[2, 1]] 300 - LCW a{LCW{LCW{1, 2}, LCW{7, 6, 5}}, LCW{LCW{5, 6}}, LCW{LCW{0, 3}, LCW{}, LCW{5}, LCW{2, 1}}}; + LCW a{{{1, 2}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {}, {5}, {2, 1}}}; FCW b{100, 200, 300}; - LCW expected_a{LCW{1, 2}, LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{}, LCW{5}, LCW{2, 1}}; + LCW expected_a{{1, 2}, {7, 6, 5}, {5, 6}, {0, 3}, {}, {5}, {2, 1}}; FCW expected_b{100, 100, 200, 300, 300, 300, 300}; cudf::table_view t({a, b}); @@ -222,10 +221,10 @@ TEST_F(ExplodeTest, NestedNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); auto always_valid = cudf::test::iterators::no_nulls(); - LCW a({LCW{LCW{1, 2}, LCW{7, 6, 5}}, LCW{LCW{null}}, LCW{LCW{0, 3}, LCW{5}, LCW{2, 1}}}, valids); + LCW a({{{1, 2}, {7, 6, 5}}, LCW::nested({{null}}), {{0, 3}, {5}, {2, 1}}}, valids); FCW b({100, null, 300}, valids); - LCW expected_a{LCW{1, 2}, LCW{7, 6, 5}, LCW{0, 3}, LCW{5}, LCW{2, 1}}; + LCW expected_a{{1, 2}, {7, 6, 5}, {0, 3}, {5}, {2, 1}}; FCW expected_b({100, 100, 300, 300, 300}, always_valid); cudf::table_view t({a, b}); @@ -253,13 +252,11 @@ TEST_F(ExplodeTest, NullsInNested) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, null}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); + LCW a( + {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); FCW b({100, 200, 300}); - LCW expected_a{ - LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; + LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; FCW expected_b{100, 100, 200, 300, 300, 300}; cudf::table_view t({a, b}); @@ -287,9 +284,9 @@ TEST_F(ExplodeTest, NullsInNestedDoubleExplode) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{LCW{LCW({1, null}, valids), LCW{}, LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}; + LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, + LCW::nested({{5, 6}}), + {{0, 3}, {5}, {{2, null}, valids}}}; FCW b{100, 200, 300}; FCW expected_a({1, null, 7, 6, 5, 5, 6, 0, 3, 5, 2, null}, @@ -322,15 +319,13 @@ TEST_F(ExplodeTest, NestedStructs) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, null}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); + LCW a( + {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); FCW b1({100, 200, 300}); cudf::test::strings_column_wrapper b2{"100", "200", "300"}; cudf::test::structs_column_wrapper b({b1, b2}); - LCW expected_a{ - LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; + LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; FCW expected_b1{100, 100, 200, 300, 300, 300}; cudf::test::strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; cudf::test::structs_column_wrapper expected_b({expected_b1, expected_b2}); @@ -489,15 +484,14 @@ TEST_F(ExplodeTest, SlicedList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, 2}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, 1}, valids)}, - LCW{LCW{8, 3}, LCW{}, LCW({4, 3, 1, 2}, valids)}, - LCW{LCW{2, 3, 4}, LCW{9, 8}}}); + LCW a({{{{1, 2}, valids}, {7, 6, 5}}, + LCW::nested({{5, 6}}), + {{0, 3}, {5}, {{2, 1}, valids}}, + {{8, 3}, {}, {{4, 3, 1, 2}, valids}}, + {{2, 3, 4}, {9, 8}}}); FCW b({100, 200, 300, 400, 500}); - LCW expected_a{ - LCW{0, 3}, LCW{5}, LCW({2, null}, valids), LCW{8, 3}, LCW{}, LCW({4, null, 1, null}, valids)}; + LCW expected_a{{0, 3}, {5}, {{2, null}, valids}, {8, 3}, {}, {{4, null, 1, null}, valids}}; FCW expected_b{300, 300, 300, 400, 400, 400}; cudf::table_view t({a, b}); @@ -547,7 +541,7 @@ TEST_F(ExplodeOuterTest, Basics) // 300 [0, 3] string2 FCW a{100, 200, 300}; - LCW b{LCW{1, 2, 7}, LCW{5, 6}, LCW{0, 3}}; + LCW b{{1, 2, 7}, {5, 6}, {0, 3}}; cudf::test::strings_column_wrapper c{"string0", "string1", "string2"}; FCW expected_a{100, 100, 100, 200, 200, 300, 300}; @@ -580,7 +574,7 @@ TEST_F(ExplodeOuterTest, SingleNull) auto first_invalid = cudf::test::iterators::null_at(0); - LCW a({LCW{null}, LCW{5, 6}, LCW{}, LCW{0, 3}}, first_invalid); + LCW a({{null}, {5, 6}, {}, {0, 3}}, first_invalid); FCW b({100, 200, 300, 400}); FCW expected_a{{null, 5, 6, 0, 0, 3}, {false, true, true, false, true, true}}; @@ -609,7 +603,7 @@ TEST_F(ExplodeOuterTest, Nulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{1, 2, 7}, LCW{null}, LCW{0, 3}}, valids); + LCW a({{1, 2, 7}, {null}, {0, 3}}, valids); FCW b({100, null, 300}, valids); FCW expected_a({1, 2, 7, null, 0, 3}, {true, true, true, false, true, true}); @@ -639,7 +633,7 @@ TEST_F(ExplodeOuterTest, AllNulls) auto non_valid = cudf::test::iterators::all_nulls(); - LCW a({LCW{null}, LCW{null}, LCW{null}}, non_valid); + LCW a({{null}, {null}, {null}}, non_valid); FCW b({100, 200, 300}); FCW expected_a({null, null, null}, {false, false, false}); @@ -671,7 +665,7 @@ TEST_F(ExplodeOuterTest, SequentialNulls) auto third_invalid = cudf::test::iterators::null_at(2); - LCW a{LCW({1, 2, null}, third_invalid), LCW{3, 4}, LCW{}, LCW{}, LCW{5, 6, 7}}; + LCW a{{{1, 2, null}, third_invalid}, {3, 4}, {}, {}, {5, 6, 7}}; FCW b{100, 200, 300, 400, 500}; FCW expected_a({1, 2, null, 3, 4, null, null, 5, 6, 7}, @@ -704,7 +698,7 @@ TEST_F(ExplodeOuterTest, MoreEmptyThanData) constexpr auto null = 0; - LCW a{LCW{1, 2}, LCW{}, LCW{}, LCW{}, LCW{}, LCW{3}}; + LCW a{{1, 2}, {}, {}, {}, {}, {3}}; FCW b{100, 200, 300, 400, 500, 600}; FCW expected_a({1, 2, null, null, null, null, 3}, {true, true, false, false, false, false, true}); @@ -734,7 +728,7 @@ TEST_F(ExplodeOuterTest, TrailingEmptys) constexpr auto null = 0; - LCW a{LCW{1, 2}, LCW{}, LCW{}, LCW{}, LCW{}}; + LCW a{{1, 2}, {}, {}, {}, {}}; FCW b{100, 200, 300, 400, 500}; FCW expected_a({1, 2, null, null, null, null}, {true, true, false, false, false, false}); @@ -766,7 +760,7 @@ TEST_F(ExplodeOuterTest, LeadingNulls) auto valids = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i == 4; }); - LCW a({LCW{null}, LCW{null}, LCW{null}, LCW{null}, LCW{1, 2}}, valids); + LCW a({{null}, {null}, {null}, {null}, {1, 2}}, valids); FCW b{100, 200, 300, 400, 500}; FCW expected_a({null, null, null, null, 1, 2}, {false, false, false, false, true, true}); @@ -797,8 +791,7 @@ TEST_F(ExplodeOuterTest, NullsInList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{ - LCW({1, null, 7}, valids), LCW({5, null, 0, null}, valids), LCW{}, LCW({0, null, 8}, valids)}; + LCW a{{{1, null, 7}, valids}, {{5, null, 0, null}, valids}, {}, {{0, null, 8}, valids}}; FCW b{100, 200, 300, 400}; FCW expected_a({1, null, 7, 5, null, 0, null, null, 0, null, 8}, @@ -827,10 +820,10 @@ TEST_F(ExplodeOuterTest, Nested) // [[5, 6]] 200 // [[0, 3],[],[5],[2, 1]] 300 - LCW a{LCW{LCW{1, 2}, LCW{7, 6, 5}}, LCW{LCW{5, 6}}, LCW{LCW{0, 3}, LCW{}, LCW{5}, LCW{2, 1}}}; + LCW a{{{1, 2}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {}, {5}, {2, 1}}}; FCW b{100, 200, 300}; - LCW expected_a{LCW{1, 2}, LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{}, LCW{5}, LCW{2, 1}}; + LCW expected_a{{1, 2}, {7, 6, 5}, {5, 6}, {0, 3}, {}, {5}, {2, 1}}; FCW expected_b{100, 100, 200, 300, 300, 300, 300}; cudf::table_view t({a, b}); @@ -858,12 +851,11 @@ TEST_F(ExplodeOuterTest, NestedNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW{1, 2}, LCW{7, 6, 5}}, LCW{LCW{null}}, LCW{LCW{0, 3}, LCW{5}, LCW{2, 1}}}, valids); + LCW a({{{1, 2}, {7, 6, 5}}, LCW::nested({{null}}), {{0, 3}, {5}, {2, 1}}}, valids); FCW b({100, 200, 300}); auto expected_valids = cudf::test::iterators::null_at(2); - LCW expected_a({LCW{1, 2}, LCW{7, 6, 5}, LCW{null}, LCW{0, 3}, LCW{5}, LCW{2, 1}}, - expected_valids); + LCW expected_a({{1, 2}, {7, 6, 5}, {null}, {0, 3}, {5}, {2, 1}}, expected_valids); FCW expected_b({100, 100, 200, 300, 300, 300}); cudf::table_view t({a, b}); cudf::table_view expected({expected_a, expected_b}); @@ -889,13 +881,11 @@ TEST_F(ExplodeOuterTest, NullsInNested) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, null}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); + LCW a( + {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); FCW b({100, 200, 300}); - LCW expected_a{ - LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; + LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; FCW expected_b{100, 100, 200, 300, 300, 300}; cudf::table_view t({a, b}); @@ -923,9 +913,9 @@ TEST_F(ExplodeOuterTest, NullsInNestedDoubleExplode) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{LCW{LCW({1, null}, valids), LCW{}, LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}; + LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, + LCW::nested({{5, 6}}), + {{0, 3}, {5}, {{2, null}, valids}}}; FCW b{100, 200, 300}; FCW expected_a({1, null, null, 7, 6, 5, 5, 6, 0, 3, 5, 2, null}, @@ -960,15 +950,13 @@ TEST_F(ExplodeOuterTest, NestedStructs) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, null}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}}); + LCW a( + {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); FCW b1({100, 200, 300}); cudf::test::strings_column_wrapper b2{"100", "200", "300"}; cudf::test::structs_column_wrapper b({b1, b2}); - LCW expected_a{ - LCW({1, null}, valids), LCW{7, 6, 5}, LCW{5, 6}, LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}; + LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; FCW expected_b1{100, 100, 200, 300, 300, 300}; cudf::test::strings_column_wrapper expected_b2{"100", "100", "200", "300", "300", "300"}; cudf::test::structs_column_wrapper expected_b({expected_b1, expected_b2}); @@ -1129,15 +1117,14 @@ TEST_F(ExplodeOuterTest, SlicedList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({LCW{LCW({1, null}, valids), LCW{7, 6, 5}}, - LCW{LCW{5, 6}}, - LCW{LCW{0, 3}, LCW{5}, LCW({2, null}, valids)}, - LCW{LCW{8, 3}, LCW{}, LCW({4, null, 1, null}, valids)}, - LCW{LCW{2, 3, 4}, LCW{9, 8}}}); + LCW a({{{{1, null}, valids}, {7, 6, 5}}, + LCW::nested({{5, 6}}), + {{0, 3}, {5}, {{2, null}, valids}}, + {{8, 3}, {}, {{4, null, 1, null}, valids}}, + {{2, 3, 4}, {9, 8}}}); FCW b({100, 200, 300, 400, 500}); - LCW expected_a{ - LCW{0, 3}, LCW{5}, LCW({2, null}, valids), LCW{8, 3}, LCW{}, LCW({4, null, 1, null}, valids)}; + LCW expected_a{{0, 3}, {5}, {{2, null}, valids}, {8, 3}, {}, {{4, null, 1, null}, valids}}; FCW expected_b{300, 300, 300, 400, 400, 400}; cudf::table_view t({a, b}); diff --git a/cpp/tests/lists/extract_tests.cpp b/cpp/tests/lists/extract_tests.cpp index 8e38053785c2..257bab31de58 100644 --- a/cpp/tests/lists/extract_tests.cpp +++ b/cpp/tests/lists/extract_tests.cpp @@ -44,7 +44,7 @@ TYPED_TEST(ListsExtractNumericsTest, ExtractElement) auto validity = cudf::detail::make_counting_transform_iterator(cudf::size_type{0}, [](auto i) { return i != 1; }); using LCW = cudf::test::lists_column_wrapper; - LCW input({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}}, validity); + LCW input({{3, 2, 1}, {}, {30, 20, 10, 50}, {100, 120}, {0}}, validity); { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(input), 0); @@ -103,9 +103,8 @@ TEST_F(ListsExtractTest, ExtractElementStrings) auto validity = cudf::detail::make_counting_transform_iterator(cudf::size_type{0}, [](auto i) { return i != 1; }); using LCW = cudf::test::lists_column_wrapper; - LCW input( - {LCW{"", "Héllo", "thesé"}, LCW{}, LCW{"are", "some", "", "z"}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW input({{"", "Héllo", "thesé"}, {}, {"are", "some", "", "z"}, {"tést", "String"}, {""}}, + validity); { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(input), 0); @@ -164,48 +163,48 @@ TYPED_TEST(ListsExtractNumericsTest, ExtractElementNestedLists) { std::vector validity{1, 0, 1, 1}; using LCW = cudf::test::lists_column_wrapper; - LCW list({LCW{LCW{2, 3}, LCW{4, 5}}, - LCW{LCW{}}, - LCW{LCW{6, 7, 8}, LCW{9, 10, 11}, LCW{12, 13, 14}}, - LCW{LCW{15, 16}, LCW{17, 18}, LCW{19, 20}, LCW{21, 22}, LCW{23, 24}}}, + LCW list({{{2, 3}, {4, 5}}, + LCW::nested({{}}), + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {19, 20}, {21, 22}, {23, 24}}}, validity.begin()); { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), 0); - LCW expected({LCW{2, 3}, LCW{}, LCW{6, 7, 8}, LCW{15, 16}}, validity.begin()); + LCW expected({{2, 3}, {}, {6, 7, 8}, {15, 16}}, validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), 1); - LCW expected({LCW{4, 5}, LCW{}, LCW{9, 10, 11}, LCW{17, 18}}, validity.begin()); + LCW expected({{4, 5}, {}, {9, 10, 11}, {17, 18}}, validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), 2); std::vector expected_validity{0, 0, 1, 1}; - LCW expected({LCW{}, LCW{}, LCW{12, 13, 14}, LCW{19, 20}}, expected_validity.begin()); + LCW expected({{}, {}, {12, 13, 14}, {19, 20}}, expected_validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), 3); std::vector expected_validity{0, 0, 0, 1}; - LCW expected({LCW{}, LCW{}, LCW{}, LCW{21, 22}}, expected_validity.begin()); + LCW expected({{}, {}, {}, {21, 22}}, expected_validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), -1); - LCW expected({LCW{4, 5}, LCW{}, LCW{12, 13, 14}, LCW{23, 24}}, validity.begin()); + LCW expected({{4, 5}, {}, {12, 13, 14}, {23, 24}}, validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), -2); - LCW expected({LCW{2, 3}, LCW{}, LCW{9, 10, 11}, LCW{21, 22}}, validity.begin()); + LCW expected({{2, 3}, {}, {9, 10, 11}, {21, 22}}, validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } { auto result = cudf::lists::extract_list_element(cudf::lists_column_view(list), -3); std::vector expected_validity{0, 0, 1, 1}; - LCW expected({LCW{}, LCW{}, LCW{6, 7, 8}, LCW{19, 20}}, expected_validity.begin()); + LCW expected({{}, {}, {6, 7, 8}, {19, 20}}, expected_validity.begin()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } } @@ -219,12 +218,12 @@ TEST_F(ListsExtractTest, ExtractElementEmpty) EXPECT_EQ(cudf::data_type{cudf::type_id::STRING}, result->type()); EXPECT_EQ(0, result->size()); - LCW empty_strings({LCW{"", "", ""}}); + LCW empty_strings({{"", "", ""}}); result = cudf::lists::extract_list_element(cudf::lists_column_view(empty_strings), 1); cudf::test::strings_column_wrapper expected({""}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *result); - LCW null_strings({LCW{"", "", ""}}, cuda::make_constant_iterator(0)); + LCW null_strings({{"", "", ""}}, cuda::make_constant_iterator(0)); result = cudf::lists::extract_list_element(cudf::lists_column_view(null_strings), 1); cudf::test::strings_column_wrapper expected_null({""}, {0}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected_null, *result); @@ -268,9 +267,9 @@ TYPED_TEST(ListsExtractColumnIndicesTypedTest, ExtractElement) using FWCW = cudf::test::fixed_width_column_wrapper; using indices = cudf::test::fixed_width_column_wrapper; - auto input_column = LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, - cudf::test::iterators::null_at(1)); - auto input = cudf::lists_column_view(input_column); + auto input_column = + LCW({{3, 2, 1}, {}, {30, 20, 10, 50}, {100, 120}, {0}, {}}, cudf::test::iterators::null_at(1)); + auto input = cudf::lists_column_view(input_column); { // Test fetching first element. @@ -330,19 +329,17 @@ TYPED_TEST(ListsExtractColumnIndicesTypedTest, FailureCases) { // Non-empty input, with mismatched size of indices. - auto input_column = - LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, - cudf::test::iterators::null_at(1)); - auto input = cudf::lists_column_view(input_column); + auto input_column = LCW({{3, 2, 1}, {}, {30, 20, 10, 50}, {100, 120}, {0}, {}}, + cudf::test::iterators::null_at(1)); + auto input = cudf::lists_column_view(input_column); EXPECT_THROW(cudf::lists::extract_list_element(input, indices{0, 1, 2}), cudf::logic_error); } { // Non-empty input, with empty indices. - auto input_column = - LCW({LCW{3, 2, 1}, LCW{}, LCW{30, 20, 10, 50}, LCW{100, 120}, LCW{0}, LCW{}}, - cudf::test::iterators::null_at(1)); - auto input = cudf::lists_column_view(input_column); + auto input_column = LCW({{3, 2, 1}, {}, {30, 20, 10, 50}, {100, 120}, {0}, {}}, + cudf::test::iterators::null_at(1)); + auto input = cudf::lists_column_view(input_column); EXPECT_THROW(cudf::lists::extract_list_element(input, indices{}), cudf::logic_error); } @@ -360,9 +357,9 @@ TEST_F(ListsExtractColumnIndicesTest, ExtractStrings) using strings = cudf::test::strings_column_wrapper; using indices = cudf::test::fixed_width_column_wrapper; - auto input_column = LCW( - {LCW{"3", "2", "1"}, LCW{}, LCW{"30", "20", "10", "50"}, LCW{"100", "120"}, LCW{"0"}, LCW{}}, - cudf::test::iterators::null_at(1)); + auto input_column = + LCW({{"3", "2", "1"}, {}, {"30", "20", "10", "50"}, {"100", "120"}, {"0"}, {}}, + cudf::test::iterators::null_at(1)); auto input = cudf::lists_column_view(input_column); { diff --git a/cpp/tests/lists/reverse_tests.cpp b/cpp/tests/lists/reverse_tests.cpp index 1432cf6f7ae1..767011b88465 100644 --- a/cpp/tests/lists/reverse_tests.cpp +++ b/cpp/tests/lists/reverse_tests.cpp @@ -47,14 +47,14 @@ TEST_F(ListsReverseTest, EmptyInput) // Empty lists. { - auto const input = ints_lists{ints_lists{}, ints_lists{}, ints_lists{}}; + auto const input = ints_lists{{}, {}, {}}; auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(input, *results); } // Empty nested lists. { - auto const input = ints_lists{ints_lists{ints_lists{}}, ints_lists{}, ints_lists{}}; + auto const input = ints_lists{{{}}, {}, {}}; auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(input, *results); } @@ -79,7 +79,7 @@ TYPED_TEST(ListsReverseTypedTest, SimpleInputNoNulls) } { - auto const expected = lists_col{lists_col{}}; + auto const expected = lists_col{{}}; auto const input = cudf::slice(input_original, {2, 3})[0]; auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results); @@ -95,47 +95,36 @@ TYPED_TEST(ListsReverseTypedTest, SimpleInputNoNulls) TYPED_TEST(ListsReverseTypedTest, SimpleInputWithNulls) { - using lists_col = cudf::test::lists_column_wrapper; - auto const input_original = lists_col{{lists_col{}, - lists_col{1, 2, 3}, - lists_col{} /*null*/, - lists_col{{4, 5, null}, null_at(2)}, - lists_col{6, 7, 8}, - lists_col{9}}, - null_at(2)}; + using lists_col = cudf::test::lists_column_wrapper; + auto const input_original = + lists_col{{{}, {1, 2, 3}, {} /*null*/, {{4, 5, null}, null_at(2)}, {6, 7, 8}, {9}}, null_at(2)}; { - auto const expected = lists_col{{lists_col{}, - lists_col{3, 2, 1}, - lists_col{} /*null*/, - lists_col{{null, 5, 4}, null_at(0)}, - lists_col{8, 7, 6}, - lists_col{9}}, - null_at(2)}; - auto const results = cudf::lists::reverse(cudf::lists_column_view(input_original)); + auto const expected = lists_col{ + {{}, {3, 2, 1}, {} /*null*/, {{null, 5, 4}, null_at(0)}, {8, 7, 6}, {9}}, null_at(2)}; + auto const results = cudf::lists::reverse(cudf::lists_column_view(input_original)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results); } { - auto const expected = lists_col{ - {lists_col{3, 2, 1}, lists_col{} /*null*/, lists_col{{null, 5, 4}, null_at(0)}}, null_at(1)}; + auto const expected = + lists_col{{{3, 2, 1}, {} /*null*/, {{null, 5, 4}, null_at(0)}}, null_at(1)}; auto const input = cudf::slice(input_original, {1, 4})[0]; auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results); } { - auto const expected = lists_col{{lists_col{} /*null*/}, null_at(0)}; + auto const expected = lists_col{{{}}, null_at(0)}; auto const input = cudf::slice(input_original, {2, 3})[0]; auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results); } { - auto const expected = - lists_col{{lists_col{} /*null*/, lists_col{{null, 5, 4}, null_at(0)}}, null_at(0)}; - auto const input = cudf::slice(input_original, {2, 4})[0]; - auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); + auto const expected = lists_col{{{} /*null*/, {{null, 5, 4}, null_at(0)}}, null_at(0)}; + auto const input = cudf::slice(input_original, {2, 4})[0]; + auto const results = cudf::lists::reverse(cudf::lists_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results); } diff --git a/cpp/tests/lists/sequences_tests.cpp b/cpp/tests/lists/sequences_tests.cpp index c8930d85a01f..45d585cd2520 100644 --- a/cpp/tests/lists/sequences_tests.cpp +++ b/cpp/tests/lists/sequences_tests.cpp @@ -41,18 +41,16 @@ TYPED_TEST(NumericSequencesTypedTest, SimpleTestNoNull) // Sequences with step == 1. { - auto const expected = - ListsCol{ListsCol{1, 2, 3, 4, 5}, ListsCol{2, 3, 4}, ListsCol{3, 4, 5, 6}}; - auto const result = cudf::lists::sequences(starts, sizes); + auto const expected = ListsCol{{1, 2, 3, 4, 5}, {2, 3, 4}, {3, 4, 5, 6}}; + auto const result = cudf::lists::sequences(starts, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } // Sequences with various steps. { - auto const steps = FWDCol{1, 3, 2}; - auto const expected = - ListsCol{ListsCol{1, 2, 3, 4, 5}, ListsCol{2, 5, 8}, ListsCol{3, 5, 7, 9}}; - auto const result = cudf::lists::sequences(starts, steps, sizes); + auto const steps = FWDCol{1, 3, 2}; + auto const expected = ListsCol{{1, 2, 3, 4, 5}, {2, 5, 8}, {3, 5, 7, 9}}; + auto const result = cudf::lists::sequences(starts, steps, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } } @@ -66,7 +64,7 @@ TYPED_TEST(NumericSequencesTypedTest, ZeroSizesTest) // Sequences with step == 1. { - auto const expected = ListsCol{ListsCol{}, ListsCol{2, 3, 4}, ListsCol{}}; + auto const expected = ListsCol{{}, {2, 3, 4}, {}}; auto const result = cudf::lists::sequences(starts, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } @@ -74,7 +72,7 @@ TYPED_TEST(NumericSequencesTypedTest, ZeroSizesTest) // Sequences with various steps. { auto const steps = FWDCol{1, 3, 2}; - auto const expected = ListsCol{ListsCol{}, ListsCol{2, 5, 8}, ListsCol{}}; + auto const expected = ListsCol{{}, {2, 5, 8}, {}}; auto const result = cudf::lists::sequences(starts, steps, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } @@ -94,11 +92,7 @@ TYPED_TEST(NumericSequencesTypedTest, SlicedInputTestNoNulls) // Sequences with step == 1. { - auto const expected = ListsCol{ListsCol{1, 2, 3, 4, 5}, - ListsCol{2, 3, 4}, - ListsCol{3, 4, 5, 6}, - ListsCol{4}, - ListsCol{5, 6} + auto const expected = ListsCol{{1, 2, 3, 4, 5}, {2, 3, 4}, {3, 4, 5, 6}, {4}, {5, 6} }; auto const result = cudf::lists::sequences(starts, sizes); @@ -110,11 +104,7 @@ TYPED_TEST(NumericSequencesTypedTest, SlicedInputTestNoNulls) auto const steps_original = FWDCol{dont_care, dont_care, 1, 3, 2, 2, 3, dont_care}; auto const steps = cudf::slice(steps_original, {2, 7})[0]; - auto const expected = ListsCol{ListsCol{1, 2, 3, 4, 5}, - ListsCol{2, 5, 8}, - ListsCol{3, 5, 7, 9}, - ListsCol{4}, - ListsCol{5, 8} + auto const expected = ListsCol{{1, 2, 3, 4, 5}, {2, 5, 8}, {3, 5, 7, 9}, {4}, {5, 8} }; auto const result = cudf::lists::sequences(starts, steps, sizes); @@ -141,21 +131,20 @@ TYPED_TEST(DurationSequencesTypedTest, SequencesNoNull) // Sequences with step == 1. { auto const expected_h = std::vector{start_time, start_time + 1L, start_time + 2L}; - auto const expected = - ListsCol{ListsCol{expected_h.begin(), expected_h.begin() + 1}, - ListsCol{expected_h.begin(), expected_h.begin() + 2}, - ListsCol{expected_h.begin(), expected_h.begin() + 3}}; - auto const result = cudf::lists::sequences(starts, sizes); + auto const expected = ListsCol{{expected_h.begin(), expected_h.begin() + 1}, + {expected_h.begin(), expected_h.begin() + 2}, + {expected_h.begin(), expected_h.begin() + 3}}; + auto const result = cudf::lists::sequences(starts, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } // Sequences with various steps, including negative. { - auto const steps = FWDCol{10L, -155L, -13L}; - auto const expected = ListsCol{ - ListsCol{start_time}, - ListsCol{start_time, start_time - 155L}, - ListsCol{start_time, start_time - 13L, start_time - 13L * 2L}}; + auto const steps = FWDCol{10L, -155L, -13L}; + auto const expected = + ListsCol{{start_time}, + {start_time, start_time - 155L}, + {start_time, start_time - 13L, start_time - 13L * 2L}}; auto const result = cudf::lists::sequences(starts, steps, sizes); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); } diff --git a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp index 515b3d69734a..8afb20ff8677 100644 --- a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp @@ -65,21 +65,18 @@ TYPED_TEST_SUITE(SetDifferenceTypedTest, TestTypes); TEST_F(SetDifferenceTest, TrivialTest) { - auto const lhs = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; - auto const rhs = - floats_lists{{floats_lists{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - {} /*NULL*/}, - null_at(3)}; - auto const expected = floats_lists{ - {floats_lists{5.0}, floats_lists{5.0, NaN}, floats_lists{} /*NULL*/, floats_lists{} /*NULL*/}, - nulls_at({2, 3})}; + auto const lhs = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; + auto const rhs = floats_lists{{{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {} /*NULL*/}, + null_at(3)}; + auto const expected = + floats_lists{{{5.0}, {5.0, NaN}, {} /*NULL*/, {} /*NULL*/}, nulls_at({2, 3})}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results_sorted); @@ -87,15 +84,13 @@ TEST_F(SetDifferenceTest, TrivialTest) TEST_F(SetDifferenceTest, TrivialIdentityTest) { - auto const input = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; + auto const input = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; - auto const expected = - floats_lists{{floats_lists{}, floats_lists{}, {} /*NULL*/, floats_lists{}}, null_at(2)}; + auto const expected = floats_lists{{{}, {}, {} /*NULL*/, {}}, null_at(2)}; auto const results_sorted = set_difference_sorted(input, input); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results_sorted); @@ -106,7 +101,7 @@ TEST_F(SetDifferenceTest, FloatingPointTestsWithSignedZero) // -0.0 and 0.0 should be considered equal. auto const lhs = floats_lists{{0.0, 0.0, 0.0, 0.0, 0.0}, {-0.0, 1.0}, {0.0}}; auto const rhs = floats_lists{{-0.0, -0.0, -0.0, -0.0, -0.0}, {0.0, 2.0}, {1.0}}; - auto const expected = floats_lists{floats_lists{}, floats_lists{1.0}, floats_lists{0.0}}; + auto const expected = floats_lists{{}, {1.0}, {0.0}}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -116,7 +111,7 @@ TEST_F(SetDifferenceTest, FloatingPointTestsWithInf) { auto const lhs = floats_lists{{Inf, Inf, Inf}, {Inf, 0.0, neg_Inf}}; auto const rhs = floats_lists{{neg_Inf, neg_Inf}, {0.0}}; - auto const expected = floats_lists{floats_lists{Inf}, floats_lists{neg_Inf, Inf}}; + auto const expected = floats_lists{{Inf}, {neg_Inf, Inf}}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -158,9 +153,9 @@ TEST_F(SetDifferenceTest, StringTestsNonNull) // Trivial cases - empty input. { - auto const lhs = strings_lists{strings_lists{}}; - auto const rhs = strings_lists{strings_lists{}}; - auto const expected = strings_lists{strings_lists{}}; + auto const lhs = strings_lists{{}}; + auto const rhs = strings_lists{{}}; + auto const expected = strings_lists{{}}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -188,14 +183,11 @@ TEST_F(SetDifferenceTest, StringTestsNonNull) // Multiple lists column. { - auto const lhs = strings_lists{strings_lists{"one", "two", "three"}, - strings_lists{"four", "five", "six"}, - strings_lists{"1", "2", "3"}}; - auto const rhs = strings_lists{strings_lists{"one", "banana"}, - strings_lists{"apple", "kiwi", "cherry"}, - strings_lists{"two", "and", "1"}}; - auto const expected = strings_lists{ - strings_lists{"three", "two"}, strings_lists{"five", "four", "six"}, strings_lists{"2", "3"}}; + auto const lhs = + strings_lists{{"one", "two", "three"}, {"four", "five", "six"}, {"1", "2", "3"}}; + auto const rhs = + strings_lists{{"one", "banana"}, {"apple", "kiwi", "cherry"}, {"two", "and", "1"}}; + auto const expected = strings_lists{{"three", "two"}, {"five", "four", "six"}, {"2", "3"}}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -220,21 +212,20 @@ TEST_F(SetDifferenceTest, StringTestsWithNullsEqual) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = [] { - auto str_lists = strings_lists{{strings_lists{"a", "is", "string", "this"}, - strings_lists{} /*NULL*/, - strings_lists{"a", "is", "string"}}, - null_at(1)} - .release(); + auto str_lists = + strings_lists{{{"a", "is", "string", "this"}, {} /*NULL*/, {"a", "is", "string"}}, + null_at(1)} + .release(); auto& child = str_lists->child(cudf::lists_column_view::child_column_index); child.set_null_mask(cudf::create_null_mask(child.size(), cudf::mask_state::ALL_VALID), 0); return str_lists; @@ -264,19 +255,19 @@ TEST_F(SetDifferenceTest, StringTestsWithNullsUnequal) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = strings_lists{ - {strings_lists{{null, null, null, null, "a", "is", "string", "this"}, nulls_at({0, 1, 2, 3})}, - strings_lists{} /*NULL*/, - strings_lists{"a", "is", "string"}}, + {{{null, null, null, null, "a", "is", "string", "this"}, nulls_at({0, 1, 2, 3})}, + {} /*NULL*/, + {"a", "is", "string"}}, null_at(1)}; auto const results_sorted = set_difference_sorted(lhs, rhs, NULL_UNEQUAL); @@ -300,9 +291,9 @@ TYPED_TEST(SetDifferenceTypedTest, TrivialInputTests) // All input lists are empty. { - auto const lhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const rhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const expected = lists_col{lists_col{}, lists_col{}, lists_col{}}; + auto const lhs = lists_col{{}, {}, {}}; + auto const rhs = lists_col{{}, {}, {}}; + auto const expected = lists_col{{}, {}, {}}; auto const results_sorted = set_difference_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -383,13 +374,12 @@ TYPED_TEST(SetDifferenceTypedTest, InputHaveNullsTests) // Nullable child and nulls are equal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = lists_col{lists_col{1, 3}, lists_col{}, lists_col{{null}, null_at(0)}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{{1, 3}, {}, {{null}, null_at(0)}}; auto const results_sorted = set_difference_sorted(lhs, rhs, NULL_EQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -397,15 +387,14 @@ TYPED_TEST(SetDifferenceTypedTest, InputHaveNullsTests) // Nullable child and nulls are unequal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = lists_col{lists_col{{null, null, 1, 3}, nulls_at({0, 1})}, - lists_col{{null}, null_at(0)}, - lists_col{{null, null}, nulls_at({0, 1})}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{{{null, null, 1, 3}, nulls_at({0, 1})}, + {{null}, null_at(0)}, + {{null, null}, nulls_at({0, 1})}}; auto const results_sorted = set_difference_sorted(lhs, rhs, NULL_UNEQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -598,15 +587,15 @@ TEST_F(SetDifferenceTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{0, 1}, - floats_lists{0, 2}, - floats_lists{1, 1}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7}, - floats_lists{6, 8}, - floats_lists{6, 7, 8}}; + {0, 1}, + {0, 2}, + {1, 1}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7}, + {6, 8}, + {6, 7, 8}}; return structs_col{{child1, child2}}; }; @@ -627,15 +616,15 @@ TEST_F(SetDifferenceTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{1, 1}, - floats_lists{0, 2}, - floats_lists{1, 2}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7, 8, 9}, - floats_lists{6, 8}, - floats_lists{3, 4, 5}}; + {1, 1}, + {0, 2}, + {1, 2}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7, 8, 9}, + {6, 8}, + {3, 4, 5}}; return structs_col{{child1, child2}}; }; @@ -646,8 +635,7 @@ TEST_F(SetDifferenceTest, InputListsOfStructsOfLists) auto const expected = [] { auto const get_structs = [] { auto child1 = int32s_col{0, 2, 4, 6}; - auto child2 = floats_lists{ - floats_lists{0, 1}, floats_lists{1, 1}, floats_lists{6, 7}, floats_lists{6, 7, 8}}; + auto child2 = floats_lists{{0, 1}, {1, 1}, {6, 7}, {6, 7, 8}}; return structs_col{{child1, child2}}; }; diff --git a/cpp/tests/lists/set_operations/have_overlap_tests.cpp b/cpp/tests/lists/set_operations/have_overlap_tests.cpp index 7260c7d4ff4e..68681e157cbb 100644 --- a/cpp/tests/lists/set_operations/have_overlap_tests.cpp +++ b/cpp/tests/lists/set_operations/have_overlap_tests.cpp @@ -50,18 +50,16 @@ TYPED_TEST_SUITE(ListOverlapTypedTest, TestTypes); TEST_F(ListOverlapTest, TrivialTest) { - auto const lhs = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; - auto const rhs = - floats_lists{{floats_lists{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - {} /*NULL*/}, - null_at(3)}; + auto const lhs = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; + auto const rhs = floats_lists{{{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {} /*NULL*/}, + null_at(3)}; auto const expected = bools_col{{1, 1, null, null}, nulls_at({2, 3})}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}); @@ -127,8 +125,8 @@ TEST_F(ListOverlapTest, StringTestsNonNull) // Trivial cases - empty input. { - auto const lhs = strings_lists{strings_lists{}}; - auto const rhs = strings_lists{strings_lists{}}; + auto const lhs = strings_lists{{}}; + auto const rhs = strings_lists{{}}; auto const expected = bools_col{0}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}); @@ -157,12 +155,10 @@ TEST_F(ListOverlapTest, StringTestsNonNull) // Multiple lists column. { - auto const lhs = strings_lists{strings_lists{"one", "two", "three"}, - strings_lists{"four", "five", "six"}, - strings_lists{"1", "2", "3"}}; - auto const rhs = strings_lists{strings_lists{"one", "banana"}, - strings_lists{"apple", "kiwi", "cherry"}, - strings_lists{"two", "and", "1"}}; + auto const lhs = + strings_lists{{"one", "two", "three"}, {"four", "five", "six"}, {"1", "2", "3"}}; + auto const rhs = + strings_lists{{"one", "banana"}, {"apple", "kiwi", "cherry"}, {"two", "and", "1"}}; auto const expected = bools_col{1, 0, 1}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}); @@ -188,15 +184,15 @@ TEST_F(ListOverlapTest, StringTestsWithNullsEqual) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = bools_col{{1, 0 /*null*/, 1}, null_at(1)}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}, NULL_EQUAL); @@ -222,15 +218,15 @@ TEST_F(ListOverlapTest, StringTestsWithNullsUnequal) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = bools_col{{0, 0 /*null*/, 1}, null_at(1)}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}, NULL_UNEQUAL); @@ -254,8 +250,8 @@ TYPED_TEST(ListOverlapTypedTest, TrivialInputTests) // All input lists are empty. { - auto const lhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const rhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; + auto const lhs = lists_col{{}, {}, {}}; + auto const rhs = lists_col{{}, {}, {}}; auto const expected = bools_col{0, 0, 0}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}); @@ -337,12 +333,11 @@ TYPED_TEST(ListOverlapTypedTest, InputHaveNullsTests) // Nullable child and nulls are equal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; auto const expected = bools_col{1, 1, 1}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}, NULL_EQUAL); @@ -351,12 +346,11 @@ TYPED_TEST(ListOverlapTypedTest, InputHaveNullsTests) // Nullable child and nulls are unequal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; auto const expected = bools_col{0, 1, 1}; auto const results = cudf::lists::have_overlap(lists_cv{lhs}, lists_cv{rhs}, NULL_UNEQUAL); @@ -489,15 +483,15 @@ TEST_F(ListOverlapTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{0, 1}, - floats_lists{0, 2}, - floats_lists{1, 1}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7}, - floats_lists{6, 8}, - floats_lists{6, 7, 8}}; + {0, 1}, + {0, 2}, + {1, 1}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7}, + {6, 8}, + {6, 7, 8}}; return structs_col{{child1, child2}}; }; @@ -518,15 +512,15 @@ TEST_F(ListOverlapTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{1, 1}, - floats_lists{1, 2}, - floats_lists{1, 2}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7, 8, 9}, - floats_lists{6, 8}, - floats_lists{3, 4, 5}}; + {1, 1}, + {1, 2}, + {1, 2}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7, 8, 9}, + {6, 8}, + {3, 4, 5}}; return structs_col{{child1, child2}}; }; diff --git a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp index 30e9d583c9f5..2855c23837f2 100644 --- a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp @@ -66,23 +66,19 @@ TYPED_TEST_SUITE(SetIntersectTypedTest, TestTypes); TEST_F(SetIntersectTest, TrivialTest) { - auto const lhs = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; - auto const rhs = - floats_lists{{floats_lists{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - {} /*NULL*/}, - null_at(3)}; - auto const expected = floats_lists{{floats_lists{{null, 0.0, NaN}, null_at(0)}, - floats_lists{{null, 0.0, 1.0}, null_at(0)}, - floats_lists{} /*NULL*/, - floats_lists{} /*NULL*/}, - nulls_at({2, 3})}; + auto const lhs = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; + auto const rhs = floats_lists{{{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {} /*NULL*/}, + null_at(3)}; + auto const expected = floats_lists{ + {{{null, 0.0, NaN}, null_at(0)}, {{null, 0.0, 1.0}, null_at(0)}, {} /*NULL*/, {} /*NULL*/}, + nulls_at({2, 3})}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results_sorted); @@ -90,12 +86,11 @@ TEST_F(SetIntersectTest, TrivialTest) TEST_F(SetIntersectTest, TrivialIdentityTest) { - auto const input = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; + auto const input = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; // `intersect_distinct(input, input) <==> lists::distinct(input)`. auto const input_distinct = cudf::lists::distinct(lists_cv{input}); @@ -111,7 +106,7 @@ TEST_F(SetIntersectTest, FloatingPointTestsWithSignedZero) // -0.0 and 0.0 should be considered equal. auto const lhs = floats_lists{{0.0, 0.0, 0.0, 0.0, 0.0}, {-0.0, 1.0}, {0.0}}; auto const rhs = floats_lists{{-0.0, -0.0, -0.0, -0.0, -0.0}, {0.0, 2.0}, {1.0}}; - auto const expected = floats_lists{floats_lists{0}, floats_lists{0}, floats_lists{}}; + auto const expected = floats_lists{{0}, {0}, {}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -121,7 +116,7 @@ TEST_F(SetIntersectTest, FloatingPointTestsWithInf) { auto const lhs = floats_lists{{Inf, Inf, Inf}, {Inf, 0.0, neg_Inf}}; auto const rhs = floats_lists{{neg_Inf, neg_Inf}, {0.0, Inf}}; - auto const expected = floats_lists{floats_lists{}, floats_lists{0.0, Inf}}; + auto const expected = floats_lists{{}, {0.0, Inf}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -163,9 +158,9 @@ TEST_F(SetIntersectTest, StringTestsNonNull) // Trivial cases - empty input. { - auto const lhs = strings_lists{strings_lists{}}; - auto const rhs = strings_lists{strings_lists{}}; - auto const expected = strings_lists{strings_lists{}}; + auto const lhs = strings_lists{{}}; + auto const rhs = strings_lists{{}}; + auto const expected = strings_lists{{}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -175,7 +170,7 @@ TEST_F(SetIntersectTest, StringTestsNonNull) { auto const lhs = strings_lists{"this", "is", "a", "string"}; auto const rhs = strings_lists{"aha", "bear", "blow", "heat"}; - auto const expected = strings_lists{strings_lists{}}; + auto const expected = strings_lists{{}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -193,13 +188,11 @@ TEST_F(SetIntersectTest, StringTestsNonNull) // Multiple lists column. { - auto const lhs = strings_lists{strings_lists{"one", "two", "three"}, - strings_lists{"four", "five", "six"}, - strings_lists{"1", "2", "3"}}; - auto const rhs = strings_lists{strings_lists{"one", "banana"}, - strings_lists{"apple", "kiwi", "cherry"}, - strings_lists{"two", "and", "1"}}; - auto const expected = strings_lists{strings_lists{"one"}, strings_lists{}, strings_lists{"1"}}; + auto const lhs = + strings_lists{{"one", "two", "three"}, {"four", "five", "six"}, {"1", "2", "3"}}; + auto const rhs = + strings_lists{{"one", "banana"}, {"apple", "kiwi", "cherry"}, {"two", "and", "1"}}; + auto const expected = strings_lists{{"one"}, {}, {"1"}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -224,18 +217,16 @@ TEST_F(SetIntersectTest, StringTestsWithNullsEqual) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; - auto const expected = strings_lists{ - {strings_lists{{null}, null_at(0)}, strings_lists{} /*NULL*/, strings_lists{"this"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; + auto const expected = strings_lists{{{{null}, null_at(0)}, {} /*NULL*/, {"this"}}, null_at(1)}; auto const results_sorted = set_intersect_sorted(lhs, rhs, NULL_EQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -252,7 +243,7 @@ TEST_F(SetIntersectTest, StringTestsWithNullsUnequal) {"this", null, "is", "is", "is", "a", null, "string", null, "string"}, nulls_at({1, 6, 8})}; auto const rhs = strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}; - auto const expected = strings_lists{strings_lists{}}; + auto const expected = strings_lists{{}}; auto const results_sorted = set_intersect_sorted(lhs, rhs, NULL_UNEQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -260,21 +251,18 @@ TEST_F(SetIntersectTest, StringTestsWithNullsUnequal) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = [] { - auto str_lists = - strings_lists{{strings_lists{}, strings_lists{} /*NULL*/, strings_lists{"this"}}, - null_at(1)} - .release(); - auto& child = str_lists->child(cudf::lists_column_view::child_column_index); + auto str_lists = strings_lists({{}, {} /*NULL*/, {"this"}}, null_at(1)).release(); + auto& child = str_lists->child(cudf::lists_column_view::child_column_index); child.set_null_mask(cudf::create_null_mask(child.size(), cudf::mask_state::ALL_VALID), 0); return str_lists; }(); @@ -300,9 +288,9 @@ TYPED_TEST(SetIntersectTypedTest, TrivialInputTests) // All input lists are empty. { - auto const lhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const rhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const expected = lists_col{lists_col{}, lists_col{}, lists_col{}}; + auto const lhs = lists_col{{}, {}, {}}; + auto const rhs = lists_col{{}, {}, {}}; + auto const expected = lists_col{{}, {}, {}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -347,7 +335,7 @@ TYPED_TEST(SetIntersectTypedTest, SlicedNonNullInputTests) { auto const lhs = cudf::slice(lhs_original, {1, 3})[0]; auto const rhs = cudf::slice(rhs_original, {1, 3})[0]; - auto const expected = lists_col{lists_col{}, lists_col{}}; + auto const expected = lists_col{{}, {}}; auto const results_sorted = set_intersect_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -383,14 +371,12 @@ TYPED_TEST(SetIntersectTypedTest, InputHaveNullsTests) // Nullable child and nulls are equal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = - lists_col{lists_col{{null}, null_at(0)}, lists_col{{null, 5}, null_at(0)}, lists_col{7, 9}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{{{null}, null_at(0)}, {{null, 5}, null_at(0)}, {7, 9}}; auto const results_sorted = set_intersect_sorted(lhs, rhs, NULL_EQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -398,13 +384,12 @@ TYPED_TEST(SetIntersectTypedTest, InputHaveNullsTests) // Nullable child and nulls are unequal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = lists_col{lists_col{}, lists_col{5}, lists_col{7, 9}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{{}, {5}, {7, 9}}; auto const results_sorted = set_intersect_sorted(lhs, rhs, NULL_UNEQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results_sorted); @@ -566,15 +551,15 @@ TEST_F(SetIntersectTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{0, 1}, - floats_lists{0, 2}, - floats_lists{1, 1}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7}, - floats_lists{6, 8}, - floats_lists{6, 7, 8}}; + {0, 1}, + {0, 2}, + {1, 1}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7}, + {6, 8}, + {6, 7, 8}}; return structs_col{{child1, child2}}; }; @@ -595,15 +580,15 @@ TEST_F(SetIntersectTest, InputListsOfStructsOfLists) 5, 6}; auto child2 = floats_lists{// begin list1 - floats_lists{1, 1}, - floats_lists{0, 2}, - floats_lists{1, 2}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{6, 7, 8, 9}, - floats_lists{6, 8}, - floats_lists{3, 4, 5}}; + {1, 1}, + {0, 2}, + {1, 2}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {6, 7, 8, 9}, + {6, 8}, + {3, 4, 5}}; return structs_col{{child1, child2}}; }; @@ -614,7 +599,7 @@ TEST_F(SetIntersectTest, InputListsOfStructsOfLists) auto const expected = [] { auto const get_structs = [] { auto child1 = int32s_col{1, 3, 5}; - auto child2 = floats_lists{floats_lists{0, 2}, floats_lists{3, 4, 5}, floats_lists{6, 8}}; + auto child2 = floats_lists{{0, 2}, {3, 4, 5}, {6, 8}}; return structs_col{{child1, child2}}; }; diff --git a/cpp/tests/lists/set_operations/union_distinct_tests.cpp b/cpp/tests/lists/set_operations/union_distinct_tests.cpp index 340cf0746009..7756ebecd2aa 100644 --- a/cpp/tests/lists/set_operations/union_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/union_distinct_tests.cpp @@ -65,22 +65,20 @@ TYPED_TEST_SUITE(SetUnionTypedTest, TestTypes); TEST_F(SetUnionTest, TrivialTest) { - auto const lhs = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; - auto const rhs = - floats_lists{{floats_lists{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - floats_lists{{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, - {} /*NULL*/}, - null_at(3)}; - auto const expected = floats_lists{{floats_lists{{null, 0.0, 0.5, 1.0, 5.0, NaN}, null_at(0)}, - floats_lists{{null, 0.0, 1.0, 2.0, 5.0, NaN}, null_at(0)}, - floats_lists{} /*NULL*/, - floats_lists{} /*NULL*/}, + auto const lhs = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; + auto const rhs = floats_lists{{{{1.0, 0.5, null, 0.0, 0.0, null, NaN}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {{2.0, 1.0, null, 0.0, 0.0, null}, nulls_at({2, 5})}, + {} /*NULL*/}, + null_at(3)}; + auto const expected = floats_lists{{{{null, 0.0, 0.5, 1.0, 5.0, NaN}, null_at(0)}, + {{null, 0.0, 1.0, 2.0, 5.0, NaN}, null_at(0)}, + {} /*NULL*/, + {} /*NULL*/}, nulls_at({2, 3})}; auto const results_sorted = set_union_sorted(lhs, rhs); @@ -89,12 +87,11 @@ TEST_F(SetUnionTest, TrivialTest) TEST_F(SetUnionTest, TrivialIdentityTest) { - auto const input = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; + auto const input = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; // `union_distinct(input, input) <==> lists::distinct(input)`. auto const input_distinct = cudf::lists::distinct(lists_cv{input}); @@ -110,7 +107,7 @@ TEST_F(SetUnionTest, FloatingPointTestsWithSignedZero) // -0.0 and 0.0 should be considered equal. auto const lhs = floats_lists{{0.0, 0.0, 0.0, 0.0, 0.0}, {-0.0, 1.0}, {0.0}}; auto const rhs = floats_lists{{-0.0, -0.0, -0.0, -0.0, -0.0}, {0.0, 2.0}, {1.0}}; - auto const expected = floats_lists{floats_lists{0}, floats_lists{0, 1, 2}, floats_lists{0, 1}}; + auto const expected = floats_lists{{0}, {0, 1, 2}, {0, 1}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -120,7 +117,7 @@ TEST_F(SetUnionTest, FloatingPointTestsWithInf) { auto const lhs = floats_lists{{Inf, Inf, Inf}, {Inf, 0.0, neg_Inf}}; auto const rhs = floats_lists{{neg_Inf, neg_Inf}, {0.0, Inf}}; - auto const expected = floats_lists{floats_lists{neg_Inf, Inf}, floats_lists{neg_Inf, 0.0, Inf}}; + auto const expected = floats_lists{{neg_Inf, Inf}, {neg_Inf, 0.0, Inf}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -166,9 +163,9 @@ TEST_F(SetUnionTest, StringTestsNonNull) // Trivial cases - empty input. { - auto const lhs = strings_lists{strings_lists{}}; - auto const rhs = strings_lists{strings_lists{}}; - auto const expected = strings_lists{strings_lists{}}; + auto const lhs = strings_lists{{}}; + auto const rhs = strings_lists{{}}; + auto const expected = strings_lists{{}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -179,7 +176,7 @@ TEST_F(SetUnionTest, StringTestsNonNull) auto const lhs = strings_lists{"this", "is", "a", "string"}; auto const rhs = strings_lists{"aha", "bear", "blow", "heat"}; auto const expected = - strings_lists{strings_lists{"a", "aha", "bear", "blow", "heat", "is", "string", "this"}}; + strings_lists{{"a", "aha", "bear", "blow", "heat", "is", "string", "this"}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -197,16 +194,13 @@ TEST_F(SetUnionTest, StringTestsNonNull) // Multiple lists column. { - auto const lhs = strings_lists{strings_lists{"one", "two", "three"}, - strings_lists{"four", "five", "six"}, - strings_lists{"1", "2", "3"}}; - auto const rhs = strings_lists{strings_lists{"one", "banana"}, - strings_lists{"apple", "kiwi", "cherry"}, - strings_lists{"two", "and", "1"}}; - auto const expected = - strings_lists{strings_lists{"banana", "one", "three", "two"}, - strings_lists{"apple", "cherry", "five", "four", "kiwi", "six"}, - strings_lists{"1", "2", "3", "and", "two"}}; + auto const lhs = + strings_lists{{"one", "two", "three"}, {"four", "five", "six"}, {"1", "2", "3"}}; + auto const rhs = + strings_lists{{"one", "banana"}, {"apple", "kiwi", "cherry"}, {"two", "and", "1"}}; + auto const expected = strings_lists{{"banana", "one", "three", "two"}, + {"apple", "cherry", "five", "four", "kiwi", "six"}, + {"1", "2", "3", "and", "two"}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -232,19 +226,19 @@ TEST_F(SetUnionTest, StringTestsWithNullsEqual) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = strings_lists{ - {strings_lists{{null, "1111", "2222", "a", "abc", "aha", "is", "string", "this"}, null_at(0)}, - strings_lists{} /*NULL*/, - strings_lists{"a", "aha", "is", "is another", "string", "string???", "this"}}, + {{{null, "1111", "2222", "a", "abc", "aha", "is", "string", "this"}, null_at(0)}, + {} /*NULL*/, + {"a", "aha", "is", "is another", "string", "string???", "this"}}, null_at(1)}; auto const results_sorted = set_union_sorted(lhs, rhs, NULL_EQUAL); @@ -284,34 +278,34 @@ TEST_F(SetUnionTest, StringTestsWithNullsUnequal) // Multiple lists column with null lists and null entries. { - auto const lhs = strings_lists{ - strings_lists{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, - strings_lists{}, - strings_lists{"this", "is", "a", "string"}}; - auto const rhs = strings_lists{ - {strings_lists{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, - strings_lists{}, /* NULL */ - strings_lists{"aha", "this", "is another", "string???"}}, - null_at(1)}; + auto const lhs = + strings_lists{{{"this", null, "is", null, "a", null, null, "string"}, nulls_at({1, 3, 5, 6})}, + {}, + {"this", "is", "a", "string"}}; + auto const rhs = + strings_lists{{{{"aha", null, "abc", null, "1111", null, "2222"}, nulls_at({1, 3, 5})}, + {}, /* NULL */ + {"aha", "this", "is another", "string???"}}, + null_at(1)}; auto const expected = - strings_lists{{strings_lists{{null, - null, - null, - null, - null, - null, - null, - "1111", - "2222", - "a", - "abc", - "aha", - "is", - "string", - "this"}, - nulls_at({0, 1, 2, 3, 4, 5, 6})}, - strings_lists{} /*NULL*/, - strings_lists{"a", "aha", "is", "is another", "string", "string???", "this"}}, + strings_lists{{{{null, + null, + null, + null, + null, + null, + null, + "1111", + "2222", + "a", + "abc", + "aha", + "is", + "string", + "this"}, + nulls_at({0, 1, 2, 3, 4, 5, 6})}, + {} /*NULL*/, + {"a", "aha", "is", "is another", "string", "string???", "this"}}, null_at(1)}; auto const results_sorted = set_union_sorted(lhs, rhs, NULL_UNEQUAL); @@ -335,9 +329,9 @@ TYPED_TEST(SetUnionTypedTest, TrivialInputTests) // All input lists are empty. { - auto const lhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const rhs = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const expected = lists_col{lists_col{}, lists_col{}, lists_col{}}; + auto const lhs = lists_col{{}, {}, {}}; + auto const rhs = lists_col{{}, {}, {}}; + auto const expected = lists_col{{}, {}, {}}; auto const results_sorted = set_union_sorted(lhs, rhs); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -420,15 +414,13 @@ TYPED_TEST(SetUnionTypedTest, InputHaveNullsTests) // Nullable child and nulls are equal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = lists_col{lists_col{{null, 1, 3, 5}, null_at(0)}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, 8, 9}, null_at(0)}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{ + {{null, 1, 3, 5}, null_at(0)}, {{null, 5}, null_at(0)}, {{null, 7, 8, 9}, null_at(0)}}; auto const results_sorted = set_union_sorted(lhs, rhs, NULL_EQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -436,16 +428,14 @@ TYPED_TEST(SetUnionTypedTest, InputHaveNullsTests) // Nullable child and nulls are unequal. { - auto const lhs = lists_col{lists_col{{null, 1, null, 3}, nulls_at({0, 2})}, - lists_col{{null, 5}, null_at(0)}, - lists_col{{null, 7, null, 9}, nulls_at({0, 2})}}; - auto const rhs = lists_col{lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{5, null}, null_at(1)}, - lists_col{7, 8, 9}}; - auto const expected = - lists_col{lists_col{{null, null, null, null, 1, 3, 5}, nulls_at({0, 1, 2, 3})}, - lists_col{{null, null, 5}, nulls_at({0, 1})}, - lists_col{{null, null, 7, 8, 9}, nulls_at({0, 1})}}; + auto const lhs = lists_col{{{null, 1, null, 3}, nulls_at({0, 2})}, + {{null, 5}, null_at(0)}, + {{null, 7, null, 9}, nulls_at({0, 2})}}; + auto const rhs = + lists_col{{{null, null, 5}, nulls_at({0, 1})}, {{5, null}, null_at(1)}, {7, 8, 9}}; + auto const expected = lists_col{{{null, null, null, null, 1, 3, 5}, nulls_at({0, 1, 2, 3})}, + {{null, null, 5}, nulls_at({0, 1})}, + {{null, null, 7, 8, 9}, nulls_at({0, 1})}}; auto const results_sorted = set_union_sorted(lhs, rhs, NULL_UNEQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, *results_sorted); diff --git a/cpp/tests/lists/sort_lists_tests.cpp b/cpp/tests/lists/sort_lists_tests.cpp index 8b7bc0e8463f..aaa277097e3f 100644 --- a/cpp/tests/lists/sort_lists_tests.cpp +++ b/cpp/tests/lists/sort_lists_tests.cpp @@ -130,14 +130,14 @@ TEST_F(SortListsInt, Empty) CUDF_TEST_EXPECT_COLUMNS_EQUAL(stable_sorted_lists->view(), l); } { - LCW l{LCW{}}; + LCW l{{}}; auto const [sorted_lists, stable_sorted_lists] = generate_sorted_lists(cudf::lists_column_view{l}, {}, {}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(sorted_lists->view(), l); CUDF_TEST_EXPECT_COLUMNS_EQUAL(stable_sorted_lists->view(), l); } { - LCW l{LCW{}, LCW{}}; + LCW l{{}, {}}; auto const [sorted_lists, stable_sorted_lists] = generate_sorted_lists(cudf::lists_column_view{l}, {}, {}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(sorted_lists->view(), l); @@ -182,10 +182,10 @@ TEST_F(SortListsInt, NestedListElement) using T = int; // Column of LIST>: each row's inner lists are reordered as whole elements. The third // row's inner lists tie on their first element, so ordering falls through to the second. - LCW input{LCW{{3, 1}, {2, 0}}, LCW{{5, 5}, {4, 9}}, LCW{{1, 3}, {1, 2}}}; + LCW input{{{3, 1}, {2, 0}}, {{5, 5}, {4, 9}}, {{1, 3}, {1, 2}}}; { // Ascending. - LCW expected{LCW{{2, 0}, {3, 1}}, LCW{{4, 9}, {5, 5}}, LCW{{1, 2}, {1, 3}}}; + LCW expected{{{2, 0}, {3, 1}}, {{4, 9}, {5, 5}}, {{1, 2}, {1, 3}}}; auto const [sorted_lists, stable_sorted_lists] = generate_sorted_lists( cudf::lists_column_view{input}, cudf::order::ASCENDING, cudf::null_order::AFTER); CUDF_TEST_EXPECT_COLUMNS_EQUAL(sorted_lists->view(), expected); @@ -193,7 +193,7 @@ TEST_F(SortListsInt, NestedListElement) } { // Descending reverses each row's ascending order. - LCW expected{LCW{{3, 1}, {2, 0}}, LCW{{5, 5}, {4, 9}}, LCW{{1, 3}, {1, 2}}}; + LCW expected{{{3, 1}, {2, 0}}, {{5, 5}, {4, 9}}, {{1, 3}, {1, 2}}}; auto const [sorted_lists, stable_sorted_lists] = generate_sorted_lists( cudf::lists_column_view{input}, cudf::order::DESCENDING, cudf::null_order::AFTER); CUDF_TEST_EXPECT_COLUMNS_EQUAL(sorted_lists->view(), expected); diff --git a/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp b/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp index 1e0793c3cc71..b0db904996fa 100644 --- a/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp +++ b/cpp/tests/lists/stream_compaction/apply_boolean_mask_tests.cpp @@ -65,11 +65,11 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, NullElementsInTheListRows) auto input = lists{ {0, 1, 2, 3}, - lists{{X, 5}, null_at(0)}, + {{X, 5}, null_at(0)}, {6, 7, 8, 9}, {0, 1}, - lists{{X, 3, 4, X}, nulls_at({0, 3})}, - lists{{X, X}, nulls_at({0, 1})}, + {{X, 3, 4, X}, nulls_at({0, 3})}, + {{X, X}, nulls_at({0, 1})}, } .release(); auto filter = filter_t{{1, 0, 1, 0}, {1, 0}, {1, 0, 1, 0}, {1, 0}, {1, 0, 1, 0}, {1, 0}}; @@ -77,12 +77,8 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, NullElementsInTheListRows) { // Unsliced. auto filtered = apply_boolean_mask(lists_column_view{*input}, lists_column_view{filter}); - auto expected = lists{{0, 2}, - lists{{X}, null_at(0)}, - {6, 8}, - {0}, - lists{{X, 4}, null_at(0)}, - lists{{X}, null_at(0)}}; + auto expected = + lists{{0, 2}, {{X}, null_at(0)}, {6, 8}, {0}, {{X, 4}, null_at(0)}, {{X}, null_at(0)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } { @@ -91,7 +87,7 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, NullElementsInTheListRows) // == lists_t {{X, 5}, {6, 7, 8, 9}, {0, 1}, {X, 3, 4, X}, {X, X}}; auto filter = filter_t{{0, 1}, {0, 1, 0, 1}, {1, 1}, {0, 1, 0, 1}, {0, 0}}; auto filtered = apply_boolean_mask(lists_column_view{sliced}, lists_column_view{filter}); - auto expected = lists{{5}, {7, 9}, {0, 1}, lists{{3, X}, null_at(1)}, {}}; + auto expected = lists{{5}, {7, 9}, {0, 1}, {{3, X}, null_at(1)}, {}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } } @@ -203,7 +199,7 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, NullsInBooleanMask) auto mask = cudf::make_lists_column(3, offsets{0, 3, 5, 9}.release(), mask_child.release(), 0, {}); auto filtered = apply_boolean_mask(lists_column_view{input}, lists_column_view{*mask}); - auto expected = lists{{10, 30}, lists{}, {80}}; + auto expected = lists{{10, 30}, {}, {80}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } @@ -261,7 +257,7 @@ TYPED_TEST(ApplyDeletionMaskTypedTest, AllTrue) auto mask = filter_t{{1, 1, 1}, {1, 1}}; auto filtered = apply_deletion_mask(lists_column_view{input}, lists_column_view{mask}); - auto expected = lists{lists{}, lists{}}; + auto expected = lists{{}, {}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } @@ -282,30 +278,26 @@ TYPED_TEST(ApplyDeletionMaskTypedTest, NullElementsInTheListRows) auto input = lists{ {0, 1, 2, 3}, - lists{{X, 5}, null_at(0)}, + {{X, 5}, null_at(0)}, {6, 7, 8, 9}, {0, 1}, - lists{{X, 3, 4, X}, nulls_at({0, 3})}, - lists{{X, X}, nulls_at({0, 1})}, + {{X, 3, 4, X}, nulls_at({0, 3})}, + {{X, X}, nulls_at({0, 1})}, } .release(); auto filter = filter_t{{1, 0, 1, 0}, {1, 0}, {1, 0, 1, 0}, {1, 0}, {1, 0, 1, 0}, {1, 0}}; { auto filtered = apply_deletion_mask(lists_column_view{*input}, lists_column_view{filter}); - auto expected = - lists{{1, 3}, {5}, {7, 9}, {1}, lists{{3, X}, null_at(1)}, lists{{X}, null_at(0)}}; + auto expected = lists{{1, 3}, {5}, {7, 9}, {1}, {{3, X}, null_at(1)}, {{X}, null_at(0)}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } { auto sliced = cudf::slice(*input, {1, input->size()}).front(); auto filter = filter_t{{0, 1}, {0, 1, 0, 1}, {1, 1}, {0, 1, 0, 1}, {0, 0}}; auto filtered = apply_deletion_mask(lists_column_view{sliced}, lists_column_view{filter}); - auto expected = lists{lists{{X}, null_at(0)}, - {6, 8}, - {}, - lists{{X, 4}, null_at(0)}, - lists{{X, X}, nulls_at({0, 1})}}; + auto expected = + lists{{{X}, null_at(0)}, {6, 8}, {}, {{X, 4}, null_at(0)}, {{X, X}, nulls_at({0, 1})}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } } @@ -364,7 +356,7 @@ TYPED_TEST(ApplyDeletionMaskTypedTest, NullsInDeletionMask) auto mask = cudf::make_lists_column(3, offsets{0, 3, 5, 9}.release(), mask_child.release(), 0, {}); auto filtered = apply_deletion_mask(lists_column_view{input}, lists_column_view{*mask}); - auto expected = lists{lists{}, {40}, {70, 90}}; + auto expected = lists{{}, {40}, {70, 90}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*filtered, expected); } diff --git a/cpp/tests/lists/stream_compaction/distinct_tests.cpp b/cpp/tests/lists/stream_compaction/distinct_tests.cpp index b16ed2519385..28be28465d57 100644 --- a/cpp/tests/lists/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/lists/stream_compaction/distinct_tests.cpp @@ -64,17 +64,16 @@ TYPED_TEST_SUITE(ListDistinctTypedTest, TestTypes); TEST_F(ListDistinctTest, TrivialTest) { - auto const input = - floats_lists{{floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, - {} /*NULL*/, - floats_lists{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, - null_at(2)}; - - auto const expected = floats_lists{{floats_lists{{null, 0.0, 5.0, NaN}, null_at(0)}, - floats_lists{{null, 0.0, 1.0, 5.0, NaN}, null_at(0)}, - floats_lists{} /*NULL*/, - floats_lists{{null, 0.0, 1.0, 5.0, NaN}, null_at(0)}}, + auto const input = floats_lists{{{{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 0.0}, null_at(6)}, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}, + {} /*NULL*/, + {{NaN, 5.0, 0.0, 0.0, 0.0, 0.0, null, 1.0}, null_at(6)}}, + null_at(2)}; + + auto const expected = floats_lists{{{{null, 0.0, 5.0, NaN}, null_at(0)}, + {{null, 0.0, 1.0, 5.0, NaN}, null_at(0)}, + {} /*NULL*/, + {{null, 0.0, 1.0, 5.0, NaN}, null_at(0)}}, null_at(2)}; auto const results_sorted = distinct_sorted(input); @@ -153,16 +152,15 @@ TEST_F(ListDistinctTest, StringTestsNonNull) // Multiple lists column. { - auto const input = strings_lists{ - strings_lists{"this", "is", "a", "no duplicate", "string"}, - strings_lists{"this", "is", "is", "a", "one duplicate", "string"}, - strings_lists{"this", "is", "is", "is", "a", "two duplicates", "string"}, - strings_lists{"this", "is", "is", "is", "is", "a", "three duplicates", "string"}}; - auto const expected = - strings_lists{strings_lists{"a", "is", "no duplicate", "string", "this"}, - strings_lists{"a", "is", "one duplicate", "string", "this"}, - strings_lists{"a", "is", "string", "this", "two duplicates"}, - strings_lists{"a", "is", "string", "this", "three duplicates"}}; + auto const input = + strings_lists{{"this", "is", "a", "no duplicate", "string"}, + {"this", "is", "is", "a", "one duplicate", "string"}, + {"this", "is", "is", "is", "a", "two duplicates", "string"}, + {"this", "is", "is", "is", "is", "a", "three duplicates", "string"}}; + auto const expected = strings_lists{{"a", "is", "no duplicate", "string", "this"}, + {"a", "is", "one duplicate", "string", "this"}, + {"a", "is", "string", "this", "two duplicates"}, + {"a", "is", "string", "this", "three duplicates"}}; auto const results_sorted = distinct_sorted(input); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -185,16 +183,16 @@ TEST_F(ListDistinctTest, StringTestsWithNullsEqual) // Multiple lists column with null lists and null entries. { - auto const input = strings_lists{ - {strings_lists{{"this", null, "is", null, "a", null, "no duplicate", null, "string"}, - nulls_at({1, 3, 5, 7})}, - strings_lists{}, /* NULL */ - strings_lists{"this", "is", "is", "a", "one duplicate", "string"}}, - null_at(1)}; + auto const input = + strings_lists{{{{"this", null, "is", null, "a", null, "no duplicate", null, "string"}, + nulls_at({1, 3, 5, 7})}, + {}, /* NULL */ + {"this", "is", "is", "a", "one duplicate", "string"}}, + null_at(1)}; auto const expected = - strings_lists{{strings_lists{{null, "a", "is", "no duplicate", "string", "this"}, null_at(0)}, - strings_lists{}, /* NULL */ - strings_lists{"a", "is", "one duplicate", "string", "this"}}, + strings_lists{{{{null, "a", "is", "no duplicate", "string", "this"}, null_at(0)}, + {}, /* NULL */ + {"a", "is", "one duplicate", "string", "this"}}, null_at(1)}; auto const results_sorted = distinct_sorted(input); @@ -219,18 +217,18 @@ TEST_F(ListDistinctTest, StringTestsWithNullsUnequal) // Multiple lists column with null lists and null entries. { - auto const input = strings_lists{ - {strings_lists{{"this", null, "is", null, "a", null, "no duplicate", null, "string"}, - nulls_at({1, 3, 5, 7})}, - strings_lists{}, /* NULL */ - strings_lists{"this", "is", "is", "a", "one duplicate", "string"}}, - null_at(1)}; - auto const expected = strings_lists{ - {strings_lists{{null, null, null, null, "a", "is", "no duplicate", "string", "this"}, - nulls_at({0, 1, 2, 3})}, - strings_lists{}, /* NULL */ - strings_lists{"a", "is", "one duplicate", "string", "this"}}, - null_at(1)}; + auto const input = + strings_lists{{{{"this", null, "is", null, "a", null, "no duplicate", null, "string"}, + nulls_at({1, 3, 5, 7})}, + {}, /* NULL */ + {"this", "is", "is", "a", "one duplicate", "string"}}, + null_at(1)}; + auto const expected = + strings_lists{{{{null, null, null, null, "a", "is", "no duplicate", "string", "this"}, + nulls_at({0, 1, 2, 3})}, + {}, /* NULL */ + {"a", "is", "one duplicate", "string", "this"}}, + null_at(1)}; auto const results_sorted = distinct_sorted(input, NULL_UNEQUAL); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -252,8 +250,8 @@ TYPED_TEST(ListDistinctTypedTest, TrivialInputTests) // All input lists are empty. { - auto const input = lists_col{lists_col{}, lists_col{}, lists_col{}}; - auto const expected = lists_col{lists_col{}, lists_col{}, lists_col{}}; + auto const input = lists_col{{}, {}, {}}; + auto const expected = lists_col{{}, {}, {}}; auto const results_sorted = distinct_sorted(input); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results_sorted); @@ -712,18 +710,18 @@ TEST_F(ListDistinctTest, InputListsOfStructsOfLists) 3, 3}; auto child2 = floats_lists{// begin list1 - floats_lists{0, 1}, - floats_lists{0, 1}, - floats_lists{0, 1}, // end list1 - // begin list2 - floats_lists{3, 4, 5}, // end list2 - // begin list3 - floats_lists{}, - floats_lists{}, // end list3 - // begin list4 - floats_lists{6, 7}, - floats_lists{6, 7}, - floats_lists{6, 7}}; + {0, 1}, + {0, 1}, + {0, 1}, // end list1 + // begin list2 + {3, 4, 5}, // end list2 + // begin list3 + {}, + {}, // end list3 + // begin list4 + {6, 7}, + {6, 7}, + {6, 7}}; return structs_col{{child1, child2}}; }; @@ -734,8 +732,7 @@ TEST_F(ListDistinctTest, InputListsOfStructsOfLists) auto const expected = [] { auto const get_structs = [] { auto child1 = int32s_col{0, 1, 2, 3}; - auto child2 = - floats_lists{floats_lists{0, 1}, floats_lists{3, 4, 5}, floats_lists{}, floats_lists{6, 7}}; + auto child2 = floats_lists{{0, 1}, {3, 4, 5}, {}, {6, 7}}; return structs_col{{child1, child2}}; }; diff --git a/cpp/tests/merge/merge_test.cpp b/cpp/tests/merge/merge_test.cpp index 1d8ea3010ae2..90038a371c95 100644 --- a/cpp/tests/merge/merge_test.cpp +++ b/cpp/tests/merge/merge_test.cpp @@ -860,15 +860,15 @@ using cudf::test::iterators::nulls_at; TEST_F(MergeTest, Lists) { - auto col1 = lcw{lcw{1}, lcw{3}, lcw{5}, lcw{7}}; - auto col2 = lcw{lcw{2}, lcw{4}, lcw{6}, lcw{8}}; + auto col1 = lcw({{1}, {3}, {5}, {7}}); + auto col2 = lcw({{2}, {4}, {6}, {8}}); auto tbl1 = cudf::table_view{{col1}}; auto tbl2 = cudf::table_view{{col2}}; auto result = cudf::merge({tbl1, tbl2}, {0}, {cudf::order::ASCENDING}); - auto expected_col = lcw{lcw{1}, lcw{2}, lcw{3}, lcw{4}, lcw{5}, lcw{6}, lcw{7}, lcw{8}}; + auto expected_col = lcw({{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}}); auto expected_tbl = cudf::table_view{{expected_col}}; CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected_tbl, *result); @@ -876,22 +876,24 @@ TEST_F(MergeTest, Lists) TEST_F(MergeTest, NestedListsWithNulls) { - auto col1 = lcw{{lcw{lcw{1}}, lcw{lcw{3}}, lcw{lcw{5}}, lcw{lcw{7}}}, null_at(3)}; - auto col2 = lcw{{lcw{lcw{2}}, lcw{lcw{4}}, lcw{lcw{6}}, lcw{lcw{8}}}, null_at(3)}; + auto col1 = lcw{{lcw::nested({{1}}), lcw::nested({{3}}), lcw::nested({{5}}), lcw::nested({{7}})}, + null_at(3)}; + auto col2 = lcw{{lcw::nested({{2}}), lcw::nested({{4}}), lcw::nested({{6}}), lcw::nested({{8}})}, + null_at(3)}; auto tbl1 = cudf::table_view{{col1}}; auto tbl2 = cudf::table_view{{col2}}; auto result = cudf::merge({tbl1, tbl2}, {0}, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); - auto expected_col = lcw{{lcw{lcw{1}}, - lcw{lcw{2}}, - lcw{lcw{3}}, - lcw{lcw{4}}, - lcw{lcw{5}}, - lcw{lcw{6}}, - lcw{lcw{7}}, - lcw{lcw{8}}}, + auto expected_col = lcw{{lcw::nested({{1}}), + lcw::nested({{2}}), + lcw::nested({{3}}), + lcw::nested({{4}}), + lcw::nested({{5}}), + lcw::nested({{6}}), + lcw::nested({{7}}), + lcw::nested({{8}})}, nulls_at({6, 7})}; auto expected_tbl = cudf::table_view{{expected_col}}; diff --git a/cpp/tests/reductions/collect_ops_tests.cpp b/cpp/tests/reductions/collect_ops_tests.cpp index e0aad1db4e58..a60b7ad8e1a9 100644 --- a/cpp/tests/reductions/collect_ops_tests.cpp +++ b/cpp/tests/reductions/collect_ops_tests.cpp @@ -126,13 +126,13 @@ TYPED_TEST(CollectTestFixedWidth, MergeLists) // test with nulls auto const lists2 = lists_col{{ - lists_col{1, 2, 3}, - lists_col{}, - lists_col{{0, 4, 0, 5}, cudf::test::iterators::nulls_at({0, 2})}, - lists_col{{0, 0, 0}, cudf::test::iterators::all_nulls()}, - lists_col{6}, - lists_col{-1, -1}, // null_list - lists_col{7, 8, 9}, + {1, 2, 3}, + {}, + {{0, 4, 0, 5}, cudf::test::iterators::nulls_at({0, 2})}, + {{0, 0, 0}, cudf::test::iterators::all_nulls()}, + {6}, + {-1, -1}, // null_list + {7, 8, 9}, }, cudf::test::iterators::null_at(5)}; auto const expected2 = fw_wrapper{{1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 7, 8, 9}, @@ -157,13 +157,13 @@ TYPED_TEST(CollectTestFixedWidth, MergeSets) // test with null_equal auto const lists2 = lists_col{{ - lists_col{1, 2, 3}, - lists_col{}, - lists_col{{0, 4, 0, 5}, cudf::test::iterators::nulls_at({0, 2})}, - lists_col{{0, 0, 0}, cudf::test::iterators::all_nulls()}, - lists_col{5}, - lists_col{-1, -1}, // null_list - lists_col{1, 3, 5}, + {1, 2, 3}, + {}, + {{0, 4, 0, 5}, cudf::test::iterators::nulls_at({0, 2})}, + {{0, 0, 0}, cudf::test::iterators::all_nulls()}, + {5}, + {-1, -1}, // null_list + {1, 3, 5}, }, cudf::test::iterators::null_at(5)}; auto const expected2 = fw_wrapper{{1, 2, 3, 4, 5, 0}, {1, 1, 1, 1, 1, 0}}; @@ -231,11 +231,11 @@ TEST_F(CollectTest, MergeSetsWithNaN) using lists_col = cudf::test::lists_column_wrapper; auto const col = lists_col{ - lists_col{1.0f, -2.3e-5f, NAN}, - lists_col{}, - lists_col{{-2.3e-5f, 2.3e5f, NAN, 0.0f}, cudf::test::iterators::nulls_at({3})}, - lists_col{{0.0f, 0.0f}, cudf::test::iterators::all_nulls()}, - lists_col{-NAN}, + {1.0f, -2.3e-5f, NAN}, + {}, + {{-2.3e-5f, 2.3e5f, NAN, 0.0f}, cudf::test::iterators::nulls_at({3})}, + {{0.0f, 0.0f}, cudf::test::iterators::all_nulls()}, + {-NAN}, }; // nan unequal with null equal @@ -309,9 +309,9 @@ TEST_F(CollectTest, CollectStrings) lists_col strings{{"a"}, {}, {"a", "b"}, - lists_col{{"b", "null", "c"}, cudf::test::iterators::null_at(1)}, - lists_col{{"null", "d"}, cudf::test::iterators::null_at(0)}, - lists_col{{"null"}, cudf::test::iterators::null_at(0)}, + {{"b", "null", "c"}, cudf::test::iterators::null_at(1)}, + {{"null", "d"}, cudf::test::iterators::null_at(0)}, + {{"null"}, cudf::test::iterators::null_at(0)}, {"e"}}; // merge_lists @@ -393,7 +393,7 @@ TEST_F(CollectTest, CollectAllNullsWithLists) using namespace cudf::test::iterators; // list> - auto const input = LCW{{LCW{LCW{1, 2, 3}, LCW{4, 5, 6}}, LCW{{1, 2, 3}}}, all_nulls()}; + auto const input = LCW{{{{1, 2, 3}, {4, 5, 6}}, {{1, 2, 3}}}, all_nulls()}; auto const expected = cudf::empty_like(input); { diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index 9952f7bb4948..d1ab5b73e546 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -43,18 +43,18 @@ TEST_F(ListRankScanTest, DeepList) {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{1, 2, 3}, {}, {4, 5}, {0, 6, 0}}, {{7, 8}, {}}, - lcw{lcw{}, lcw{}, lcw{}}, - lcw{lcw{}}, - lcw{lcw{}}, - lcw{lcw{}}, - lcw{lcw{}, lcw{}, lcw{}}, - lcw{lcw{}, lcw{}, lcw{}}, - {lcw{10}}, - {lcw{10}}, + {{}, {}, {}}, + lcw::nested({{}}), + lcw::nested({{}}), + lcw::nested({{}}), + {{}, {}, {}}, + {{}, {}, {}}, + lcw::nested({{10}}), + lcw::nested({{10}}), {{13, 14}, {15}}, {{13, 14}, {16}}, - lcw{}, - lcw{lcw{}}, + {}, + lcw::nested({{}}), }; { // Non-sliced diff --git a/cpp/tests/reductions/reduction_tests.cpp b/cpp/tests/reductions/reduction_tests.cpp index b951cb5d91df..6b1261e26dd2 100644 --- a/cpp/tests/reductions/reduction_tests.cpp +++ b/cpp/tests/reductions/reduction_tests.cpp @@ -3279,10 +3279,10 @@ TEST_F(ListReductionTest, NestedListReductionNthElement) using LCW = cudf::test::lists_column_wrapper; // test without nulls - auto validity = std::vector{true, false, false, true, true}; - auto nested_list = LCW( - {{LCW{}, LCW{2, 3, 4}}, {}, {LCW{5}, LCW{6}, LCW{7, 8}}, {LCW{9, 10}}, {LCW{11}, LCW{12, 13}}}, - validity.begin()); + auto validity = std::vector{true, false, false, true, true}; + auto nested_list = + LCW({{{}, {2, 3, 4}}, {}, {{5}, {6}, {7, 8}}, LCW::nested({{9, 10}}), {{11}, {12, 13}}}, + validity.begin()); this->reduction_test( nested_list, LCW{{}, {2, 3, 4}}, // expected_value, @@ -3429,14 +3429,14 @@ TEST_F(ListReductionTest, ReductionMinMaxWithNulls) using cudf::test::iterators::nulls_at; constexpr int null{0}; - auto const input = LISTS_CW{{LISTS_CW{3, 4}, - LISTS_CW{1, 2}, - LISTS_CW{{1, null}, null_at(1)}, - LISTS_CW{} /*null*/, - LISTS_CW{5, 6, 7}, - LISTS_CW{1, 8}, - LISTS_CW{{9, null}, null_at(1)}, - LISTS_CW{} /*null*/}, + auto const input = LISTS_CW{{{3, 4}, + {1, 2}, + {{1, null}, null_at(1)}, + {} /*null*/, + {5, 6, 7}, + {1, 8}, + {{9, null}, null_at(1)}, + {} /*null*/}, nulls_at({3, 7})}; this->reduction_test(input, INTS_CW{{1, null}, null_at(1)}, @@ -3553,7 +3553,7 @@ TEST_F(StructReductionTest, NestedStructReductionNthElement) auto result_child0 = ICW{0}; auto result_col0 = SCW({result_child0}, std::vector{false}); auto result_col1 = ICW{{1}, {true}}; - auto result_col2 = LCW({LCW{}}, std::vector{true}.begin()); + auto result_col2 = LCW({{}}, std::vector{true}.begin()); // test without nulls this->reduction_test( struct_col1, @@ -3566,7 +3566,7 @@ TEST_F(StructReductionTest, NestedStructReductionNthElement) result_child0 = ICW{0}; result_col0 = SCW({result_child0}, std::vector{false}); result_col1 = ICW{{0}, {false}}; - result_col2 = LCW({LCW{3}}, std::vector{false}.begin()); + result_col2 = LCW({{3}}, std::vector{false}.begin()); this->reduction_test( struct_col1, cudf::table_view{{result_col0, result_col1, result_col2}}, // expected_value, @@ -3578,7 +3578,7 @@ TEST_F(StructReductionTest, NestedStructReductionNthElement) result_child0 = ICW{0}; result_col0 = SCW({result_child0}, std::vector{true}); result_col1 = ICW{{4}, {true}}; - result_col2 = LCW({LCW{4}}, std::vector{true}.begin()); + result_col2 = LCW({{4}}, std::vector{true}.begin()); this->reduction_test( struct_col1, cudf::table_view{{result_col0, result_col1, result_col2}}, // expected_value, diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 39c4332a18bd..dfe198cb5487 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -417,12 +417,10 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InterleaveOneColumnWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col = ListsCol{{ListsCol{{1, 2, null}, null_at(2)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 3, 4, 4, 4, 4}, null_at(0)}, - ListsCol{5, 6}}, - null_at(1)} - .release(); + auto const col = + ListsCol{{{{1, 2, null}, null_at(2)}, {} /*NULL*/, {{null, 3, 4, 4, 4, 4}, null_at(0)}, {5, 6}}, + null_at(1)} + .release(); auto const results = cudf::interleave_columns(TView{{col->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *results, verbosity); } @@ -440,19 +438,16 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputNoNull) TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsNoNull) { - auto const col1 = StrListsCol{StrListsCol{"Tomato", "Apple"}, - StrListsCol{"Banana", "Kiwi", "Cherry"}, - StrListsCol{"Coconut"}} - .release(); - auto const col2 = - StrListsCol{StrListsCol{"Orange"}, StrListsCol{"Lemon", "Peach"}, StrListsCol{}}.release(); + auto const col1 = + StrListsCol{{"Tomato", "Apple"}, {"Banana", "Kiwi", "Cherry"}, {"Coconut"}}.release(); + auto const col2 = StrListsCol{{"Orange"}, {"Lemon", "Peach"}, {}}.release(); auto const expected = StrListsCol{ - StrListsCol{"Tomato", "Apple"}, - StrListsCol{"Orange"}, - StrListsCol{"Banana", "Kiwi", "Cherry"}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{"Coconut"}, - StrListsCol{}}.release(); + {"Tomato", "Apple"}, + {"Orange"}, + {"Banana", "Kiwi", "Cherry"}, + {"Lemon", "Peach"}, + {"Coconut"}, + {}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -461,48 +456,48 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1 = ListsCol{{ListsCol{{1, null, 3, 4}, null_at(1)}, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{} /*NULL*/, - ListsCol{{1, 2, null, 4}, null_at(2)}, - ListsCol{{1, 2, 3, null}, null_at(3)}}, + auto const col1 = ListsCol{{{{1, null, 3, 4}, null_at(1)}, + {{null, 2, 3, 4}, null_at(0)}, + {{null, 2, 3, 4}, null_at(0)}, + {} /*NULL*/, + {{1, 2, null, 4}, null_at(2)}, + {{1, 2, 3, null}, null_at(3)}}, null_at(3)} .release(); - auto const col2 = ListsCol{{ListsCol{{10, 11, 12, null}, null_at(3)}, - ListsCol{{13, 14, 15, 16, 17, null}, null_at(5)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 18}, null_at(0)}, - ListsCol{{19, 20, null}, null_at(2)}, - ListsCol{{null}, null_at(0)}}, + auto const col2 = ListsCol{{{{10, 11, 12, null}, null_at(3)}, + {{13, 14, 15, 16, 17, null}, null_at(5)}, + {} /*NULL*/, + {{null, 18}, null_at(0)}, + {{19, 20, null}, null_at(2)}, + {{null}, null_at(0)}}, null_at(2)} .release(); - auto const col3 = ListsCol{{ListsCol{} /*NULL*/, - ListsCol{{20, null}, null_at(1)}, - ListsCol{{null, 21, null, null}, nulls_at({0, 2, 3})}, - ListsCol{}, - ListsCol{22, 23, 24, 25}, - ListsCol{{null, null, null, null, null}, all_nulls()}}, + auto const col3 = ListsCol{{{} /*NULL*/, + {{20, null}, null_at(1)}, + {{null, 21, null, null}, nulls_at({0, 2, 3})}, + {}, + {22, 23, 24, 25}, + {{null, null, null, null, null}, all_nulls()}}, null_at(0)} .release(); - auto const expected = ListsCol{{ListsCol{{1, null, 3, 4}, null_at(1)}, - ListsCol{{10, 11, 12, null}, null_at(3)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{{13, 14, 15, 16, 17, null}, null_at(5)}, - ListsCol{{20, null}, null_at(1)}, - ListsCol{{null, 2, 3, 4}, null_at(0)}, - ListsCol{} /*NULL*/, - ListsCol{{null, 21, null, null}, nulls_at({0, 2, 3})}, - ListsCol{} /*NULL*/, - ListsCol{{null, 18}, null_at(0)}, - ListsCol{}, - ListsCol{{1, 2, null, 4}, null_at(2)}, - ListsCol{{19, 20, null}, null_at(2)}, - ListsCol{22, 23, 24, 25}, - ListsCol{{1, 2, 3, null}, null_at(3)}, - ListsCol{{null}, null_at(0)}, - ListsCol{{null, null, null, null, null}, all_nulls()}}, + auto const expected = ListsCol{{{{1, null, 3, 4}, null_at(1)}, + {{10, 11, 12, null}, null_at(3)}, + {} /*NULL*/, + {{null, 2, 3, 4}, null_at(0)}, + {{13, 14, 15, 16, 17, null}, null_at(5)}, + {{20, null}, null_at(1)}, + {{null, 2, 3, 4}, null_at(0)}, + {} /*NULL*/, + {{null, 21, null, null}, nulls_at({0, 2, 3})}, + {} /*NULL*/, + {{null, 18}, null_at(0)}, + {}, + {{1, 2, null, 4}, null_at(2)}, + {{19, 20, null}, null_at(2)}, + {22, 23, 24, 25}, + {{1, 2, 3, null}, null_at(3)}, + {{null}, null_at(0)}, + {{null, null, null, null, null}, all_nulls()}}, nulls_at({2, 7, 9})} .release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view(), col3->view()}}); @@ -515,9 +510,9 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNullableChild) auto const col1 = ListsCol{{1, 2}, {3, 4}}.release(); auto const col2 = ListsCol{{5, 6}, {7, 8}}.release(); - auto const col3 = ListsCol{{9, 10}, ListsCol{{null, 12}, null_at(0)}}.release(); + auto const col3 = ListsCol{{9, 10}, {{null, 12}, null_at(0)}}.release(); auto const expected = - ListsCol{{1, 2}, {5, 6}, {9, 10}, {3, 4}, {7, 8}, ListsCol{{null, 12}, null_at(0)}}.release(); + ListsCol{{1, 2}, {5, 6}, {9, 10}, {3, 4}, {7, 8}, {{null, 12}, null_at(0)}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view(), col3->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -525,29 +520,25 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SimpleInputWithNullableChild) TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNulls) { auto const col1 = - StrListsCol{ - StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}} + StrListsCol{{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}} .release(); auto const col2 = - StrListsCol{ - {StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, - nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ - null_at(2)} + StrListsCol{{{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ + null_at(2)} .release(); auto const expected = - StrListsCol{ - {StrListsCol{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{"Coconut"}, - StrListsCol{}}, /*NULL*/ - null_at(5)} + StrListsCol{{{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, + {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, + {"Lemon", "Peach"}, + {"Coconut"}, + {}}, /*NULL*/ + null_at(5)} .release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -555,26 +546,24 @@ TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNulls) TEST_F(ListsColumnsInterleaveTest, SimpleInputStringsColumnsWithNullableChild) { - auto const col1 = StrListsCol{StrListsCol{"Tomato", "Bear", "Apple"}, - StrListsCol{"Banana", "Pig", "Kiwi", "Cherry", "Whale"}, - StrListsCol{"Coconut"}} - .release(); - auto const col2 = StrListsCol{ - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, + auto const col1 = StrListsCol{ - {"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, - all_nulls()}}.release(); + {"Tomato", "Bear", "Apple"}, {"Banana", "Pig", "Kiwi", "Cherry", "Whale"}, {"Coconut"}} + .release(); + auto const col2 = StrListsCol{ + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, + all_nulls()}}.release(); auto const expected = StrListsCol{ - StrListsCol{"Tomato", "Bear", "Apple"}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Banana", "Pig", "Kiwi", "Cherry", "Whale"}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{"Coconut"}, - StrListsCol{ - {"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, - all_nulls()}}.release(); + {"Tomato", "Bear", "Apple"}, + {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Banana", "Pig", "Kiwi", "Cherry", "Whale"}, + {"Lemon", "Peach"}, + {"Coconut"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, + all_nulls()}}.release(); auto const results = cudf::interleave_columns(TView{{col1->view(), col2->view()}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -588,18 +577,18 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNoNull) auto const col2 = cudf::slice(col->view(), {1, 4})[0]; auto const col3 = cudf::slice(col->view(), {2, 5})[0]; auto const col4 = cudf::slice(col->view(), {3, 6})[0]; - auto const expected = ListsCol{ListsCol{1, 2, 3}, - ListsCol{2, 3}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{2, 3}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{}, - ListsCol{7}} + auto const expected = ListsCol{{1, 2, 3}, + {2, 3}, + {3, 4, 5, 6}, + {5, 6}, + {2, 3}, + {3, 4, 5, 6}, + {5, 6}, + {}, + {3, 4, 5, 6}, + {5, 6}, + {}, + {7}} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -609,13 +598,13 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col = ListsCol{{ListsCol{{null, 2, 3}, null_at(0)}, - ListsCol{2, 3}, /*NULL*/ - ListsCol{{3, null, 5, 6}, null_at(1)}, - ListsCol{5, 6}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{7}, - ListsCol{8, 9, 10}}, + auto const col = ListsCol{{{{null, 2, 3}, null_at(0)}, + {2, 3}, /*NULL*/ + {{3, null, 5, 6}, null_at(1)}, + {5, 6}, /*NULL*/ + {}, /*NULL*/ + {7}, + {8, 9, 10}}, nulls_at({1, 3, 4})} .release(); auto const col1 = cudf::slice(col->view(), {0, 3})[0]; @@ -623,21 +612,21 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputWithNulls) auto const col3 = cudf::slice(col->view(), {2, 5})[0]; auto const col4 = cudf::slice(col->view(), {3, 6})[0]; auto const col5 = cudf::slice(col->view(), {4, 7})[0]; - auto const expected = ListsCol{{ListsCol{{null, 2, 3}, null_at(0)}, - ListsCol{}, /*NULL*/ - ListsCol{{3, null, 5, 6}, null_at(1)}, - ListsCol{}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{{3, null, 5, 6}, null_at(1)}, - ListsCol{}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{7}, - ListsCol{{3, null, 5, 6}, null_at(1)}, - ListsCol{}, /*NULL*/ - ListsCol{}, /*NULL*/ - ListsCol{7}, - ListsCol{8, 9, 10}}, + auto const expected = ListsCol{{{{null, 2, 3}, null_at(0)}, + {}, /*NULL*/ + {{3, null, 5, 6}, null_at(1)}, + {}, /*NULL*/ + {}, /*NULL*/ + {}, /*NULL*/ + {{3, null, 5, 6}, null_at(1)}, + {}, /*NULL*/ + {}, /*NULL*/ + {7}, + {{3, null, 5, 6}, null_at(1)}, + {}, /*NULL*/ + {}, /*NULL*/ + {7}, + {8, 9, 10}}, nulls_at({1, 3, 4, 5, 7, 8, 11, 12})} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4, col5}}); @@ -649,23 +638,23 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedColumnsInputNullableChild) using ListsCol = cudf::test::lists_column_wrapper; auto const col = - ListsCol{{1, 2, 3}, ListsCol{{null, 3}, null_at(0)}, {3, 4, 5, 6}, {5, 6}, {}, {7}}.release(); + ListsCol{{1, 2, 3}, {{null, 3}, null_at(0)}, {3, 4, 5, 6}, {5, 6}, {}, {7}}.release(); auto const col1 = cudf::slice(col->view(), {0, 3})[0]; auto const col2 = cudf::slice(col->view(), {1, 4})[0]; auto const col3 = cudf::slice(col->view(), {2, 5})[0]; auto const col4 = cudf::slice(col->view(), {3, 6})[0]; - auto const expected = ListsCol{ListsCol{1, 2, 3}, - ListsCol{{null, 3}, null_at(0)}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{{null, 3}, null_at(0)}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{}, - ListsCol{3, 4, 5, 6}, - ListsCol{5, 6}, - ListsCol{}, - ListsCol{7}} + auto const expected = ListsCol{{1, 2, 3}, + {{null, 3}, null_at(0)}, + {3, 4, 5, 6}, + {5, 6}, + {{null, 3}, null_at(0)}, + {3, 4, 5, 6}, + {5, 6}, + {}, + {3, 4, 5, 6}, + {5, 6}, + {}, + {7}} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); @@ -675,21 +664,17 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InputListsOfListsNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1 = ListsCol{ListsCol{ListsCol{1, 2, 3}, ListsCol{4, 5, 6}}, - ListsCol{ListsCol{7, 8}, ListsCol{9, 10}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15}, ListsCol{16, 17}}}; - auto const col2 = - ListsCol{ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15, 16}}, - ListsCol{ListsCol{17, 18}, ListsCol{19, 110}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}}; - auto const expected = - ListsCol{ListsCol{ListsCol{1, 2, 3}, ListsCol{4, 5, 6}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15, 16}}, - ListsCol{ListsCol{7, 8}, ListsCol{9, 10}}, - ListsCol{ListsCol{17, 18}, ListsCol{19, 110}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15}, ListsCol{16, 17}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}} - .release(); + auto const col1 = + ListsCol{{{1, 2, 3}, {4, 5, 6}}, {{7, 8}, {9, 10}}, {{11, 12, 13}, {14, 15}, {16, 17}}}; + auto const col2 = ListsCol{ + {{11, 12, 13}, {14, 15, 16}}, {{17, 18}, {19, 110}}, {{111, 112, 13}, {114, 115}, {116, 117}}}; + auto const expected = ListsCol{{{1, 2, 3}, {4, 5, 6}}, + {{11, 12, 13}, {14, 15, 16}}, + {{7, 8}, {9, 10}}, + {{17, 18}, {19, 110}}, + {{11, 12, 13}, {14, 15}, {16, 17}}, + {{111, 112, 13}, {114, 115}, {116, 117}}} + .release(); auto const results = cudf::interleave_columns(TView{{col1, col2}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -698,24 +683,19 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, InputListsOfListsWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1 = ListsCol{ - ListsCol{ListsCol{{null, 2, 3}, null_at(0)}, ListsCol{{4, null, null}, nulls_at({1, 2})}}, - ListsCol{{ListsCol{7, 8}, ListsCol{9, 10}, ListsCol{null, null, null} /*NULL*/}, null_at(2)}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{{14, null}, null_at(1)}, ListsCol{16, 17}}}; - auto const col2 = - ListsCol{ListsCol{{ListsCol{11, 12, 13}, ListsCol{null, null} /*NULL*/}, null_at(1)}, - ListsCol{ListsCol{17, 18}, ListsCol{{19, 110, null}, null_at(2)}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}}; - auto const expected = ListsCol{ - ListsCol{ListsCol{{null, 2, 3}, null_at(0)}, ListsCol{{4, null, null}, nulls_at({1, 2})}}, - ListsCol{{ListsCol{11, 12, 13}, ListsCol{null, null} /*NULL*/}, null_at(1)}, - ListsCol{{ListsCol{7, 8}, ListsCol{9, 10}, ListsCol{null, null, null} /*NULL*/}, null_at(2)}, - ListsCol{ListsCol{17, 18}, ListsCol{{19, 110, null}, null_at(2)}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{{14, null}, null_at(1)}, ListsCol{16, 17}}, - ListsCol{ - ListsCol{111, 112, 13}, - ListsCol{114, 115}, - ListsCol{116, 117}}}.release(); + auto const col1 = ListsCol{{{{null, 2, 3}, null_at(0)}, {{4, null, null}, nulls_at({1, 2})}}, + {{{7, 8}, {9, 10}, {null, null, null} /*NULL*/}, null_at(2)}, + {{11, 12, 13}, {{14, null}, null_at(1)}, {16, 17}}}; + auto const col2 = ListsCol{{{{11, 12, 13}, {null, null} /*NULL*/}, null_at(1)}, + {{17, 18}, {{19, 110, null}, null_at(2)}}, + {{111, 112, 13}, {114, 115}, {116, 117}}}; + auto const expected = ListsCol{{{{null, 2, 3}, null_at(0)}, {{4, null, null}, nulls_at({1, 2})}}, + {{{11, 12, 13}, {null, null} /*NULL*/}, null_at(1)}, + {{{7, 8}, {9, 10}, {null, null, null} /*NULL*/}, null_at(2)}, + {{17, 18}, {{19, 110, null}, null_at(2)}}, + {{11, 12, 13}, {{14, null}, null_at(1)}, {16, 17}}, + {{111, 112, 13}, {114, 115}, {116, 117}}} + .release(); auto const results = cudf::interleave_columns(TView{{col1, col2}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -725,34 +705,33 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedInputListsOfListsNoNull) using ListsCol = cudf::test::lists_column_wrapper; auto const col1_original = ListsCol{ - ListsCol{ListsCol{11, 11, 11}, ListsCol{22}, ListsCol{33, 33, 33}}, // don't care - ListsCol{ListsCol{11, 11, 11}, ListsCol{22}, ListsCol{33, 33, 33}}, // don't care + {{11, 11, 11}, {22}, {33, 33, 33}}, // don't care + {{11, 11, 11}, {22}, {33, 33, 33}}, // don't care // - ListsCol{ListsCol{1, 2, 3}, ListsCol{4, 5, 6}}, - ListsCol{ListsCol{7, 8}, ListsCol{9, 10}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15}, ListsCol{16, 17}}, + {{1, 2, 3}, {4, 5, 6}}, + {{7, 8}, {9, 10}}, + {{11, 12, 13}, {14, 15}, {16, 17}}, // - ListsCol{ListsCol{11, 11, 11}, ListsCol{22}, ListsCol{33, 33, 33}}, // don't care - ListsCol{ListsCol{11, 11, 11}, ListsCol{22}, ListsCol{33, 33, 33}} // don't care + {{11, 11, 11}, {22}, {33, 33, 33}}, // don't care + {{11, 11, 11}, {22}, {33, 33, 33}} // don't care }; auto const col2_original = ListsCol{ - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15, 16}}, - ListsCol{ListsCol{17, 18}, ListsCol{19, 110}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}, + {{11, 12, 13}, {14, 15, 16}}, + {{17, 18}, {19, 110}}, + {{111, 112, 13}, {114, 115}, {116, 117}}, // - ListsCol{ListsCol{11, 11, 11}, ListsCol{22}, ListsCol{33, 33, 33}} // don't care + {{11, 11, 11}, {22}, {33, 33, 33}} // don't care }; - auto const col1 = cudf::slice(col1_original, {2, 5})[0]; - auto const col2 = cudf::slice(col2_original, {0, 3})[0]; - auto const expected = - ListsCol{ListsCol{ListsCol{1, 2, 3}, ListsCol{4, 5, 6}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15, 16}}, - ListsCol{ListsCol{7, 8}, ListsCol{9, 10}}, - ListsCol{ListsCol{17, 18}, ListsCol{19, 110}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{14, 15}, ListsCol{16, 17}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}} - .release(); + auto const col1 = cudf::slice(col1_original, {2, 5})[0]; + auto const col2 = cudf::slice(col2_original, {0, 3})[0]; + auto const expected = ListsCol{{{1, 2, 3}, {4, 5, 6}}, + {{11, 12, 13}, {14, 15, 16}}, + {{7, 8}, {9, 10}}, + {{17, 18}, {19, 110}}, + {{11, 12, 13}, {14, 15}, {16, 17}}, + {{111, 112, 13}, {114, 115}, {116, 117}}} + .release(); auto const results = cudf::interleave_columns(TView{{col1, col2}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -761,53 +740,43 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedInputListsOfListsWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto const col1_original = ListsCol{ - { - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - // - ListsCol{ListsCol{{null, 2, 3}, null_at(0)}, ListsCol{{4, null, null}, nulls_at({1, 2})}}, - ListsCol{{ListsCol{7, 8}, ListsCol{9, 10}, ListsCol{null, null, null} /*NULL*/}, null_at(2)}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{{14, null}, null_at(1)}, ListsCol{16, 17}}, - // - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}} // don't care - }, - nulls_at({0, 2, 3})}; + auto const col1_original = + ListsCol{{ + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + // + {{{null, 2, 3}, null_at(0)}, {{4, null, null}, nulls_at({1, 2})}}, + {{{7, 8}, {9, 10}, {null, null, null} /*NULL*/}, null_at(2)}, + {{11, 12, 13}, {{14, null}, null_at(1)}, {16, 17}}, + // + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}} // don't care + }, + nulls_at({0, 2, 3})}; auto const col2_original = ListsCol{ - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - // - ListsCol{{ListsCol{11, 12, 13}, ListsCol{null, null} /*NULL*/}, null_at(1)}, - ListsCol{ListsCol{17, 18}, ListsCol{{19, 110, null}, null_at(2)}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}, - ListsCol{ListsCol{{null, 11}, null_at(0)}, - // - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}}, // don't care - ListsCol{ListsCol{{null, 11}, null_at(0)}, - ListsCol{{22, null, null}, nulls_at({1, 2})}} // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + // + {{{11, 12, 13}, {null, null} /*NULL*/}, null_at(1)}, + {{17, 18}, {{19, 110, null}, null_at(2)}}, + {{111, 112, 13}, {114, 115}, {116, 117}}, + {{{null, 11}, null_at(0)}, + // + {{22, null, null}, nulls_at({1, 2})}}, // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}}, // don't care + {{{null, 11}, null_at(0)}, {{22, null, null}, nulls_at({1, 2})}} // don't care }; - auto const col1 = cudf::slice(col1_original, {3, 6})[0]; - auto const col2 = cudf::slice(col2_original, {2, 5})[0]; - auto const expected = - ListsCol{ - {ListsCol{ListsCol{{null, 2, 3}, null_at(0)}, ListsCol{{4, null, null}, nulls_at({1, 2})}}, - ListsCol{{ListsCol{11, 12, 13}, ListsCol{null, null} /*NULL*/}, null_at(1)}, - ListsCol{{ListsCol{7, 8}, ListsCol{9, 10}, ListsCol{null, null, null} /*NULL*/}, null_at(2)}, - ListsCol{ListsCol{17, 18}, ListsCol{{19, 110, null}, null_at(2)}}, - ListsCol{ListsCol{11, 12, 13}, ListsCol{{14, null}, null_at(1)}, ListsCol{16, 17}}, - ListsCol{ListsCol{111, 112, 13}, ListsCol{114, 115}, ListsCol{116, 117}}}, - null_at(0)} - .release(); + auto const col1 = cudf::slice(col1_original, {3, 6})[0]; + auto const col2 = cudf::slice(col2_original, {2, 5})[0]; + auto const expected = ListsCol{{{{{null, 2, 3}, null_at(0)}, {{4, null, null}, nulls_at({1, 2})}}, + {{{11, 12, 13}, {null, null} /*NULL*/}, null_at(1)}, + {{{7, 8}, {9, 10}, {null, null, null} /*NULL*/}, null_at(2)}, + {{17, 18}, {{19, 110, null}, null_at(2)}}, + {{11, 12, 13}, {{14, null}, null_at(1)}, {16, 17}}, + {{111, 112, 13}, {114, 115}, {116, 117}}}, + null_at(0)} + .release(); auto const results = cudf::interleave_columns(TView{{col1, col2}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); } @@ -985,36 +954,32 @@ TYPED_TEST(ListsColumnsInterleaveTypedTest, SlicedInputListsOfStructsWithNulls) TEST_F(ListsColumnsInterleaveTest, SlicedStringsColumnsInputWithNulls) { auto const col = - StrListsCol{ - {StrListsCol{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, - nulls_at({1, 4})}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, - nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ - null_at(5)} + StrListsCol{{{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}, + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {{"Deer" /*NULL*/, "Snake" /*NULL*/, "Horse" /*NULL*/}, all_nulls()}}, /*NULL*/ + null_at(5)} .release(); auto const col1 = cudf::slice(col->view(), {0, 3})[0]; auto const col2 = cudf::slice(col->view(), {1, 4})[0]; auto const col3 = cudf::slice(col->view(), {2, 5})[0]; auto const col4 = cudf::slice(col->view(), {3, 6})[0]; auto const expected = - StrListsCol{ - {StrListsCol{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{"Coconut"}, - StrListsCol{{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, - StrListsCol{"Lemon", "Peach"}, - StrListsCol{}}, /*NULL*/ - null_at(11)} + StrListsCol{{{{"Tomato", "" /*NULL*/, "Apple"}, null_at(1)}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}, + {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, + {{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, + {"Coconut"}, + {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {"Coconut"}, + {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {}}, /*NULL*/ + null_at(11)} .release(); auto const results = cudf::interleave_columns(TView{{col1, col2, col3, col4}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*expected, *results, verbosity); diff --git a/cpp/tests/search/search_list_test.cpp b/cpp/tests/search/search_list_test.cpp index f45027ba52a4..40cec6d3383d 100644 --- a/cpp/tests/search/search_list_test.cpp +++ b/cpp/tests/search/search_list_test.cpp @@ -138,16 +138,9 @@ TYPED_TEST(TypedListsContainsTestScalarNeedle, SimpleInputWithNulls) // Test with nulls at the children level. { - auto const haystack = lists_col{{lists_col{1, 2}, - lists_col{1}, - lists_col{{1, null}, null_at(1)}, - lists_col{} /*NULL*/, - lists_col{1, 3}, - lists_col{1, 4}, - lists_col{4}, - lists_col{} /*NULL*/, - lists_col{1, 1}}, - nulls_at({3, 7})}; + auto const haystack = lists_col{ + {{1, 2}, {1}, {{1, null}, null_at(1)}, {} /*NULL*/, {1, 3}, {1, 4}, {4}, {} /*NULL*/, {1, 1}}, + nulls_at({3, 7})}; auto const needle1 = [] { auto child = tdata_col{{1, null}, null_at(1)}; @@ -175,7 +168,7 @@ TYPED_TEST(TypedListsContainsTestScalarNeedle, SlicedInputHavingNulls) auto const haystack_original = lists_col{{{0, 0}, {0} /*NULL*/, - lists_col{{1, null}, null_at(1)}, + {{1, null}, null_at(1)}, {1}, {} /*NULL*/, {1, 3}, @@ -254,7 +247,7 @@ TYPED_TEST(TypedListContainsTestColumnNeedles, SlicedInputHavingNulls) auto const haystack_original = lists_col{{{0, 0}, {0} /*NULL*/, - lists_col{{1, null}, null_at(1)}, + {{1, null}, null_at(1)}, {1}, {} /*NULL*/, {1, 3}, @@ -267,7 +260,7 @@ TYPED_TEST(TypedListContainsTestColumnNeedles, SlicedInputHavingNulls) auto const needles_original = lists_col{{{0, 0}, {0} /*NULL*/, - lists_col{{1, null}, null_at(1)}, + {{1, null}, null_at(1)}, {1}, {} /*NULL*/, {1, 3, 1}, @@ -350,13 +343,13 @@ TEST_F(ListBinarySearch, ListWithNulls) { using lcw = cudf::test::lists_column_wrapper; auto const haystack = lcw{ - lcw{-3.45967821e+12}, // 0 - lcw{-3.6912186e-32}, // 1 - lcw{9.721175}, // 2 + {-3.45967821e+12}, // 0 + {-3.6912186e-32}, // 1 + {9.721175}, // 2 }; auto const needles = lcw{ - lcw{{null, 4.22671e+32}, null_at(0)}, + {{null, 4.22671e+32}, null_at(0)}, }; auto const expected = int32s_col{0}; @@ -372,23 +365,23 @@ TEST_F(ListBinarySearch, ListWithNulls) { using lcw = cudf::test::lists_column_wrapper; auto const col1 = lcw{ - lcw{{null}, null_at(0)}, // 0 - lcw{-80}, // 1 - lcw{-17}, // 2 + {{null}, null_at(0)}, // 0 + {-80}, // 1 + {-17}, // 2 }; auto const col2 = lcw{ - lcw{27}, // 0 - lcw{{null}, null_at(0)}, // 1 - lcw{}, // 2 + {27}, // 0 + {{null}, null_at(0)}, // 1 + {}, // 2 }; auto const val1 = lcw{ - lcw{87}, + {87}, }; auto const val2 = lcw{ - lcw{}, + {}, }; cudf::table_view input{{col1, col2}}; diff --git a/cpp/tests/sort/is_sorted_tests.cpp b/cpp/tests/sort/is_sorted_tests.cpp index 9bf906ce0878..197eced80c6b 100644 --- a/cpp/tests/sort/is_sorted_tests.cpp +++ b/cpp/tests/sort/is_sorted_tests.cpp @@ -233,23 +233,23 @@ template lcw ascending() requires(std::is_same_v) { - return lcw{lcw{lcw{lcw{0}}, lcw{lcw{0}}, lcw{lcw{0}}}, - lcw{lcw{lcw{0}, lcw{0}, lcw{0}}}, - lcw{lcw{lcw{0, 0}}, lcw{lcw{0, 0, 0, 0, 0, 0, 0, 0}}, lcw{lcw{0}}}, - lcw{lcw{lcw{0, 0, 0}}}, - lcw{lcw{lcw{0, 0, 0}}, lcw{lcw{0}}, lcw{lcw{0}}}}; + return lcw{{{{0}}, {{0}}, {{0}}}, + {{{0}, {0}, {0}}}, + {{{0, 0}}, {{0, 0, 0, 0, 0, 0, 0, 0}}, {{0}}}, + {{{0, 0, 0}}}, + {{{0, 0, 0}}, {{0}}, {{0}}}}; } template lcw descending() requires(std::is_same_v) { - return lcw{lcw{lcw{lcw{0, 0, 0}}, lcw{lcw{0}}, lcw{lcw{0}}}, - lcw{lcw{lcw{0, 0, 0}}}, - lcw{lcw{lcw{0, 0}}, lcw{lcw{0, 0, 0, 0, 0, 0, 0, 0}}, lcw{lcw{0}}}, + return lcw{{{{0, 0, 0}}, {{0}}, {{0}}}, + {{{0, 0, 0}}}, + {{{0, 0}}, {{0, 0, 0, 0, 0, 0, 0, 0}}, {{0}}}, - lcw{lcw{lcw{0}, lcw{0}, lcw{0}}}, - lcw{lcw{lcw{0}}, lcw{lcw{0}}, lcw{lcw{0}}}}; + {{{0}, {0}, {0}}}, + {{{0}}, {{0}}, {{0}}}}; } template <> diff --git a/cpp/tests/sort/sort_nested_types_tests.cpp b/cpp/tests/sort/sort_nested_types_tests.cpp index 56d0d82115e1..920ea41e3b91 100644 --- a/cpp/tests/sort/sort_nested_types_tests.cpp +++ b/cpp/tests/sort/sort_nested_types_tests.cpp @@ -435,7 +435,7 @@ TEST_F(NestedListTest, MultipleListsColumnsWithNulls) { // A STRUCT> column with all nulls. auto const col0 = [] { - auto child = int32s_lists{{int32s_lists{}, int32s_lists{}}, all_nulls()}; + auto child = int32s_lists{{{}, {}}, all_nulls()}; return structs_col{{child}, all_nulls()}; }(); diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index d015bf00701f..548bce6ef439 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -742,10 +742,10 @@ TYPED_TEST(Sort, WithListColumn) {{1, 2, 3}, {}, {4, 5}, {0, 6, 0}}, {{1, 2}, {3}, {4, 5}, {0, 6, 0}}, {{7, 8}, {}}, - lcw{lcw{}, lcw{}, lcw{}}, - lcw{lcw{}}, - {lcw{10}}, - lcw{}}; + {{}, {}, {}}, + lcw::nested({{}}), + lcw::nested({{10}}), + {}}; auto expect = cudf::test::fixed_width_column_wrapper{8, 6, 5, 3, 0, 1, 2, 4, 7}; auto result = cudf::sorted_order(cudf::table_view({col})); @@ -784,10 +784,10 @@ TYPED_TEST(Sort, WithNullableListColumn) {{1, 2}, {3}, {4, 5}, {0, 6, 0}}, // 3 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0})}}, // 4 {{7, 8}, {}}, // 5 - lcw{lcw{}, lcw{}, lcw{}}, // 6 - lcw{lcw{}}, // 7 - {lcw{10}}, // 8 - lcw{}, // 9 + {{}, {}, {}}, // 6 + lcw::nested({{}}), // 7 + lcw::nested({{10}}), // 8 + {}, // 9 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 10 {{1, 2}, {3}, {4, 5}, {{0, 7}, nulls_at({0})}}, // 11 }; @@ -815,8 +815,8 @@ TYPED_TEST(Sort, MoreLists) ] */ lcw col{ - lcw{lcw{{0}, nulls_at({0})}, lcw{-21827}}, // 0 - lcw{lcw{{0, 0}, nulls_at({0, 1})}} // 1 + {{{0}, nulls_at({0})}, {-21827}}, // 0 + lcw::nested({{{0, 0}, nulls_at({0, 1})}}) // 1 }; cudf::test::fixed_width_column_wrapper expected{{0, 1}}; auto result = cudf::sorted_order(cudf::table_view({col})); @@ -830,7 +830,7 @@ TYPED_TEST(Sort, MoreLists) [[1, NULL], [2, 3]] 1 ] */ - auto const col = lcw{lcw{lcw{1}, lcw{2}}, lcw{lcw{{1, 0}, nulls_at({1})}, lcw{2, 3}}}; + auto const col = lcw{{{1}, {2}}, {{{1, 0}, nulls_at({1})}, {2, 3}}}; cudf::test::fixed_width_column_wrapper expected{{0, 1}}; auto result = cudf::sorted_order(cudf::table_view({col})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); @@ -847,11 +847,11 @@ TYPED_TEST(Sort, MoreLists) [[[0, 0]], [[0, 0, 0, 0, 0, 0, 0, 0]], [[0]]] 4 ] */ - lcw col{lcw{lcw{lcw{0, 0, 0}}}, - lcw{lcw{lcw{0}, lcw{0}, lcw{0}}}, - lcw{lcw{lcw{0}}, lcw{lcw{0}}, lcw{lcw{0}}}, - lcw{lcw{lcw{0, 0, 0}}, lcw{lcw{0}}, lcw{lcw{0}}}, - lcw{lcw{lcw{0, 0}}, lcw{lcw{0, 0, 0, 0, 0, 0, 0, 0}}, lcw{lcw{0}}}}; + lcw col{{{{0, 0, 0}}}, + {{{0}, {0}, {0}}}, + {{{0}}, {{0}}, {{0}}}, + {{{0, 0, 0}}, {{0}}, {{0}}}, + {{{0, 0}}, {{0, 0, 0, 0, 0, 0, 0, 0}}, {{0}}}}; cudf::test::fixed_width_column_wrapper expected{{2, 1, 4, 0, 3}}; auto result = cudf::sorted_order(cudf::table_view({col})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *result); @@ -900,8 +900,7 @@ TYPED_TEST(Sort, MoreLists) } } { - lcw col{lcw{lcw{}, lcw{-729297378, -627961465}}, - lcw{lcw{{0}, null_at(0)}, lcw{881899016, -1415270016}}}; + lcw col{{{}, {-729297378, -627961465}}, {{{0}, null_at(0)}, {881899016, -1415270016}}}; { cudf::test::fixed_width_column_wrapper expected{{0, 1}}; @@ -925,10 +924,10 @@ TYPED_TEST(Sort, WithSlicedListColumn) {{1, 2}, {3}, {4, 5}, {0, 6, 0}}, // 2 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0})}}, // 3 {{7, 8}, {}}, // 4 - lcw{lcw{}, lcw{}, lcw{}}, // 5 - lcw{lcw{}}, // 6 - {lcw{10}}, // 7 - lcw{}, // 8 + {{}, {}, {}}, // 5 + lcw::nested({{}}), // 6 + lcw::nested({{10}}), // 7 + {}, // 8 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 9 {{1, 2}, {3}, {4, 5}, {{0, 7}, nulls_at({0})}}, // }; diff --git a/cpp/tests/sort/top_k_tests.cpp b/cpp/tests/sort/top_k_tests.cpp index 6a6141763aa3..3b30170c2ff9 100644 --- a/cpp/tests/sort/top_k_tests.cpp +++ b/cpp/tests/sort/top_k_tests.cpp @@ -137,8 +137,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // Seg0 desc top2: 30@1,20@2 ; seg2 desc top2: 50@3,45@5. auto input = cudf::test::fixed_width_column_wrapper({10, 30, 20, 50, 15, 45, 25}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 3, 3, 7}); - LCW expected({LCW{30, 20}, LCW{}, LCW{50, 45}}); - LCWO expected_order({LCWO{1, 2}, LCWO{}, LCWO{3, 5}}); + LCW expected({{30, 20}, {}, {50, 45}}); + LCWO expected_order({{1, 2}, {}, {3, 5}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -150,8 +150,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // Seg1 desc top2: 40@0,30@2. auto input = cudf::test::fixed_width_column_wrapper({40, 10, 30, 20}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0, 4}); - LCW expected({LCW{}, LCW{40, 30}}); - LCWO expected_order({LCWO{}, LCWO{0, 2}}); + LCW expected({{}, {40, 30}}); + LCWO expected_order({{}, {0, 2}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -162,8 +162,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // Trailing empty segment: offsets [0,4,4]; seg1=[4,4) is empty. auto input = cudf::test::fixed_width_column_wrapper({40, 10, 30, 20}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 4, 4}); - LCW expected({LCW{40, 30}, LCW{}}); - LCWO expected_order({LCWO{0, 2}, LCWO{}}); + LCW expected({{40, 30}, {}}); + LCWO expected_order({{0, 2}, {}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -174,8 +174,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // Consecutive interior empty segments: offsets [0,3,3,3,7]; seg1 and seg2 are both empty. auto input = cudf::test::fixed_width_column_wrapper({10, 30, 20, 50, 15, 45, 25}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 3, 3, 3, 7}); - LCW expected({LCW{30, 20}, LCW{}, LCW{}, LCW{50, 45}}); - LCWO expected_order({LCWO{1, 2}, LCWO{}, LCWO{}, LCWO{3, 5}}); + LCW expected({{30, 20}, {}, {}, {50, 45}}); + LCWO expected_order({{1, 2}, {}, {}, {3, 5}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -187,8 +187,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // seg0=[0,1) has one (({7, 3, 9, 1}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 1, 1, 4}); - LCW expected({LCW{7}, LCW{}, LCW{9, 3}}); - LCWO expected_order({LCWO{0}, LCWO{}, LCWO{2, 1}}); + LCW expected({{7}, {}, {9, 3}}); + LCWO expected_order({{0}, {}, {2, 1}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -200,8 +200,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmpty) // Seg0 asc top2: 10@0,20@2 ; seg2 asc top2: 15@4,25@6. auto input = cudf::test::fixed_width_column_wrapper({10, 30, 20, 50, 15, 45, 25}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 3, 3, 7}); - LCW expected({LCW{10, 20}, LCW{}, LCW{15, 25}}); - LCWO expected_order({LCWO{0, 2}, LCWO{}, LCWO{4, 6}}); + LCW expected({{10, 20}, {}, {15, 25}}); + LCWO expected_order({{0, 2}, {}, {4, 6}}); auto result = cudf::segmented_top_k(input, offsets, 2, cudf::order::ASCENDING); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2, cudf::order::ASCENDING); @@ -222,8 +222,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmptyWithNulls) auto input = cudf::test::fixed_width_column_wrapper( {10, 30, 20, 50, 15, 45, 25}, cudf::test::iterators::null_at(2)); auto offsets = cudf::test::fixed_width_column_wrapper({0, 3, 3, 7}); - LCW expected({LCW{30, 10}, LCW{}, LCW{50, 45}}); - LCWO expected_order({LCWO{1, 0}, LCWO{}, LCWO{3, 5}}); + LCW expected({{30, 10}, {}, {50, 45}}); + LCWO expected_order({{1, 0}, {}, {3, 5}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -244,8 +244,8 @@ TYPED_TEST(TopKTypes, TopKSegmentedEmptySliced) auto input = cudf::slice(input_full, {1, 5})[0]; auto offsets = cudf::slice(offsets_full, {1, 4})[0]; - LCW expected({LCW{40, 30}, LCW{}}); - LCWO expected_order({LCWO{0, 2}, LCWO{}}); + LCW expected({{40, 30}, {}}); + LCWO expected_order({{0, 2}, {}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); @@ -447,7 +447,7 @@ TEST_F(TopK, TopKSegmentedEmptyOrderInitcheck) // Seg0 desc top2: 30@1,20@2 ; seg2 desc top2: 50@3,45@5. auto input = cudf::test::fixed_width_column_wrapper({10, 30, 20, 50, 15, 45, 25}); auto offsets = cudf::test::fixed_width_column_wrapper({0, 3, 3, 7}); - LCWO expected_order({LCWO{1, 2}, LCWO{}, LCWO{3, 5}}); + LCWO expected_order({{1, 2}, {}, {3, 5}}); auto result = cudf::segmented_top_k_order(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_order, result->view()); } @@ -465,8 +465,8 @@ TEST_F(TopK, TopKSegmentedEmptyMultiBlock) auto input = cudf::test::fixed_width_column_wrapper(itr, itr + 300); auto offsets = cudf::test::fixed_width_column_wrapper({0, 150, 150, 300}); // offsets [0,150,150,300]; seg1=[150,150) empty. Values equal their row index. - LCW expected({LCW{149, 148}, LCW{}, LCW{299, 298}}); - LCWO expected_order({LCWO{149, 148}, LCWO{}, LCWO{299, 298}}); + LCW expected({{149, 148}, {}, {299, 298}}); + LCWO expected_order({{149, 148}, {}, {299, 298}}); auto result = cudf::segmented_top_k(input, offsets, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); result = cudf::segmented_top_k_order(input, offsets, 2); diff --git a/cpp/tests/stream_compaction/distinct_tests.cpp b/cpp/tests/stream_compaction/distinct_tests.cpp index 7514bef19cc6..5c2e4711c13c 100644 --- a/cpp/tests/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/stream_compaction/distinct_tests.cpp @@ -807,9 +807,8 @@ TEST_F(DistinctKeepFirstLastNone, ListsWithNullsUnequal) // KEEP_NONE { - auto const exp_idx_sort = int32s_col{7, 10}; - auto const exp_keys_sort = - lists_col{{lists_col{} /*NULL*/, lists_col{} /*NULL*/}, nulls_at({0, 1})}; + auto const exp_idx_sort = int32s_col{7, 10}; + auto const exp_keys_sort = lists_col{{{} /*NULL*/, {} /*NULL*/}, nulls_at({0, 1})}; auto const expected_sort = cudf::table_view{{exp_idx_sort, exp_keys_sort}}; auto const result = cudf::distinct(input, key_idx, KEEP_NONE, NULL_UNEQUAL); @@ -1160,8 +1159,7 @@ TEST_F(DistinctKeepAny, EmptyDeepList) // 2. Null // 3. Null - auto const keys = - lists_col{{lists_col{}, lists_col{}, lists_col{}, lists_col{}}, nulls_at({2, 3})}; + auto const keys = lists_col{{{}, {}, {}, {}}, nulls_at({2, 3})}; auto const idx = int32s_col{1, 1, 2, 2}; auto const input = cudf::table_view{{idx, keys}}; diff --git a/cpp/tests/stream_compaction/stable_distinct_tests.cpp b/cpp/tests/stream_compaction/stable_distinct_tests.cpp index 352503dfd169..3b8b9103c9b7 100644 --- a/cpp/tests/stream_compaction/stable_distinct_tests.cpp +++ b/cpp/tests/stream_compaction/stable_distinct_tests.cpp @@ -749,7 +749,7 @@ TEST_F(StableDistinctKeepFirstLastNone, ListsWithNullsUnequal) // KEEP_NONE { auto const exp_idx = int32s_col{7, 10}; - auto const exp_keys = lists_col{{lists_col{} /*NULL*/, lists_col{} /*NULL*/}, nulls_at({0, 1})}; + auto const exp_keys = lists_col{{{} /*NULL*/, {} /*NULL*/}, nulls_at({0, 1})}; auto const expected = cudf::table_view{{exp_idx, exp_keys}}; auto const result = cudf::stable_distinct(input, key_idx, KEEP_NONE, NULL_UNEQUAL); @@ -1096,8 +1096,7 @@ TEST_F(StableDistinctKeepAny, EmptyDeepList) // 2. Null // 3. Null - auto const keys = - lists_col{{lists_col{}, lists_col{}, lists_col{}, lists_col{}}, nulls_at({2, 3})}; + auto const keys = lists_col{{{}, {}, {}, {}}, nulls_at({2, 3})}; auto const idx = int32s_col{1, 1, 2, 2}; auto const input = cudf::table_view{{idx, keys}}; diff --git a/cpp/tests/stream_compaction/unique_tests.cpp b/cpp/tests/stream_compaction/unique_tests.cpp index e8affe90f212..631b1d43f82e 100644 --- a/cpp/tests/stream_compaction/unique_tests.cpp +++ b/cpp/tests/stream_compaction/unique_tests.cpp @@ -659,8 +659,7 @@ TEST_F(Unique, EmptyDeepListKeepAny) // 2. Null // 3. Null - auto const keys = - lists_col{{lists_col{}, lists_col{}, lists_col{}, lists_col{}}, nulls_at({2, 3})}; + auto const keys = lists_col{{{}, {}, {}, {}}, nulls_at({2, 3})}; auto const idx = int32s_col{1, 1, 2, 2}; auto const input = cudf::table_view{{idx, keys}}; diff --git a/cpp/tests/streams/lists_test.cpp b/cpp/tests/streams/lists_test.cpp index 4f6e6aefb941..c4c68164a3ea 100644 --- a/cpp/tests/streams/lists_test.cpp +++ b/cpp/tests/streams/lists_test.cpp @@ -219,10 +219,7 @@ TEST_F(ListTest, HaveOverlap) TEST_F(ListTest, Explode) { cudf::test::fixed_width_column_wrapper list_col_a{100, 200, 300}; - cudf::test::lists_column_wrapper list_col_b{ - cudf::test::lists_column_wrapper{1, 2, 7}, - cudf::test::lists_column_wrapper{5, 6}, - cudf::test::lists_column_wrapper{0, 3}}; + cudf::test::lists_column_wrapper list_col_b{{1, 2, 7}, {5, 6}, {0, 3}}; cudf::test::strings_column_wrapper list_col_c{"string0", "string1", "string2"}; cudf::table_view lists_table({list_col_a, list_col_b, list_col_c}); cudf::explode(lists_table, 1, cudf::test::get_default_stream()); @@ -231,10 +228,7 @@ TEST_F(ListTest, Explode) TEST_F(ListTest, ExplodePosition) { cudf::test::fixed_width_column_wrapper list_col_a{100, 200, 300}; - cudf::test::lists_column_wrapper list_col_b{ - cudf::test::lists_column_wrapper{1, 2, 7}, - cudf::test::lists_column_wrapper{5, 6}, - cudf::test::lists_column_wrapper{0, 3}}; + cudf::test::lists_column_wrapper list_col_b{{1, 2, 7}, {5, 6}, {0, 3}}; cudf::test::strings_column_wrapper list_col_c{"string0", "string1", "string2"}; cudf::table_view lists_table({list_col_a, list_col_b, list_col_c}); cudf::explode_position(lists_table, 1, cudf::test::get_default_stream()); @@ -245,10 +239,7 @@ TEST_F(ListTest, ExplodeOuter) constexpr auto null = 0; auto valids = cudf::test::iterators::valids_at_multiples_of(2); cudf::test::lists_column_wrapper list_col_a{ - cudf::test::lists_column_wrapper({1, null, 7}, valids), - cudf::test::lists_column_wrapper({5, null, 0, null}, valids), - cudf::test::lists_column_wrapper{}, - cudf::test::lists_column_wrapper({0, null, 8}, valids)}; + {{1, null, 7}, valids}, {{5, null, 0, null}, valids}, {}, {{0, null, 8}, valids}}; cudf::test::fixed_width_column_wrapper list_col_b{100, 200, 300, 400}; cudf::table_view lists_table({list_col_a, list_col_b}); cudf::explode_outer(lists_table, 0, cudf::test::get_default_stream()); @@ -259,10 +250,7 @@ TEST_F(ListTest, ExplodeOuterPosition) constexpr auto null = 0; auto valids = cudf::test::iterators::valids_at_multiples_of(2); cudf::test::lists_column_wrapper list_col_a{ - cudf::test::lists_column_wrapper({1, null, 7}, valids), - cudf::test::lists_column_wrapper({5, null, 0, null}, valids), - cudf::test::lists_column_wrapper{}, - cudf::test::lists_column_wrapper({0, null, 8}, valids)}; + {{1, null, 7}, valids}, {{5, null, 0, null}, valids}, {}, {{0, null, 8}, valids}}; cudf::test::fixed_width_column_wrapper list_col_b{100, 200, 300, 400}; cudf::table_view lists_table({list_col_a, list_col_b}); cudf::explode_outer_position(lists_table, 0, cudf::test::get_default_stream()); diff --git a/cpp/tests/streams/strings/combine_test.cpp b/cpp/tests/streams/strings/combine_test.cpp index 84cbdd3ec4b1..fddcfd126518 100644 --- a/cpp/tests/streams/strings/combine_test.cpp +++ b/cpp/tests/streams/strings/combine_test.cpp @@ -44,9 +44,8 @@ TEST_F(StringsCombineTest, Join) TEST_F(StringsCombineTest, JoinLists) { using STR_LISTS = cudf::test::lists_column_wrapper; - auto const input = STR_LISTS{ - STR_LISTS{"a", "bb", "ccc"}, STR_LISTS{"ddd", "efgh", "ijk"}, STR_LISTS{"zzz", "xxxxx"}}; - auto view = cudf::lists_column_view(input); + auto const input = STR_LISTS{{"a", "bb", "ccc"}, {"ddd", "efgh", "ijk"}, {"zzz", "xxxxx"}}; + auto view = cudf::lists_column_view(input); auto separators = cudf::test::strings_column_wrapper({"_", ".", " "}); auto separators_view = cudf::strings_column_view(separators); diff --git a/cpp/tests/streams/strings/convert_test.cpp b/cpp/tests/streams/strings/convert_test.cpp index 9e04289d9f0d..83d6200ccd8e 100644 --- a/cpp/tests/streams/strings/convert_test.cpp +++ b/cpp/tests/streams/strings/convert_test.cpp @@ -138,8 +138,7 @@ TEST_F(StringsConvertTest, ListsFormat) { using STR_LISTS = cudf::test::lists_column_wrapper; auto const input = - STR_LISTS{{STR_LISTS{"a", "bb", "ccc"}, STR_LISTS{}, STR_LISTS{"ddd", "ee", "f"}}, - {STR_LISTS{"gg", "hhh"}, STR_LISTS{"i", "", "", "jj"}}}; + STR_LISTS{{{"a", "bb", "ccc"}, {}, {"ddd", "ee", "f"}}, {{"gg", "hhh"}, {"i", "", "", "jj"}}}; auto view = cudf::lists_column_view(input); auto null_scalar = cudf::string_scalar("NULL", true, cudf::test::get_default_stream()); auto separators = cudf::strings_column_view(cudf::test::strings_column_wrapper()); diff --git a/cpp/tests/strings/combine/join_list_elements_tests.cpp b/cpp/tests/strings/combine/join_list_elements_tests.cpp index 339d1e2b7c0e..421a27ca773c 100644 --- a/cpp/tests/strings/combine/join_list_elements_tests.cpp +++ b/cpp/tests/strings/combine/join_list_elements_tests.cpp @@ -36,18 +36,16 @@ TEST_F(StringsListsConcatenateTest, InvalidInput) // Invalid scalar separator { - auto const string_lists = - STR_LISTS{STR_LISTS{""}, STR_LISTS{"", "", ""}, STR_LISTS{"", ""}}.release(); - auto const string_lv = cudf::lists_column_view(string_lists->view()); + auto const string_lists = STR_LISTS{{""}, {"", "", ""}, {"", ""}}.release(); + auto const string_lv = cudf::lists_column_view(string_lists->view()); EXPECT_THROW(cudf::strings::join_list_elements(string_lv, cudf::string_scalar("", false)), cudf::logic_error); } // Invalid column separators { - auto const string_lists = - STR_LISTS{STR_LISTS{""}, STR_LISTS{"", "", ""}, STR_LISTS{"", ""}}.release(); - auto const string_lv = cudf::lists_column_view(string_lists->view()); + auto const string_lists = STR_LISTS{{""}, {"", "", ""}, {"", ""}}.release(); + auto const string_lv = cudf::lists_column_view(string_lists->view()); auto const separators = STR_COL{"+++"}.release(); // size doesn't match with lists column size EXPECT_THROW(cudf::strings::join_list_elements(string_lv, separators->view()), cudf::logic_error); @@ -69,9 +67,8 @@ TEST_F(StringsListsConcatenateTest, EmptyInput) TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) { - auto const string_lists = - STR_LISTS{STR_LISTS{""}, STR_LISTS{"", "", ""}, STR_LISTS{"", ""}, STR_LISTS{}}.release(); - auto const string_lv = cudf::lists_column_view(string_lists->view()); + auto const string_lists = STR_LISTS{{""}, {"", "", ""}, {"", ""}, {}}.release(); + auto const string_lv = cudf::lists_column_view(string_lists->view()); // Empty list results in empty string { @@ -110,9 +107,7 @@ TEST_F(StringsListsConcatenateTest, ZeroSizeStringsInput) TEST_F(StringsListsConcatenateTest, ColumnHasEmptyListAndNullListInput) { auto const string_lists = - STR_LISTS{{STR_LISTS{"abc", "def", ""}, STR_LISTS{} /*NULL*/, STR_LISTS{}, STR_LISTS{"gh"}}, - null_at(1)} - .release(); + STR_LISTS{{{"abc", "def", ""}, {} /*NULL*/, {}, {"gh"}}, null_at(1)}.release(); auto const string_lv = cudf::lists_column_view(string_lists->view()); // Empty list results in empty string @@ -151,11 +146,8 @@ TEST_F(StringsListsConcatenateTest, ColumnHasEmptyListAndNullListInput) TEST_F(StringsListsConcatenateTest, AllNullsStringsInput) { - auto const string_lists = STR_LISTS{ - STR_LISTS{{""}, all_nulls()}, - STR_LISTS{{"", "", ""}, all_nulls()}, - STR_LISTS{{"", ""}, - all_nulls()}}.release(); + auto const string_lists = + STR_LISTS{{{""}, all_nulls()}, {{"", "", ""}, all_nulls()}, {{"", ""}, all_nulls()}}.release(); auto const string_lv = cudf::lists_column_view(string_lists->view()); auto const expected = STR_COL{{"", "", ""}, all_nulls()}; @@ -169,11 +161,11 @@ TEST_F(StringsListsConcatenateTest, AllNullsStringsInput) TEST_F(StringsListsConcatenateTest, ScalarSeparator) { - auto const string_lists = STR_LISTS{{STR_LISTS{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, - STR_LISTS{}, /*NULL*/ - STR_LISTS{{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, - STR_LISTS{"zzz", "xxxxx"}, - STR_LISTS{{"v", "", "", "w"}, nulls_at({1, 2})}}, + auto const string_lists = STR_LISTS{{{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, + {}, /*NULL*/ + {{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, + {"zzz", "xxxxx"}, + {{"v", "", "", "w"}, nulls_at({1, 2})}}, null_at(1)} .release(); auto const string_lv = cudf::lists_column_view(string_lists->view()); @@ -214,17 +206,17 @@ TEST_F(StringsListsConcatenateTest, ScalarSeparator) TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) { auto const string_lists = STR_LISTS{ - {STR_LISTS{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, - STR_LISTS{}, /*NULL*/ - STR_LISTS{{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, - STR_LISTS{"zzz", "xxxxx"}, - STR_LISTS{"11111", "11111", "11111", "11111", "11111"}, /*NULL*/ - STR_LISTS{{"abcdef", "012345", "" /*NULL*/, "xxx000"}, null_at(2)}, - STR_LISTS{{"xyz" /*NULL*/, "11111", "00000"}, null_at(0)}, - STR_LISTS{"0a0b0c", "5x5y5z"}, - STR_LISTS{"xxx"}, /*NULL*/ - STR_LISTS{"ééé", "12345abcdef"}, - STR_LISTS{"aaaééébbbéééccc", "12345"}}, + {{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, + {}, /*NULL*/ + {{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, + {"zzz", "xxxxx"}, + {"11111", "11111", "11111", "11111", "11111"}, /*NULL*/ + {{"abcdef", "012345", "" /*NULL*/, "xxx000"}, null_at(2)}, + {{"xyz" /*NULL*/, "11111", "00000"}, null_at(0)}, + {"0a0b0c", "5x5y5z"}, + {"xxx"}, /*NULL*/ + {"ééé", "12345abcdef"}, + {"aaaééébbbéééccc", "12345"}}, cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i != 1 && i != 4 && i != 8; })}.release(); @@ -348,12 +340,12 @@ TEST_F(StringsListsConcatenateTest, SlicedListsWithScalarSeparator) TEST_F(StringsListsConcatenateTest, ColumnSeparators) { - auto const string_lists = STR_LISTS{{STR_LISTS{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, - STR_LISTS{}, /*NULL*/ - STR_LISTS{"0a0b0c", "xyzééé"}, - STR_LISTS{{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, - STR_LISTS{{"ééé" /*NULL*/, "ááá", "ííí"}, null_at(0)}, - STR_LISTS{"zzz", "xxxxx"}}, + auto const string_lists = STR_LISTS{{{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, + {}, /*NULL*/ + {"0a0b0c", "xyzééé"}, + {{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, + {{"ééé" /*NULL*/, "ááá", "ííí"}, null_at(0)}, + {"zzz", "xxxxx"}}, null_at(1)} .release(); auto const string_lv = cudf::lists_column_view(string_lists->view()); @@ -427,17 +419,17 @@ TEST_F(StringsListsConcatenateTest, ColumnSeparators) TEST_F(StringsListsConcatenateTest, SlicedListsWithColumnSeparators) { auto const string_lists = STR_LISTS{ - {STR_LISTS{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, - STR_LISTS{}, /*NULL*/ - STR_LISTS{{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, - STR_LISTS{"zzz", "xxxxx"}, - STR_LISTS{"11111", "11111", "11111", "11111", "11111"}, /*NULL*/ - STR_LISTS{{"abcdef", "012345", "" /*NULL*/, "xxx000"}, null_at(2)}, - STR_LISTS{{"xyz" /*NULL*/, "11111", "00000"}, null_at(0)}, - STR_LISTS{"0a0b0c", "5x5y5z"}, - STR_LISTS{"xxx"}, /*NULL*/ - STR_LISTS{"ééé", "12345abcdef"}, - STR_LISTS{"aaaééébbbéééccc", "12345"}}, + {{{"a", "bb" /*NULL*/, "ccc"}, null_at(1)}, + {}, /*NULL*/ + {{"ddd" /*NULL*/, "efgh", "ijk"}, null_at(0)}, + {"zzz", "xxxxx"}, + {"11111", "11111", "11111", "11111", "11111"}, /*NULL*/ + {{"abcdef", "012345", "" /*NULL*/, "xxx000"}, null_at(2)}, + {{"xyz" /*NULL*/, "11111", "00000"}, null_at(0)}, + {"0a0b0c", "5x5y5z"}, + {"xxx"}, /*NULL*/ + {"ééé", "12345abcdef"}, + {"aaaééébbbéééccc", "12345"}}, cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i != 1 && i != 4 && i != 8; })}.release(); diff --git a/cpp/tests/strings/extract_tests.cpp b/cpp/tests/strings/extract_tests.cpp index ada8c723ff19..1c777083f589 100644 --- a/cpp/tests/strings/extract_tests.cpp +++ b/cpp/tests/strings/extract_tests.cpp @@ -307,13 +307,13 @@ TEST_F(StringsExtractTests, ExtractAllTest) std::array valids{true, true, true, false, false, false, true}; using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"123", "banana", "7", "eleven"}, - LCW{"41", "apple"}, - LCW{"6", "péar", "0", "pair"}, - LCW{}, - LCW{}, - LCW{}, - LCW{"4", "paré"}}, + LCW expected({{"123", "banana", "7", "eleven"}, + {"41", "apple"}, + {"6", "péar", "0", "pair"}, + {}, + {}, + {}, + {"4", "paré"}}, valids.data()); auto prog = cudf::strings::regex_program::create(pattern); auto results = cudf::strings::extract_all_record(sv, *prog); diff --git a/cpp/tests/strings/find_multiple_tests.cpp b/cpp/tests/strings/find_multiple_tests.cpp index d980a1c5ad59..7f55f0a0a83b 100644 --- a/cpp/tests/strings/find_multiple_tests.cpp +++ b/cpp/tests/strings/find_multiple_tests.cpp @@ -36,12 +36,12 @@ TEST_F(StringsFindMultipleTest, FindMultiple) auto results = cudf::strings::find_multiple(strings_view, targets_view); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{1, -1, -1, -1, 4, -1, -1}, - LCW{4, -1, 2, -1, -1, -1, 2}, - LCW{-1, -1, -1, -1, -1, -1, -1}, - LCW{-1, 2, 1, -1, -1, -1, -1}, - LCW{-1, -1, 1, 8, -1, -1, 1}, - LCW{-1, -1, -1, -1, -1, -1, -1}}); + LCW expected({{1, -1, -1, -1, 4, -1, -1}, + {4, -1, 2, -1, -1, -1, 2}, + {-1, -1, -1, -1, -1, -1, -1}, + {-1, 2, 1, -1, -1, -1, -1}, + {-1, -1, 1, 8, -1, -1, 1}, + {-1, -1, -1, -1, -1, -1, -1}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } diff --git a/cpp/tests/strings/findall_tests.cpp b/cpp/tests/strings/findall_tests.cpp index 6051a7ad7e63..a0a236979ec3 100644 --- a/cpp/tests/strings/findall_tests.cpp +++ b/cpp/tests/strings/findall_tests.cpp @@ -30,15 +30,9 @@ TEST_F(StringsFindallTests, FindallTest) auto pattern = std::string("\\d+-\\w+"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"3-A"}, - LCW{"4-May", "5-Day", "6-Hay"}, - LCW{"12-Dec", "2021-Jan"}, - LCW{}, - LCW{}, - LCW{}, - LCW{}, - LCW{"25-9000"}}, - valids.data()); + LCW expected( + {{"3-A"}, {"4-May", "5-Day", "6-Hay"}, {"12-Dec", "2021-Jan"}, {}, {}, {}, {}, {"25-9000"}}, + valids.data()); auto prog = cudf::strings::regex_program::create(pattern); auto results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); @@ -51,7 +45,7 @@ TEST_F(StringsFindallTests, Multiline) auto pattern = std::string("^abc$"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"abc", "abc"}, LCW{"abc"}, LCW{"abc"}, LCW{}, LCW{"abc"}}); + LCW expected({{"abc", "abc"}, {"abc"}, {"abc"}, {}, {"abc"}}); auto prog = cudf::strings::regex_program::create(pattern, cudf::strings::regex_flags::MULTILINE); auto results = cudf::strings::findall(view, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); @@ -64,7 +58,7 @@ TEST_F(StringsFindallTests, DotAll) auto pattern = std::string("b.*f"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"bc\nfa\nef"}, LCW{"bbc\nfff"}, LCW{"bcdéf"}, LCW{}}); + LCW expected({{"bc\nfa\nef"}, {"bbc\nfff"}, {"bcdéf"}, {}}); auto prog = cudf::strings::regex_program::create(pattern, cudf::strings::regex_flags::DOTALL); auto results = cudf::strings::findall(view, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); @@ -84,15 +78,14 @@ TEST_F(StringsFindallTests, SpecialNewLines) cudf::strings::regex_program::create("^zzé$", cudf::strings::regex_flags::EXT_NEWLINE); auto results = cudf::strings::findall(view, *prog); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{}, LCW{}, LCW{"zzé"}, LCW{}, LCW{"zzé"}, LCW{}}); + LCW expected({{}, {}, {"zzé"}, {}, {"zzé"}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); auto both_flags = static_cast( cudf::strings::regex_flags::EXT_NEWLINE | cudf::strings::regex_flags::MULTILINE); auto prog_ml = cudf::strings::regex_program::create("^zzé$", both_flags); results = cudf::strings::findall(view, *prog_ml); - LCW expected_ml( - {LCW{"zzé", "zzé"}, LCW{"zzé"}, LCW{"zzé"}, LCW{}, LCW{"zzé"}, LCW{"zzé", "zzé"}}); + LCW expected_ml({{"zzé", "zzé"}, {"zzé"}, {"zzé"}, {}, {"zzé"}, {"zzé", "zzé"}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected_ml); } @@ -107,7 +100,7 @@ TEST_F(StringsFindallTests, MediumRegex) auto results = cudf::strings::findall(strings_view, *prog); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"first words 1234", "just numbers 9876"}, LCW{}}); + LCW expected({{"first words 1234", "just numbers 9876"}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } @@ -133,7 +126,7 @@ TEST_F(StringsFindallTests, LargeRegex) auto results = cudf::strings::findall(strings_view, *prog); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{large_regex.c_str()}, LCW{}, LCW{}}); + LCW expected({{large_regex.c_str()}, {}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } @@ -160,7 +153,7 @@ TEST_F(StringsFindallTests, NoMatches) auto pattern = std::string("^zzz$"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{}, LCW{}, LCW{}, LCW{}, LCW{}}); + LCW expected({{}, {}, {}, {}, {}}); auto prog = cudf::strings::regex_program::create(pattern); auto results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); @@ -198,23 +191,15 @@ TEST_F(StringsFindallTests, OneCaptureGroup) auto pattern = std::string("(\\d+)-\\w+"); using LCW = cudf::test::lists_column_wrapper; - LCW expected( - {LCW{"3"}, LCW{"4", "5", "6"}, LCW{"12", "2021"}, LCW{}, LCW{}, LCW{}, LCW{}, LCW{"25"}}, - valids.data()); + LCW expected({{"3"}, {"4", "5", "6"}, {"12", "2021"}, {}, {}, {}, {}, {"25"}}, valids.data()); auto prog = cudf::strings::regex_program::create(pattern); auto results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); - expected = LCW({LCW{"3-A"}, - LCW{"4-May", "5-Day", "6-Hay"}, - LCW{"12-Dec", "2021-Jan"}, - LCW{}, - LCW{}, - LCW{}, - LCW{}, - LCW{"25-9000"}}, - valids.data()); - prog = cudf::strings::regex_program::create( + expected = + LCW({{"3-A"}, {"4-May", "5-Day", "6-Hay"}, {"12-Dec", "2021-Jan"}, {}, {}, {}, {}, {"25-9000"}}, + valids.data()); + prog = cudf::strings::regex_program::create( pattern, cudf::strings::regex_flags::DEFAULT, cudf::strings::capture_groups::NON_CAPTURE); results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); @@ -232,7 +217,7 @@ TEST_F(StringsFindallTests, AlternationPriorityFirstWins) auto results = cudf::strings::findall(sv, *prog); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"foo"}, LCW{"foo"}, LCW{"foo"}, LCW{}, LCW{"foo"}, LCW{}}); + LCW expected({{"foo"}, {"foo"}, {"foo"}, {}, {"foo"}, {}}); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } @@ -242,17 +227,17 @@ TEST_F(StringsFindallTests, EmptyMatch) auto sv = cudf::strings_column_view(input); using LCW = cudf::test::lists_column_wrapper; - auto expected = LCW({LCW{}, LCW{}, LCW{}}); + auto expected = LCW({{}, {}, {}}); auto prog = cudf::strings::regex_program::create("^$", cudf::strings::regex_flags::MULTILINE); auto results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); - expected = LCW({LCW{}, LCW{"", "", "", ""}, LCW{"", "", "", ""}}); + expected = LCW({{}, {"", "", "", ""}, {"", "", "", ""}}); prog = cudf::strings::regex_program::create("\\b"); results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); - expected = LCW({LCW{}, LCW{"", "", "", ""}, LCW{"", "", "", ""}}); + expected = LCW({{}, {"", "", "", ""}, {"", "", "", ""}}); prog = cudf::strings::regex_program::create("(\\b)"); results = cudf::strings::findall(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); diff --git a/cpp/tests/strings/format_lists_tests.cpp b/cpp/tests/strings/format_lists_tests.cpp index 3e87c1246597..75a3304bf1ab 100644 --- a/cpp/tests/strings/format_lists_tests.cpp +++ b/cpp/tests/strings/format_lists_tests.cpp @@ -30,7 +30,7 @@ TEST_F(StringsFormatListsTest, EmptyNestedList) { using STR_LISTS = cudf::test::lists_column_wrapper; - auto const input = STR_LISTS{STR_LISTS{STR_LISTS{}, STR_LISTS{}}, STR_LISTS{STR_LISTS{}}}; + auto const input = STR_LISTS{{{}, {}}, STR_LISTS::nested({{}})}; auto const view = cudf::lists_column_view(input); auto results = cudf::strings::format_list_column(view); @@ -42,11 +42,11 @@ TEST_F(StringsFormatListsTest, WithNulls) { using STR_LISTS = cudf::test::lists_column_wrapper; - auto const input = STR_LISTS{{STR_LISTS{{"a", "", "ccc"}, cudf::test::iterators::null_at(1)}, - STR_LISTS{}, - STR_LISTS{{"", "bb", "ddd"}, cudf::test::iterators::null_at(0)}, - STR_LISTS{"zzz", "xxxxx"}, - STR_LISTS{{"v", "", "", "w"}, cudf::test::iterators::null_at(2)}}, + auto const input = STR_LISTS{{{{"a", "", "ccc"}, cudf::test::iterators::null_at(1)}, + {}, + {{"", "bb", "ddd"}, cudf::test::iterators::null_at(0)}, + {"zzz", "xxxxx"}, + {{"v", "", "", "w"}, cudf::test::iterators::null_at(2)}}, cudf::test::iterators::null_at(1)}; auto const view = cudf::lists_column_view(input); @@ -62,11 +62,9 @@ TEST_F(StringsFormatListsTest, CustomParameters) using STR_LISTS = cudf::test::lists_column_wrapper; auto const input = - STR_LISTS{STR_LISTS{{STR_LISTS{{"a", "", "ccc"}, cudf::test::iterators::null_at(1)}, - STR_LISTS{}, - STR_LISTS{"ddd", "ee", "f"}}, - cudf::test::iterators::null_at(1)}, - {STR_LISTS{"gg", "hhh"}, STR_LISTS{"i", "", "", "jj"}}}; + STR_LISTS{{{{{"a", "", "ccc"}, cudf::test::iterators::null_at(1)}, {}, {"ddd", "ee", "f"}}, + cudf::test::iterators::null_at(1)}, + {{"gg", "hhh"}, {"i", "", "", "jj"}}}; auto const view = cudf::lists_column_view(input); auto separators = cudf::test::strings_column_wrapper({": ", "{", "}"}); @@ -82,8 +80,7 @@ TEST_F(StringsFormatListsTest, NestedList) using STR_LISTS = cudf::test::lists_column_wrapper; auto const input = - STR_LISTS{{STR_LISTS{"a", "bb", "ccc"}, STR_LISTS{}, STR_LISTS{"ddd", "ee", "f"}}, - {STR_LISTS{"gg", "hhh"}, STR_LISTS{"i", "", "", "jj"}}}; + STR_LISTS{{{"a", "bb", "ccc"}, {}, {"ddd", "ee", "f"}}, {{"gg", "hhh"}, {"i", "", "", "jj"}}}; auto const view = cudf::lists_column_view(input); auto results = cudf::strings::format_list_column(view); @@ -96,19 +93,18 @@ TEST_F(StringsFormatListsTest, SlicedLists) { using STR_LISTS = cudf::test::lists_column_wrapper; - auto const input = - STR_LISTS{{STR_LISTS{{"a", "", "bb"}, cudf::test::iterators::null_at(1)}, - STR_LISTS{}, - STR_LISTS{{"", "ccc", "dddd"}, cudf::test::iterators::null_at(0)}, - STR_LISTS{"zzz", ""}, - STR_LISTS{}, - STR_LISTS{{"abcdef", "012345", "", ""}, cudf::test::iterators::null_at(2)}, - STR_LISTS{{"", "11111", "00000"}, cudf::test::iterators::null_at(0)}, - STR_LISTS{"hey hey", "way way"}, - STR_LISTS{}, - STR_LISTS{"ééé", "12345abcdef"}, - STR_LISTS{"www", "12345"}}, - cudf::test::iterators::nulls_at({1, 4, 8})}; + auto const input = STR_LISTS{{{{"a", "", "bb"}, cudf::test::iterators::null_at(1)}, + {}, + {{"", "ccc", "dddd"}, cudf::test::iterators::null_at(0)}, + {"zzz", ""}, + {}, + {{"abcdef", "012345", "", ""}, cudf::test::iterators::null_at(2)}, + {{"", "11111", "00000"}, cudf::test::iterators::null_at(0)}, + {"hey hey", "way way"}, + {}, + {"ééé", "12345abcdef"}, + {"www", "12345"}}, + cudf::test::iterators::nulls_at({1, 4, 8})}; // matching expected strings auto const h_expected = std::vector({"[a,NULL,bb]", @@ -144,7 +140,7 @@ TEST_F(StringsFormatListsTest, Errors) EXPECT_THROW(cudf::strings::format_list_column(cudf::lists_column_view(invalid)), cudf::logic_error); - auto const input = STR_LISTS{STR_LISTS{}, STR_LISTS{}}; + auto const input = STR_LISTS{{}, {}}; auto const view = cudf::lists_column_view(input); auto separators = cudf::test::strings_column_wrapper({"{", "}"}); diff --git a/cpp/tests/strings/split_tests.cpp b/cpp/tests/strings/split_tests.cpp index 9878bdab43a8..cfc7d0735c25 100644 --- a/cpp/tests/strings/split_tests.cpp +++ b/cpp/tests/strings/split_tests.cpp @@ -237,12 +237,12 @@ TEST_F(StringsSplitTest, SplitRecord) auto const result = cudf::strings::split_record(sv, cudf::string_scalar(" ")); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"", "Héllo", "thesé"}, - LCW{}, - LCW{"are", "some", "", ""}, - LCW{"tést", "String"}, - LCW{""}, - LCW{"", "123", ""}}, + LCW expected({{"", "Héllo", "thesé"}, + {}, + {"are", "some", "", ""}, + {"tést", "String"}, + {""}, + {"", "123", ""}}, validity); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); } @@ -257,12 +257,7 @@ TEST_F(StringsSplitTest, SplitRecordWithMaxSplit) auto const result = cudf::strings::split_record(sv, cudf::string_scalar(" "), 1); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"", "Héllo thesé"}, - LCW{}, - LCW{"are", "some "}, - LCW{"tést", "String"}, - LCW{""}, - LCW{"", "123 "}}, + LCW expected({{"", "Héllo thesé"}, {}, {"are", "some "}, {"tést", "String"}, {""}, {"", "123 "}}, validity); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); } @@ -277,13 +272,7 @@ TEST_F(StringsSplitTest, SplitRecordWhitespace) auto result = cudf::strings::split_record(sv); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"Héllo", "thesé"}, - LCW{}, - LCW{"are", "some"}, - LCW{"tést", "String"}, - LCW{}, - LCW{}, - LCW{"123"}}, + LCW expected({{"Héllo", "thesé"}, {}, {"are", "some"}, {"tést", "String"}, {}, {}, {"123"}}, validity); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); } @@ -297,13 +286,7 @@ TEST_F(StringsSplitTest, SplitRecordWhitespaceWithMaxSplit) auto const result = cudf::strings::split_record(sv, cudf::string_scalar(""), 1); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"Héllo", "thesé "}, - LCW{}, - LCW{"are", "some "}, - LCW{"tést", "String"}, - LCW{}, - LCW{}, - LCW{"123"}}, + LCW expected({{"Héllo", "thesé "}, {}, {"are", "some "}, {"tést", "String"}, {}, {}, {"123"}}, validity); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); } @@ -336,8 +319,8 @@ TEST_F(StringsSplitTest, SplitRecordAllEmpty) auto delimiter = cudf::string_scalar("s"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{""}, LCW{""}, LCW{""}, LCW{""}}); - LCW expected_empty({LCW{}, LCW{}, LCW{}, LCW{}}); + LCW expected({{""}, {""}, {""}, {""}}); + LCW expected_empty({{}, {}, {}, {}}); auto result = cudf::strings::split_record(sv, delimiter); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); @@ -358,21 +341,13 @@ TEST_F(StringsSplitTest, MultiByteDelimiters) auto view = cudf::strings_column_view(input); using LCW = cudf::test::lists_column_wrapper; { - auto result = cudf::strings::split_record(view, cudf::string_scalar("::")); - auto expected_left = LCW({LCW{"u", ""}, - LCW{"w", ":x"}, - LCW{"y", "", "z"}, - LCW{"", "a"}, - LCW{"", ":b"}, - LCW{"", ":c", ":"}}); + auto result = cudf::strings::split_record(view, cudf::string_scalar("::")); + auto expected_left = + LCW({{"u", ""}, {"w", ":x"}, {"y", "", "z"}, {"", "a"}, {"", ":b"}, {"", ":c", ":"}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected_left); - result = cudf::strings::rsplit_record(view, cudf::string_scalar("::")); - auto expected_right = LCW({LCW{"u", ""}, - LCW{"w:", "x"}, - LCW{"y", "", "z"}, - LCW{"", "a"}, - LCW{":", "b"}, - LCW{":", "c:", ""}}); + result = cudf::strings::rsplit_record(view, cudf::string_scalar("::")); + auto expected_right = + LCW({{"u", ""}, {"w:", "x"}, {"y", "", "z"}, {"", "a"}, {":", "b"}, {":", "c:", ""}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected_right); } { @@ -407,7 +382,7 @@ TEST_F(StringsSplitTest, MultiByteDelimiters) view = cudf::strings_column_view(input); { auto result = cudf::strings::split_record(view, cudf::string_scalar("}:{")); - auto expected = LCW({LCW{"{a=1", "b=2}:"}, LCW{"{c=3}"}, LCW{":{", "}"}}); + auto expected = LCW({{"{a=1", "b=2}:"}, {"{c=3}"}, {":{", "}"}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); result = cudf::strings::rsplit_record(view, cudf::string_scalar("}:{")); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected); @@ -487,9 +462,8 @@ TEST_F(StringsSplitTest, SplitRecordRegex) { auto pattern = std::string("\\s+"); - LCW expected( - {LCW{"", "Héllo", "thesé"}, LCW{}, LCW{"are", "some", ""}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW expected({{"", "Héllo", "thesé"}, {}, {"are", "some", ""}, {"tést", "String"}, {""}}, + validity); auto prog = cudf::strings::regex_program::create(pattern); auto result = cudf::strings::split_record_re(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected); @@ -502,11 +476,7 @@ TEST_F(StringsSplitTest, SplitRecordRegex) { auto pattern = std::string("[eé]"); - LCW expected({LCW{" H", "llo th", "s", ""}, - LCW{}, - LCW{"ar", " som", " "}, - LCW{"t", "st String"}, - LCW{""}}, + LCW expected({{" H", "llo th", "s", ""}, {}, {"ar", " som", " "}, {"t", "st String"}, {""}}, validity); auto prog = cudf::strings::regex_program::create(pattern); auto result = cudf::strings::split_record_re(sv, *prog); @@ -525,7 +495,7 @@ TEST_F(StringsSplitTest, SplitRecordRegexLazyQuantifier) using LCW = cudf::test::lists_column_wrapper; { - LCW expected({LCW{"\rbaa", "\ra"}}); + LCW expected({{"\rbaa", "\ra"}}); auto const prog = cudf::strings::regex_program::create("[^ \v\n\t\r\f]\\r+?\\n*", cudf::strings::regex_flags::EXT_NEWLINE, @@ -536,7 +506,7 @@ TEST_F(StringsSplitTest, SplitRecordRegexLazyQuantifier) } { - LCW expected({LCW{"\rbaa", "a"}}); + LCW expected({{"\rbaa", "a"}}); auto const prog = cudf::strings::regex_program::create("[^ \v\n\t\r\f]\\r+\\n*", cudf::strings::regex_flags::EXT_NEWLINE, @@ -577,17 +547,15 @@ TEST_F(StringsSplitTest, SplitRegexWithMaxSplit) auto pattern = std::string("\\s"); using LCW = cudf::test::lists_column_wrapper; - LCW expected1( - {LCW{"", "Héllo\tthesé"}, LCW{}, LCW{"are", "some "}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW expected1({{"", "Héllo\tthesé"}, {}, {"are", "some "}, {"tést", "String"}, {""}}, + validity); auto prog = cudf::strings::regex_program::create(pattern); auto result = cudf::strings::split_record_re(sv, *prog, 1); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected1); result = cudf::strings::split_record_re(sv, *prog, 2); - LCW expected2( - {LCW{"", "Héllo", "thesé"}, LCW{}, LCW{"are", "some", " "}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW expected2({{"", "Héllo", "thesé"}, {}, {"are", "some", " "}, {"tést", "String"}, {""}}, + validity); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected2); // split everything is the same output as maxsplit==3 for the test input column here @@ -620,7 +588,7 @@ TEST_F(StringsSplitTest, SplitRegexWordBoundary) auto pattern = std::string("\\B"); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"a"}, LCW{"a", "b"}, LCW{"", "-", "+", ""}, LCW{"e\né"}}); + LCW expected({{"a"}, {"a", "b"}, {"", "-", "+", ""}, {"e\né"}}); auto prog = cudf::strings::regex_program::create(pattern); auto result = cudf::strings::split_record_re(sv, *prog); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected); @@ -653,15 +621,15 @@ TEST_F(StringsSplitTest, RSplitRecord) cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end(), validity); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"héllo"}, - LCW{}, - LCW{"a", "bc", "déf"}, - LCW{"a", "", "bc"}, - LCW{"", "ab", "cd"}, - LCW{"ab", "cd", ""}, - LCW{""}, - LCW{" a b "}, - LCW{" a bbb c"}}, + LCW expected({{"héllo"}, + {}, + {"a", "bc", "déf"}, + {"a", "", "bc"}, + {"", "ab", "cd"}, + {"ab", "cd", ""}, + {""}, + {" a b "}, + {" a bbb c"}}, validity); auto result = cudf::strings::rsplit_record(cudf::strings_column_view(strings), cudf::string_scalar("_")); @@ -684,15 +652,15 @@ TEST_F(StringsSplitTest, RSplitRecordWithMaxSplit) cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end(), validity); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"héllo"}, - LCW{}, - LCW{"a", "bc", "déf"}, - LCW{"___a", "", "bc"}, - LCW{"_ab", "cd", ""}, - LCW{"ab", "cd", ""}, - LCW{""}, - LCW{" a b _", "", ""}, - LCW{"_", "", " a bbb c"}}, + LCW expected({{"héllo"}, + {}, + {"a", "bc", "déf"}, + {"___a", "", "bc"}, + {"_ab", "cd", ""}, + {"ab", "cd", ""}, + {""}, + {" a b _", "", ""}, + {"_", "", " a bbb c"}}, validity); auto result = @@ -709,8 +677,7 @@ TEST_F(StringsSplitTest, RSplitRecordWhitespace) cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end(), validity); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"héllo"}, LCW{}, LCW{"a_bc_déf"}, LCW{}, LCW{"a", "b"}, LCW{"a", "bbb", "c"}}, - validity); + LCW expected({{"héllo"}, {}, {"a_bc_déf"}, {}, {"a", "b"}, {"a", "bbb", "c"}}, validity); auto result = cudf::strings::rsplit_record(cudf::strings_column_view(strings)); @@ -726,9 +693,8 @@ TEST_F(StringsSplitTest, RSplitRecordWhitespaceWithMaxSplit) cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end(), validity); using LCW = cudf::test::lists_column_wrapper; - LCW expected( - {LCW{" héllo", "Asher"}, LCW{}, LCW{"a_bc_déf"}, LCW{}, LCW{" a", "b"}, LCW{" a\r bbb", "c"}}, - validity); + LCW expected({{" héllo", "Asher"}, {}, {"a_bc_déf"}, {}, {" a", "b"}, {" a\r bbb", "c"}}, + validity); auto result = cudf::strings::rsplit_record(cudf::strings_column_view(strings), cudf::string_scalar(""), 1); @@ -756,9 +722,7 @@ TEST_F(StringsSplitTest, RSplitRegexWithMaxSplit) } { using LCW = cudf::test::lists_column_wrapper; - LCW expected( - {LCW{" Héllo", "thesé"}, LCW{}, LCW{"are some", ""}, LCW{"tést", "String"}, LCW{""}}, - validity); + LCW expected({{" Héllo", "thesé"}, {}, {"are some", ""}, {"tést", "String"}, {""}}, validity); auto result = cudf::strings::rsplit_record_re(sv, *prog, 1); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), expected); @@ -838,7 +802,7 @@ TEST_F(StringsSplitTest, AllNullsCase) auto target = cudf::string_scalar(" "); auto list_result = cudf::strings::split_record(sv); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{}, LCW{}, LCW{}}, cudf::test::iterators::all_nulls()); + LCW expected({{}, {}, {}}, cudf::test::iterators::all_nulls()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(list_result->view(), expected); list_result = cudf::strings::rsplit_record(sv); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(list_result->view(), expected); diff --git a/cpp/tests/text/minhash_tests.cpp b/cpp/tests/text/minhash_tests.cpp index ff790b511803..c4242853f650 100644 --- a/cpp/tests/text/minhash_tests.cpp +++ b/cpp/tests/text/minhash_tests.cpp @@ -43,16 +43,16 @@ TEST_F(MinHashTest, Permuted) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{1392101586u, 394869177u, 811528444u}, - LCW32{ 211415830u, 187088503u, 130291444u}, - LCW32{2098117052u, 394869177u, 799753544u}, - LCW32{2264583304u, 2920538364u, 3576493424u}, - LCW32{ 253327882u, 41747273u, 302030804u}, - LCW32{2109809594u, 1017470651u, 326988172u}, - LCW32{1303819864u, 850676747u, 147107852u}, - LCW32{ 736021564u, 720812292u, 1405158760u}, - LCW32{ 902780242u, 134064807u, 1613944636u}, - LCW32{ 547084870u, 1748895564u, 656501844u} + {1392101586u, 394869177u, 811528444u}, + { 211415830u, 187088503u, 130291444u}, + {2098117052u, 394869177u, 799753544u}, + {2264583304u, 2920538364u, 3576493424u}, + { 253327882u, 41747273u, 302030804u}, + {2109809594u, 1017470651u, 326988172u}, + {1303819864u, 850676747u, 147107852u}, + { 736021564u, 720812292u, 1405158760u}, + { 902780242u, 134064807u, 1613944636u}, + { 547084870u, 1748895564u, 656501844u} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -64,16 +64,16 @@ TEST_F(MinHashTest, Permuted) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{ 827364888116975697ul, 1601854279692781452ul, 70500662054893256ul}, - LCW64{ 18312093741021833ul, 133793446674258329ul, 21974512489226198ul}, - LCW64{ 22474244732520567ul, 1638811775655358395ul, 949306297364502264ul}, - LCW64{1332357434996402861ul, 2157346081260151330ul, 676491718310205848ul}, - LCW64{ 65816830624808020ul, 43323600380520789ul, 63511816333816345ul}, - LCW64{ 629657184954525200ul, 49741036507643002ul, 97466271004074331ul}, - LCW64{ 301611977846331113ul, 101188874709594830ul, 97466271004074331ul}, - LCW64{ 121498891461700668ul, 171065800427907402ul, 97466271004074331ul}, - LCW64{ 54617739511834072ul, 231454301607238929ul, 97466271004074331ul}, - LCW64{ 576418665851990314ul, 231454301607238929ul, 97466271004074331ul} + { 827364888116975697ul, 1601854279692781452ul, 70500662054893256ul}, + { 18312093741021833ul, 133793446674258329ul, 21974512489226198ul}, + { 22474244732520567ul, 1638811775655358395ul, 949306297364502264ul}, + {1332357434996402861ul, 2157346081260151330ul, 676491718310205848ul}, + { 65816830624808020ul, 43323600380520789ul, 63511816333816345ul}, + { 629657184954525200ul, 49741036507643002ul, 97466271004074331ul}, + { 301611977846331113ul, 101188874709594830ul, 97466271004074331ul}, + { 121498891461700668ul, 171065800427907402ul, 97466271004074331ul}, + { 54617739511834072ul, 231454301607238929ul, 97466271004074331ul}, + { 576418665851990314ul, 231454301607238929ul, 97466271004074331ul} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results64, expected64); @@ -93,8 +93,8 @@ TEST_F(MinHashTest, PermutedWide) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{1731998032u, 315359380u, 3193688024u}, - LCW32{1293098788u, 2860992281u, 133918478u} + {1731998032u, 315359380u, 3193688024u}, + {1293098788u, 2860992281u, 133918478u} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -106,8 +106,8 @@ TEST_F(MinHashTest, PermutedWide) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{1818322427062143853ul, 641024893347719371ul, 1769570368846988848ul}, - LCW64{1389920339306667795ul, 421787002125838902ul, 1759496674158703968ul} + {1818322427062143853ul, 641024893347719371ul, 1769570368846988848ul}, + {1389920339306667795ul, 421787002125838902ul, 1759496674158703968ul} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results64, expected64); @@ -128,11 +128,11 @@ TEST_F(MinHashTest, PermutedManyParameters) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{1731998032u, 315359380u, 3193688024u, 1777049372u, 360410720u, 3238739364u, 1822100712u, 405462060u, + {1731998032u, 315359380u, 3193688024u, 1777049372u, 360410720u, 3238739364u, 1822100712u, 405462060u, 3283790704u, 1867152052u, 450513400u, 3328842044u, 1912203392u, 495564740u, 3373893384u, 1957254732u, 540616080u, 3418944724u, 2002306072u, 585667420u, 3463996064u, 2047357412u, 630718760u, 3509047404u, 2092408752u, 675770100u, 3554098744u, 2137460092u, 720821440u, 3599150084u, 2182511432u}, - LCW32{1293098788u, 2860992281u, 133918478u, 1701811971u, 3269705464u, 542631661u, 2110525154u, 3678418647u, + {1293098788u, 2860992281u, 133918478u, 1701811971u, 3269705464u, 542631661u, 2110525154u, 3678418647u, 951344844u, 2519238337u, 4087131830u, 1360058027u, 2927951520u, 200877717u, 1768771210u, 3336664703u, 609590900u, 2177484393u, 3745377886u, 1018304083u, 2586197576u, 4154091069u, 1427017266u, 2994910759u, 267836956u, 1835730449u, 3403623942u, 676550139u, 2244443632u, 3812337125u, 1085263322u} @@ -148,7 +148,7 @@ TEST_F(MinHashTest, PermutedManyParameters) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{1818322427062143853, 641024893347719371, 1769570368846988848, 592272835132564366, + {1818322427062143853, 641024893347719371, 1769570368846988848, 592272835132564366, 1720818310631833835, 543520776917409353, 1672066252416678822, 494768718702254348, 1623314194201523817, 446016660487099335, 1574562135986368804, 397264602271944322, 1525810077771213799, 348512544056789317, 1477058019556058786, 299760485841634304, @@ -156,7 +156,7 @@ TEST_F(MinHashTest, PermutedManyParameters) 1330801844910593755, 153504311196169273, 1282049786695438742, 104752252981014268, 1233297728480283737, 56000194765859255, 1184545670265128724, 7248136550704242, 1135793612049973719, 2264339087549243188, 1087041553834818706}, - LCW64{1389920339306667795, 421787002125838902, 1759496674158703968, 791363336977875075, + {1389920339306667795, 421787002125838902, 1759496674158703968, 791363336977875075, 2129073009010740141, 1160939671829911248, 192806334649082363, 1530516006681947421, 562382669501118536, 1900092341533983602, 931959004353154709, 2269668676386019775, 1301535339205190882, 333402002024361997, 1671111674057227055, 702978336876398170, @@ -236,9 +236,9 @@ TEST_F(MinHashTest, Ngrams) { using LCWS = cudf::test::lists_column_wrapper; auto input = - LCWS({LCWS{"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "brown", "dog."}, - LCWS{"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "", "dog."}, - LCWS{"short", "row"}}); + LCWS({{"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "brown", "dog."}, + {"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "", "dog."}, + {"short", "row"}}); auto view = cudf::lists_column_view(input); @@ -249,9 +249,9 @@ TEST_F(MinHashTest, Ngrams) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{ 230924604u, 55492793u, 963436400u}, - LCW32{ 230924604u, 367515795u, 963436400u}, - LCW32{2380648568u, 1330223236u, 279797904u} + { 230924604u, 55492793u, 963436400u}, + { 230924604u, 367515795u, 963436400u}, + {2380648568u, 1330223236u, 279797904u} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -262,9 +262,9 @@ TEST_F(MinHashTest, Ngrams) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{ 208926840193078200ul, 576399628675212695ul, 312927673584437419ul}, - LCW64{ 677038498284219393ul, 326338087730412201ul, 298455901014050223ul}, - LCW64{1493265692486268500ul, 720255058049417768ul, 2253087432826260995ul} + { 208926840193078200ul, 576399628675212695ul, 312927673584437419ul}, + { 677038498284219393ul, 326338087730412201ul, 298455901014050223ul}, + {1493265692486268500ul, 720255058049417768ul, 2253087432826260995ul} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results64, expected64); @@ -287,8 +287,8 @@ TEST_F(MinHashTest, NgramsWide) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{ 571536396u, 2346676954u, 4121817512u}, - LCW32{ 571536396u, 2346676954u, 4121817512u} + { 571536396u, 2346676954u, 4121817512u}, + { 571536396u, 2346676954u, 4121817512u} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -299,8 +299,8 @@ TEST_F(MinHashTest, NgramsWide) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{ 1947142336021414174ul, 1219519365938078011ul, 491896395854741840ul}, - LCW64{ 1947142336021414174ul, 1219519365938078011ul, 491896395854741840ul} + { 1947142336021414174ul, 1219519365938078011ul, 491896395854741840ul}, + { 1947142336021414174ul, 1219519365938078011ul, 491896395854741840ul} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results64, expected64); @@ -310,11 +310,11 @@ TEST_F(MinHashTest, NgramsSliced) { using LCWS = cudf::test::lists_column_wrapper; auto input = - LCWS({LCWS{"ignored", "row"}, - LCWS{"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "brown", "dog."}, - LCWS{"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "", "dog."}, - LCWS{"short", "row"}, - LCWS{"ignored", "row"}}); + LCWS({{"ignored", "row"}, + {"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "brown", "dog."}, + {"The", "quick", "brown", "fox", "jumpéd", "over", "the", "lazy", "", "dog."}, + {"short", "row"}, + {"ignored", "row"}}); auto view = cudf::lists_column_view(cudf::slice(input, {1, 4}).front()); auto first = cuda::counting_iterator{10}; @@ -326,9 +326,9 @@ TEST_F(MinHashTest, NgramsSliced) using LCW32 = cudf::test::lists_column_wrapper; // clang-format off LCW32 expected({ - LCW32{ 230924604u, 55492793u, 963436400u}, - LCW32{ 230924604u, 367515795u, 963436400u}, - LCW32{2380648568u, 1330223236u, 279797904u} + { 230924604u, 55492793u, 963436400u}, + { 230924604u, 367515795u, 963436400u}, + {2380648568u, 1330223236u, 279797904u} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -339,9 +339,9 @@ TEST_F(MinHashTest, NgramsSliced) using LCW64 = cudf::test::lists_column_wrapper; // clang-format off LCW64 expected64({ - LCW64{ 208926840193078200ul, 576399628675212695ul, 312927673584437419ul}, - LCW64{ 677038498284219393ul, 326338087730412201ul, 298455901014050223ul}, - LCW64{1493265692486268500ul, 720255058049417768ul, 2253087432826260995ul} + { 208926840193078200ul, 576399628675212695ul, 312927673584437419ul}, + { 677038498284219393ul, 326338087730412201ul, 298455901014050223ul}, + {1493265692486268500ul, 720255058049417768ul, 2253087432826260995ul} }); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results64, expected64); diff --git a/cpp/tests/text/ngrams_tests.cpp b/cpp/tests/text/ngrams_tests.cpp index da389cb97eea..bc8c19dfdee8 100644 --- a/cpp/tests/text/ngrams_tests.cpp +++ b/cpp/tests/text/ngrams_tests.cpp @@ -41,22 +41,18 @@ TEST_F(TextGenerateNgramsTest, Ngrams) } using LCW = cudf::test::lists_column_wrapper; { - LCW expected({LCW({"th", "he"}), - LCW({"fo", "ox"}), - LCW({"ju", "um", "mp", "pe", "ed"}), - LCW({"ov", "ve", "er"}), - LCW({"th", "hé"}), - LCW({"do", "og"})}); + LCW expected({{"th", "he"}, + {"fo", "ox"}, + {"ju", "um", "mp", "pe", "ed"}, + {"ov", "ve", "er"}, + {"th", "hé"}, + {"do", "og"}}); auto const results = nvtext::generate_character_ngrams(strings_view, 2); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } { - LCW expected({LCW({"the"}), - LCW({"fox"}), - LCW({"jum", "ump", "mpe", "ped"}), - LCW({"ove", "ver"}), - LCW({"thé"}), - LCW({"dog"})}); + LCW expected( + {{"the"}, {"fox"}, {"jum", "ump", "mpe", "ped"}, {"ove", "ver"}, {"thé"}, {"dog"}}); auto const results = nvtext::generate_character_ngrams(strings_view, 3); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } @@ -78,14 +74,8 @@ TEST_F(TextGenerateNgramsTest, NgramsWithNulls) } { using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW({"the"}), - LCW({"fox"}), - LCW{}, - LCW({"jum", "ump", "mpe", "ped"}), - LCW({"ove", "ver"}), - LCW{}, - LCW({"the"}), - LCW({"dog"})}); + LCW expected( + {{"the"}, {"fox"}, {}, {"jum", "ump", "mpe", "ped"}, {"ove", "ver"}, {}, {"the"}, {"dog"}}); auto const results = nvtext::generate_character_ngrams(sv, 3); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } @@ -139,10 +129,10 @@ TEST_F(TextGenerateNgramsTest, NgramsHash) using LCW = cudf::test::lists_column_wrapper; // clang-format off - LCW expected({LCW{2169381797u, 3924065905u, 1634753325u, 3766025829u, 771291085u, + LCW expected({{2169381797u, 3924065905u, 1634753325u, 3766025829u, 771291085u, 2286480985u, 2815102125u, 2383213292u, 1587939873u, 3417728802u, 741580288u, 1721912990u, 3322339040u, 2530504717u, 1448945146u}, - LCW{3542029734u, 2351937583u, 2373822151u, 2610417165u, 1303810911u, + {3542029734u, 2351937583u, 2373822151u, 2610417165u, 1303810911u, 2541942822u, 1736466351u, 3466558519u, 408633648u, 1698719372u, 620653030u, 16851044u, 608863326u, 948572753u, 3672211877u, 4097451013u, 1444462157u, 3762829398u, 743082018u, 2953783152u, @@ -152,9 +142,9 @@ TEST_F(TextGenerateNgramsTest, NgramsHash) results = nvtext::hash_character_ngrams(view, 10, 10); // clang-format off - LCW expected2({LCW{2818025299u, 4026424618u, 578054337u, 2107870805u, 3942221995u, + LCW expected2({{2818025299u, 4026424618u, 578054337u, 2107870805u, 3942221995u, 2802685757u, 2686450821u, 584898501u, 2206824201u, 487979059u}, - LCW{1154048732u, 3209682333u, 3246563372u, 3789750511u, 1287153502u, + {1154048732u, 3209682333u, 3246563372u, 3789750511u, 1287153502u, 3759561568u, 1092423314u, 339538635u, 4265577390u, 879551618u, 4222824617u, 1774528854u, 1028254379u, 485918316u, 879142987u, 3619248543u} }); diff --git a/cpp/tests/text/subword_tests.cpp b/cpp/tests/text/subword_tests.cpp index ac018e043323..43ae17bfc250 100644 --- a/cpp/tests/text/subword_tests.cpp +++ b/cpp/tests/text/subword_tests.cpp @@ -31,17 +31,17 @@ TEST(TextSubwordTest, WordPiece) using LCW = cudf::test::lists_column_wrapper; // clang-format off - auto expected = LCW({LCW{ 9, 7, 1, 4, 5, 8}, - LCW{ 9, 6, 1, 3}, - LCW{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}); + auto expected = LCW({{ 9, 7, 1, 4, 5, 8}, + { 9, 6, 1, 3}, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); results = nvtext::wordpiece_tokenize(sv, *vocab, 5); // clang-format off - expected = LCW({LCW{ 9, 7, 1, 4, 5}, - LCW{ 9, 6, 1, 3}, - LCW{ 0, 1, 2, 3, 4}}); + expected = LCW({{ 9, 7, 1, 4, 5}, + { 9, 6, 1, 3}, + { 0, 1, 2, 3, 4}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } @@ -59,9 +59,9 @@ TEST(TextSubwordTest, WordPieceWithSubwords) using LCW = cudf::test::lists_column_wrapper; // clang-format off - auto expected = LCW({LCW{4, 6, 3, 5, 7, 8, 2}, - LCW{1, 1, 6, 3, 1}, - LCW{1, 1}}); + auto expected = LCW({{4, 6, 3, 5, 7, 8, 2}, + {1, 1, 6, 3, 1}, + {1, 1}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -71,9 +71,9 @@ TEST(TextSubwordTest, WordPieceWithSubwords) results = nvtext::wordpiece_tokenize(sv, *vocab, 4); // clang-format off - expected = LCW({LCW{4, 6, 3, 5, 7, 8}, - LCW{1, 1, 6, 3}, - LCW{1, 1}}); + expected = LCW({{4, 6, 3, 5, 7, 8}, + {1, 1, 6, 3}, + {1, 1}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } @@ -97,17 +97,17 @@ TEST(TextSubwordTest, WordPieceSliced) using LCW = cudf::test::lists_column_wrapper; // clang-format off - auto expected = LCW({LCW{ 9, 7, 1, 4, 5, 8}, - LCW{ 9, 6, 1, 3}, - LCW{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}); + auto expected = LCW({{ 9, 7, 1, 4, 5, 8}, + { 9, 6, 1, 3}, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); results = nvtext::wordpiece_tokenize(sv, *vocab, 5); // clang-format off - expected = LCW({LCW{ 9, 7, 1, 4, 5}, - LCW{ 9, 6, 1, 3}, - LCW{ 0, 1, 2, 3, 4}}); + expected = LCW({{ 9, 7, 1, 4, 5}, + { 9, 6, 1, 3}, + { 0, 1, 2, 3, 4}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } @@ -132,7 +132,7 @@ TEST(TextSubwordTest, WordPieceAllNulls) auto sv = cudf::strings_column_view(input); auto results = nvtext::wordpiece_tokenize(sv, *vocab); using LCW = cudf::test::lists_column_wrapper; - auto expected = LCW({LCW{}, LCW{}, LCW{}}, cudf::test::iterators::all_nulls()); + auto expected = LCW({{}, {}, {}}, cudf::test::iterators::all_nulls()); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); results = nvtext::wordpiece_tokenize(sv, *vocab, 10); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -146,7 +146,7 @@ TEST(TextSubwordTest, WordPieceNoTokens) auto sv = cudf::strings_column_view(input); auto results = nvtext::wordpiece_tokenize(sv, *vocab); using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{}, LCW{-1}, LCW{-1}}); // -1 indicates [unk] not found in vocabulary + LCW expected({{}, {-1}, {-1}}); // -1 indicates [unk] not found in vocabulary CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); results = nvtext::wordpiece_tokenize(sv, *vocab, 10); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); diff --git a/cpp/tests/text/tokenize_tests.cpp b/cpp/tests/text/tokenize_tests.cpp index 45c133f039d6..b630297d39a0 100644 --- a/cpp/tests/text/tokenize_tests.cpp +++ b/cpp/tests/text/tokenize_tests.cpp @@ -104,9 +104,9 @@ TEST_F(TextTokenizeTest, CharacterTokenize) cudf::test::strings_column_wrapper input({"the mousé ate", "the cheese", ""}); using LCW = cudf::test::lists_column_wrapper; - LCW expected{LCW{"t", "h", "e", " ", "m", "o", "u", "s", "é", " ", "a", "t", "e"}, - LCW{"t", "h", "e", " ", "c", "h", "e", "e", "s", "e"}, - LCW{}}; + LCW expected{{"t", "h", "e", " ", "m", "o", "u", "s", "é", " ", "a", "t", "e"}, + {"t", "h", "e", " ", "c", "h", "e", "e", "s", "e"}, + {}}; auto results = nvtext::character_tokenize(cudf::strings_column_view(input)); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -210,12 +210,12 @@ TEST_F(TextTokenizeTest, Vocabulary) using LCW = cudf::test::lists_column_wrapper; // clang-format off - LCW expected({LCW{ 9, 4, 5, 8, 9, 3}, - LCW{ 9, 3, 1, 9,-7}, - LCW{}, - LCW{ 9,-7, 1, 9, 6}, - LCW{ 9, 7, 0, 2}, - LCW{}, LCW{3}}, + LCW expected({{ 9, 4, 5, 8, 9, 3}, + { 9, 3, 1, 9,-7}, + {}, + { 9,-7, 1, 9, 6}, + { 9, 7, 0, 2}, + {}, {3}}, validity); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); @@ -247,10 +247,10 @@ TEST_F(TextTokenizeTest, VocabularyLongStrings) using LCW = cudf::test::lists_column_wrapper; // clang-format off - LCW expected({LCW{ 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, - LCW{ 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, - LCW{ 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, - LCW{ 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}}); + LCW expected({{ 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, + { 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, + { 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}, + { 9, 4, 5, 1, 9, 3, 2, 6, -1, 9, 8, -1, 3, 6, -1, -1, 9, -1, 5, 8, 9, 7, -1, -1, 9, 3}}); // clang-format on CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index 98a1a4c721c8..bde37d811d24 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -446,11 +446,6 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyLists) { using T = TypeParam; - // to disambiguate between {} == 0 and {} == List{0} - // Also, see note about compiler issues when declaring nested - // empty lists in lists_column_wrapper documentation - using LCW = cudf::test::lists_column_wrapper; - // List, empty // // List: @@ -473,7 +468,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyLists) // Children : { // equivalent to {} - cudf::test::lists_column_wrapper list{LCW{}}; + cudf::test::lists_column_wrapper list{{}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 1); @@ -492,7 +487,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyLists) // Children : { // equivalent to {} - cudf::test::lists_column_wrapper list{LCW{}, LCW{}}; + cudf::test::lists_column_wrapper list{{}, {}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 2); @@ -513,7 +508,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyLists) { // equivalent to {{1, 2}, {}, {3, 4}} - cudf::test::lists_column_wrapper list{{1, 2}, LCW{}, {3, 4}}; + cudf::test::lists_column_wrapper list{{1, 2}, {}, {3, 4}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -543,7 +538,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyLists) { // equivalent to { {{}}, {{1, 2}, {}, {3, 4}}, {{}, {5, 6, 7, 8}, {}} } cudf::test::lists_column_wrapper list{ - {LCW{}}, {{1, 2}, LCW{}, {3, 4}}, {LCW{}, {5, 6, 7, 8}, LCW{}}}; + {{}}, {{1, 2}, {}, {3, 4}}, {{}, {5, 6, 7, 8}, {}}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -574,9 +569,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) { using T = TypeParam; - // to disambiguate between {} == 0 and {} == List{0} - // Also, see note about compiler issues when declaring nested - // empty lists in lists_column_wrapper documentation + // Use nested() to disambiguate between {} == 0 and {} == List{0}. using LCW = cudf::test::lists_column_wrapper; auto valids = cudf::test::iterators::valids_at_multiples_of(2); @@ -591,7 +584,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) // Children : { // equivalent to {{}, NULL} - cudf::test::lists_column_wrapper list{{LCW{}, LCW{}}, valids}; + cudf::test::lists_column_wrapper list{{{}, {}}, valids}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 2); @@ -613,7 +606,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) // Children : { // equivalent to {{}, NULL, {}} - cudf::test::lists_column_wrapper list{{LCW{}, {1, 2, 3}, LCW{}}, valids}; + cudf::test::lists_column_wrapper list{{{}, {1, 2, 3}, {}}, valids}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -636,7 +629,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) // 1, 2, 3 { // equivalent to {{}, NULL, {1, 2, 3}} - cudf::test::lists_column_wrapper list{{LCW{}, LCW{}, {1, 2, 3}}, valids}; + cudf::test::lists_column_wrapper list{{{}, {}, {1, 2, 3}}, valids}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -664,7 +657,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) { // equivalent to { {{}}, NULL, {{}, {5, 6, 7, 8}, {}} } cudf::test::lists_column_wrapper list{ - {{LCW{}}, {{1, 2}, LCW{}, {3, 4}}, {LCW{}, {5, 6, 7, 8}, LCW{}}}, valids}; + {LCW::nested({{}}), {{1, 2}, {}, {3, 4}}, {{}, {5, 6, 7, 8}, {}}}, valids}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -694,10 +687,9 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { using T = TypeParam; - // to disambiguate between {} == 0 and {} == List{0} - // Also, see note about compiler issues when declaring nested - // empty lists in lists_column_wrapper documentation - using LCW = cudf::test::lists_column_wrapper; + // Use nested() to disambiguate between {} == 0 and {} == List{0}. + using LCW = cudf::test::lists_column_wrapper; + auto const empty = decltype(LCW::nested({})){}; // List>>: // Length : 3 @@ -712,7 +704,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // Offsets : 0, 0 // Children : { - cudf::test::lists_column_wrapper list{{{LCW{}}}, {LCW{}}, LCW{}}; + LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -757,7 +749,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // Offsets : 0, 0 // Children : { - cudf::test::lists_column_wrapper list{LCW{}, {LCW{}}, {{LCW{}}}}; + LCW list({empty, LCW::nested({empty}), LCW::nested({LCW::nested({empty})})}); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -804,7 +796,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // 1, 2, 3 { // { {}, {{{1,2,3}}}, {{}} } - cudf::test::lists_column_wrapper list{LCW{}, {{{1, 2, 3}}}, {LCW{}}}; + LCW list({empty, LCW::nested({LCW::nested({{1, 2, 3}})}), LCW::nested({empty})}); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -855,7 +847,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{}}}, {{}}, null } std::vector valids{true, true, false}; - cudf::test::lists_column_wrapper list{{{{LCW{}}}, {LCW{}}, LCW{}}, valids.begin()}; + LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -902,7 +894,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{}}}, null, {} } std::vector valids{true, false, true}; - cudf::test::lists_column_wrapper list{{{{LCW{}}}, {LCW{}}, LCW{}}, valids.begin()}; + LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -945,7 +937,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, {{}}, {} } std::vector valids{false, true, true}; - cudf::test::lists_column_wrapper list{{{{LCW{}}}, {LCW{}}, LCW{}}, valids.begin()}; + LCW list({LCW::nested({}), LCW::nested({empty}), LCW::nested({})}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -979,7 +971,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, null, null } std::vector valids{false, false, false}; - cudf::test::lists_column_wrapper list{{{{LCW{}}}, {LCW{}}, LCW{}}, valids.begin()}; + LCW list({LCW::nested({}), LCW::nested({}), LCW::nested({})}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1008,7 +1000,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, null, null } std::vector valids{false, false, false}; - cudf::test::lists_column_wrapper list{{LCW{}, {{LCW{}}}, {LCW{}}}, valids.begin()}; + LCW list({LCW::nested({}), LCW::nested({}), LCW::nested({})}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1041,7 +1033,8 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {null}, {{}}, {} } std::vector valids{false}; - cudf::test::lists_column_wrapper list{{{{LCW{}}}, valids.begin()}, {LCW{}}, LCW{}}; + auto const null_row = LCW::nested({LCW::nested({})}, valids.begin()); + LCW list({null_row, LCW::nested({LCW::nested({})}), LCW::nested({})}); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1083,8 +1076,10 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{1, 2, 3}, {4, 5}}}, {{}, {{}}}, {}, {{}, {}} } - cudf::test::lists_column_wrapper list{ - {{{1, 2, 3}, {4, 5}}}, {LCW{}, {LCW{}}}, LCW{}, {LCW{}, LCW{}}}; + LCW list({LCW::nested({{{1, 2, 3}, {4, 5}}}), + {LCW::nested({}), LCW::nested({empty})}, + LCW::nested({}), + {LCW::nested({}), LCW::nested({})}}); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 4); @@ -1318,9 +1313,7 @@ TEST_F(ListColumnWrapperTest, MismatchedHierarchies) { using T = int; - // to disambiguate between {} == 0 and {} == List{0} - // Also, see note about compiler issues when declaring nested - // empty lists in lists_column_wrapper documentation + // Use nested() to disambiguate between {} == 0 and {} == List{0}. using LCW = cudf::test::lists_column_wrapper; // trying to build a column out of a List> column, and a List column diff --git a/cpp/tests/utilities_tests/type_check_tests.cpp b/cpp/tests/utilities_tests/type_check_tests.cpp index 9521f3487063..02faeeec23fe 100644 --- a/cpp/tests/utilities_tests/type_check_tests.cpp +++ b/cpp/tests/utilities_tests/type_check_tests.cpp @@ -48,10 +48,10 @@ TEST_F(ColumnTypeCheckTest, SameList) LCW lhs2{{1, 2, 3}}, rhs2{{4, 5}}; EXPECT_TRUE(cudf::have_same_types(lhs2, rhs2)); - LCW lhs3{{LCW{1}, LCW{2, 3}}}, rhs3{{LCW{4, 5}}}; + LCW lhs3{{{1}, {2, 3}}}, rhs3{LCW::nested({{4, 5}})}; EXPECT_TRUE(cudf::have_same_types(lhs3, rhs3)); - LCW lhs4{{LCW{1}, LCW{}, LCW{2, 3}}}, rhs4{{LCW{4, 5}, LCW{}}}; + LCW lhs4{{{1}, {}, {2, 3}}}, rhs4{LCW::nested({{4, 5}, {}})}; EXPECT_TRUE(cudf::have_same_types(lhs4, rhs4)); } @@ -75,7 +75,7 @@ TEST_F(ColumnTypeCheckTest, SameStruct) FCW lf1{1, 2, 3}, rf1{0, 1}; StringCW lf2{"a", "bb", ""}, rf2{"cc", "d"}; - LCW lf3{LCW{1, 2}, LCW{}, LCW{4}}, rf3{LCW{1}, LCW{2}}; + LCW lf3({{1, 2}, {}, {4}}), rf3(LCW::nested({{1}, {2}})); DCW lf4{5, 5, 5}, rf4{9, 9}; SCW lhs{lf1, lf2, lf3, lf4}, rhs{rf1, rf2, rf3, rf4}; @@ -168,14 +168,14 @@ TEST_F(ColumnTypeCheckTest, DifferentLists) using LCW_f = cudf::test::lists_column_wrapper; // Different nested level - LCW_i lhs1{LCW_i{1, 1, 2, 3}, LCW_i{}, LCW_i{42, 42}}; - LCW_i rhs1{LCW_i{LCW_i{8, 8, 8}, LCW_i{9, 9}}, LCW_i{LCW_i{42, 42}}}; + LCW_i lhs1{{1, 1, 2, 3}, {}, {42, 42}}; + LCW_i rhs1{{{8, 8, 8}, {9, 9}}, LCW_i::nested({{42, 42}})}; EXPECT_FALSE(cudf::have_same_types(lhs1, rhs1)); // Different base column type - LCW_i lhs2{LCW_i{1, 1, 2, 3}, LCW_i{}, LCW_i{42, 42}}; - LCW_f rhs2{LCW_f{9.0, 9.1}, LCW_f{3.14}, LCW_f{}}; + LCW_i lhs2{{1, 1, 2, 3}, {}, {42, 42}}; + LCW_f rhs2{{9.0, 9.1}, {3.14}, {}}; EXPECT_FALSE(cudf::have_same_types(lhs2, rhs2)); } From 585e735ffd48d8a17772f7488a239c2553833921 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 2 Sep 2026 20:35:48 +0000 Subject: [PATCH 14/21] Allow resource-aware empty lists column wrappers --- cpp/include/cudf_test/lists_column_wrapper.hpp | 11 +++++++++++ cpp/tests/copying/gather_list_tests.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cpp/include/cudf_test/lists_column_wrapper.hpp b/cpp/include/cudf_test/lists_column_wrapper.hpp index 38b0f820038a..80fbb7cb4ea2 100644 --- a/cpp/include/cudf_test/lists_column_wrapper.hpp +++ b/cpp/include/cudf_test/lists_column_wrapper.hpp @@ -602,6 +602,17 @@ class lists_column_wrapper : public detail::column_wrapper { wrapped = make_empty_lists_column(data_type{type_to_id()}); } + /** + * @brief Construct an empty lists column with an explicit stream and memory resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(cuda::stream_ref stream, cudf::memory_resources mr) + : lists_column_wrapper(initializer_type{}, stream, mr) + { + } + /** * @brief Construct a lists column of nested lists from an initializer list of values * and a validity iterator. diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 14ebac22e695..454a9da1c75b 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -79,7 +79,7 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected; + LCW expected(stream, mr); CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); From 3016b0125bfdd864a71c76ab1a579a81185da66d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 9 Sep 2026 16:52:09 +0000 Subject: [PATCH 15/21] Simplify list wrapper resource tests --- cpp/include/cudf_test/base_fixture.hpp | 16 -------- .../lists_column_wrapper_tests.cpp | 37 +++++++++---------- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index 2af7c39ff9e2..68b2bd17e388 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -47,8 +47,6 @@ class BaseFixture : public ::testing::Test { * * Each test instantiates a fresh harness. Tests should construct results with `resources()`. * `TearDown` asserts that no output or temporary allocations remain live. - * Call `fail_on_current_device_resource_use()` in test scopes that must reject accidental - * current-device-resource allocations. */ struct BaseFixtureWithHarness : public BaseFixture { /** @@ -68,25 +66,11 @@ struct BaseFixtureWithHarness : public BaseFixture { */ cudf::memory_resources resources() { return _harness.resources(); } - /** - * @brief Install a scoped failing current-device resource. - * - * While the returned object is alive, allocations from the current device resource fail. - * Destroy it (or let it leave scope) to restore the previous current resource. - * - * @return Scoped guard around the failing current-device resource - */ - [[nodiscard]] scoped_current_device_resource fail_on_current_device_resource_use() - { - return _harness.fail_on_current_device_resource_use(); - } - /** * @brief Return the memory-resource harness used by this fixture. */ [[nodiscard]] memory_resource_test_harness& harness() noexcept { return _harness; } - protected: memory_resource_test_harness _harness{mr()}; }; diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index bde37d811d24..d1accb9874e9 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1540,36 +1540,34 @@ TYPED_TEST(ListColumnWrapperTestTyped, LargeListsOfStructsWithValidity) cudf::lists_column_view(*lists_column).child()); } -// Harness-scoped construction via lists_column_initializer. -// Multi-row nested Init still routes through cudf::concatenate temporaries on the current +// Harness-scoped list construction. +// Multi-row nested initialization still routes through cudf::concatenate temporaries on the current // resource; keep fail_on_current scopes on leaf / single-child paths until concatenate is ported. struct ListsColumnInitializerHarnessTest : public cudf::test::BaseFixtureWithHarness {}; TEST_F(ListsColumnInitializerHarnessTest, LeafInitUsesExplicitResources) { - using Init = cudf::test::lists_column_initializer; - using LCW = cudf::test::lists_column_wrapper; + using LCW = cudf::test::lists_column_wrapper; auto const st = this->stream(); auto const mr = this->resources(); std::unique_ptr built; { - auto fail_on_current = this->fail_on_current_device_resource_use(); - LCW list{Init{{1, 2, 3, 4}}, st, mr}; - this->_harness.synchronize(st); + auto fail_on_current = this->harness().fail_on_current_device_resource_use(); + LCW list{{1, 2, 3, 4}, st, mr}; + this->harness().synchronize(st); built = list.release(); } - LCW expected{Init{{1, 2, 3, 4}}, st, mr}; + LCW expected{{1, 2, 3, 4}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TEST_F(ListsColumnInitializerHarnessTest, LeafNullableInitUsesExplicitResources) { - using Init = cudf::test::lists_column_initializer; - using LCW = cudf::test::lists_column_wrapper; + using LCW = cudf::test::lists_column_wrapper; using cudf::test::iterators::null_at; auto const st = this->stream(); @@ -1577,21 +1575,20 @@ TEST_F(ListsColumnInitializerHarnessTest, LeafNullableInitUsesExplicitResources) std::unique_ptr built; { - auto fail_on_current = this->fail_on_current_device_resource_use(); - LCW list{Init{{1, 2, 3, 4}, null_at(1)}, st, mr}; - this->_harness.synchronize(st); + auto fail_on_current = this->harness().fail_on_current_device_resource_use(); + LCW list{{1, 2, 3, 4}, null_at(1), st, mr}; + this->harness().synchronize(st); built = list.release(); } - LCW expected{Init{{1, 2, 3, 4}, null_at(1)}, st, mr}; + LCW expected{{1, 2, 3, 4}, null_at(1), st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } TEST_F(ListsColumnInitializerHarnessTest, SingleChildNestedInitUsesExplicitResources) { - using Init = cudf::test::lists_column_initializer; - using LCW = cudf::test::lists_column_wrapper; + using LCW = cudf::test::lists_column_wrapper; auto const st = this->stream(); auto const mr = this->resources(); @@ -1599,13 +1596,13 @@ TEST_F(ListsColumnInitializerHarnessTest, SingleChildNestedInitUsesExplicitResou // One outer row whose only child is a leaf list: both levels avoid concatenate. std::unique_ptr built; { - auto fail_on_current = this->fail_on_current_device_resource_use(); - LCW list{Init{{{{1, 2, 3}}}}, st, mr}; - this->_harness.synchronize(st); + auto fail_on_current = this->harness().fail_on_current_device_resource_use(); + LCW list{{{{1, 2, 3}}}, st, mr}; + this->harness().synchronize(st); built = list.release(); } - LCW expected{Init{{{{1, 2, 3}}}}, st, mr}; + LCW expected{{{{1, 2, 3}}}, st, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } From 09e1f099008232b2a35ae545613cf8441bdbddf8 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 11 Sep 2026 23:42:12 +0000 Subject: [PATCH 16/21] Refine recursive lists column initialization --- .../cudf_test/lists_column_wrapper.hpp | 74 +- cpp/tests/copying/gather_list_tests.cpp | 341 ++++----- .../copying/segmented_gather_list_tests.cpp | 698 +++++++++--------- .../lists_column_wrapper_tests.cpp | 22 + 4 files changed, 562 insertions(+), 573 deletions(-) diff --git a/cpp/include/cudf_test/lists_column_wrapper.hpp b/cpp/include/cudf_test/lists_column_wrapper.hpp index 80fbb7cb4ea2..528ff0383afd 100644 --- a/cpp/include/cudf_test/lists_column_wrapper.hpp +++ b/cpp/include/cudf_test/lists_column_wrapper.hpp @@ -42,6 +42,16 @@ namespace test { template class lists_column_wrapper; +template +concept iterator_like = requires(Iterator i) { + *i; + ++i; +}; + +template +concept validity_iterator = + iterator_like && requires(Iterator i) { static_cast(*i); }; + /** * @brief Host-side recursive initializer tree for constructing list columns with an * explicit stream and memory resources at every nesting level. @@ -104,11 +114,7 @@ class lists_column_initializer { }); } - template - requires requires(InputIterator i) { - *i; - ++i; - } + template lists_column_initializer(InputIterator begin, InputIterator end) : values_(begin, end) { } @@ -120,14 +126,10 @@ class lists_column_initializer { * @param values Leaf element values * @param v Validity iterator over `values.size()` elements */ - template - requires requires(ValidityIterator i) { - *i; - ++i; - } + template lists_column_initializer(std::initializer_list values, ValidityIterator v) requires(!std::is_same_v) - : values_{values} + : values_{values}, has_validity_{true} { value_validity_.reserve(values_.size()); for (std::size_t i = 0; i < values_.size(); ++i) { @@ -135,12 +137,10 @@ class lists_column_initializer { } } - template + template lists_column_initializer(std::initializer_list values, ValidityIterator v) - requires(std::is_same_v && requires(ValidityIterator i) { - *i; - ++i; - }) + requires(std::is_same_v) + : has_validity_{true} { values_.reserve(values.size()); value_validity_.reserve(values.size()); @@ -186,7 +186,7 @@ class lists_column_initializer { return lists_column_initializer(children); } - template + template static lists_column_initializer nested(std::initializer_list children, ValidityIterator v) { @@ -200,10 +200,9 @@ class lists_column_initializer { * @param children Child list initializers * @param v Validity iterator over `children.size()` rows */ - template + template lists_column_initializer(std::initializer_list children, ValidityIterator v) - requires(std::is_same_v && - std::is_convertible_v, bool>) + requires(std::is_same_v) : nested_{true}, has_validity_{true} { children_.reserve(children.size()); @@ -241,6 +240,11 @@ class lists_column_initializer { * @return Reference to the leaf validity mask */ [[nodiscard]] auto const& value_validity() const { return value_validity_; } + /** + * @brief True if validity was explicitly provided. + * @return Whether this initializer has explicit validity + */ + [[nodiscard]] bool has_validity() const { return has_validity_; } /** * @brief Child initializers when `nested()` is true. * @return Reference to the child initializers @@ -263,26 +267,22 @@ class lists_column_initializer { template [[nodiscard]] std::pair>, std::vector> - build(cuda::stream_ref stream, cudf::memory_resources mr) const + build(cuda::stream_ref stream, cudf::memory_resources mr) && { std::vector> children; std::vector validity; children.reserve(children_.size()); validity.reserve(children_.size()); - for (auto const& child : children_) { + for (auto&& child : children_) { validity.push_back(child.valid()); - children.emplace_back(child, stream, mr); + children.emplace_back(std::move(child), stream, mr); } return {std::move(children), has_validity_ ? std::move(validity) : std::vector{}}; } private: - template + template lists_column_initializer with_validity(ValidityIterator validity) && - requires requires(ValidityIterator i) { - static_cast(*i); - ++i; - } { has_validity_ = true; if (nested_) { @@ -343,7 +343,7 @@ class lists_column_wrapper : public detail::column_wrapper { return initializer_type::nested(children); } - template + template static initializer_type nested(std::initializer_list children, ValidityIterator validity) { @@ -673,7 +673,7 @@ class lists_column_wrapper : public detail::column_wrapper { : column_wrapper{} { if (!init.nested()) { - if (init.value_validity().empty()) { + if (!init.has_validity()) { *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); } else { *this = lists_column_wrapper( @@ -688,19 +688,15 @@ class lists_column_wrapper : public detail::column_wrapper { return; } - auto [children, validity] = init.template build(stream, mr); + auto [children, validity] = std::move(init).template build(stream, mr); build_from_nested(children, validity, stream, mr); } - template + template lists_column_wrapper(initializer_type init, ValidityIterator validity, cuda::stream_ref stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires requires(ValidityIterator i) { - static_cast(*i); - ++i; - } : lists_column_wrapper(std::move(init).with_validity(validity), stream, mr) { } @@ -713,14 +709,14 @@ class lists_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column * @return A list column containing a single empty row */ - static lists_column_wrapper make_one_empty_row_column( + static lists_column_wrapper make_one_empty_row_column( bool valid = true, cuda::stream_ref stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); - cudf::test::fixed_width_column_wrapper values{}; - return lists_column_wrapper( + leaf_wrapper_t values(std::initializer_list{}, stream, mr); + return lists_column_wrapper( 1, offsets.release(), values.release(), diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index 454a9da1c75b..b98d2456c5d9 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -36,7 +36,6 @@ using LCW = cudf::test::lists_column_wrapper; // Nested list values. Passing these to lists_column_wrapper builds every nesting level with the // explicit stream and memory resources instead of the current device resource. -using Init = cudf::test::lists_column_initializer; TYPED_TEST(GatherTestListTyped, Gather) { @@ -46,21 +45,17 @@ TYPED_TEST(GatherTestListTyped, Gather) auto const mr = this->resources(); // List - Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list_col{{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, stream, mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{1, 2, 3, 4}, {6, 7}}; + LCW expected{{{1, 2, 3, 4}, {6, 7}}, stream, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TYPED_TEST(GatherTestListTyped, GatherNothing) @@ -87,10 +82,9 @@ TYPED_TEST(GatherTestListTyped, GatherNothing) // List { - Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + LCW list_col{{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, stream, mr}; cudf::test::fixed_width_column_wrapper gather_map{}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -121,21 +115,18 @@ TYPED_TEST(GatherTestListTyped, GatherNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; + LCW list_col{ + {{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, stream, mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}; + LCW expected{{{{1, 2, 3, 4}, valids}, {{6, 7}, valids}}, stream, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TYPED_TEST(GatherTestListTyped, GatherNested) @@ -147,50 +138,49 @@ TYPED_TEST(GatherTestListTyped, GatherNested) // List> { - Init list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + LCW list_col{{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + LCW expected{ + {{{2, 3}, {4, 5}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, stream, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List>> { - Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; + LCW list_col{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{10, 20}}, {{30}}, {{40, 50}, {60, 70, 80}}}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{Init{0}}}, - {{{10, 20}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}}; + LCW expected{{{{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + {{{0}}}, + {{{10, 20}}, {{30}}, {{40, 50}, {60, 70, 80}}}}, + stream, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -203,25 +193,25 @@ TYPED_TEST(GatherTestListTyped, GatherOutOfOrder) // List> { - Init list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + LCW list_col{{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 0}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{2, 3}, {4, 5}}}; + LCW expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{2, 3}, {4, 5}}}, + stream, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -236,55 +226,57 @@ TYPED_TEST(GatherTestListTyped, GatherNestedNulls) // List> { - Init list{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; + LCW list_col{ + {{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 1, 3}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{2, 3}, valids}, {4, 5}}, - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; + LCW expected{ + {{{{2, 3}, valids}, {4, 5}}, + {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, + stream, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List>> { - Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + LCW list_col{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{1, 2, 4}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{Init{0}}}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; + LCW expected{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{{0}}}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + stream, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -295,21 +287,17 @@ TYPED_TEST(GatherTestListTyped, GatherNestedWithEmpties) auto const stream = this->stream(); auto const mr = this->resources(); - Init list{{{2, 3}, Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {Init{}}}; + LCW list_col{{{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{}}}, stream, mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 2}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{2, 3}, Init{}}, {Init{}}}; + LCW expected{{{{2, 3}, {}}, {{}}}, stream, mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) @@ -321,26 +309,26 @@ TYPED_TEST(GatherTestListTyped, GatherDetailInvalidIndex) // List> { - Init list{{{2, 3}, {4, 5}}, - {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; + LCW list_col{{{{2, 3}, {4, 5}}, + {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + stream, + mr}; cudf::test::fixed_width_column_wrapper gather_map{{0, 15, 16, 2}, stream, mr}; - auto const list_col = LCW(list, stream, mr); cudf::table_view source_table({list_col}); auto results = cudf::gather( source_table, gather_map, cudf::out_of_bounds_policy::NULLIFY, stream, mr.get_output_mr()); std::vector expected_validity{1, 0, 0, 1}; - Init expected{ - {{{2, 3}, {4, 5}}, {Init{}}, {Init{}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - expected_validity.begin()}; + LCW expected{ + {{{{2, 3}, {4, 5}}, {{}}, {{}}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, + expected_validity.begin()}, + stream, + mr}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view().column(0), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view().column(0), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -352,10 +340,10 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) { // List, but rows 1 and 2 are empty at the very top. // We expect to get back a "full" hierarchy of type List> anyway. - Init list{{{{1, 2}}}, Init{}, Init{}}; + LCW list_col{{{{{1, 2}}}, {}, {}}, stream, mr}; cudf::test::fixed_width_column_wrapper row1_map{{1}, stream, mr}; - auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, row1_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -378,10 +366,10 @@ TEST_F(GatherTestList, GatherIncompleteHierarchies) { // List, gathering nothing. // We expect to get back a "full" hierarchy of type List> anyway. - Init list{{{{1, 2}}}, Init{}}; + LCW list_col{{{{{1, 2}}}, {}}, stream, mr}; cudf::test::fixed_width_column_wrapper empty_map{}; - auto const list_col = LCW(list, stream, mr); + cudf::table_view source_table({list_col}); auto result = cudf::gather( source_table, empty_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); @@ -410,29 +398,33 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) auto const mr = this->resources(); { - Init a{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }; - auto const col = LCW(a, stream, mr); - auto split_a = cudf::split(col, {3}, stream); + LCW col{{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }, + stream, + mr}; + + auto split_a = cudf::split(col, {3}, stream); cudf::table_view tbl0({split_a[0]}); cudf::table_view tbl1({split_a[1]}); cudf::test::fixed_width_column_wrapper map0{{1, 2}, stream, mr}; auto result0 = cudf::gather(tbl0, map0, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected0{ - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected0, stream, mr), + LCW expected0{{ + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + }, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected0, result0->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, stream, @@ -441,11 +433,13 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::test::fixed_width_column_wrapper map1{{0, 3}, stream, mr}; auto result1 = cudf::gather(tbl1, map1, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected1{ - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{50, 50, 50, 50}, {6, 13}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected1, stream, mr), + LCW expected1{{ + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{50, 50, 50, 50}, {6, 13}}, + }, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected1, result1->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, stream, @@ -456,25 +450,27 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) // List>> { - Init list{// slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + LCW col{ + {// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - // slice 1 - {{Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + // slice 1 + {{{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - // slice 2 - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; + // slice 2 + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, + stream, + mr}; - auto const col = LCW(list, stream, mr); - auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); + auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); // gather from slice 0 { @@ -483,8 +479,8 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::test::fixed_width_column_wrapper map{{0}, stream, mr}; auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + LCW expected{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, stream, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, @@ -499,20 +495,23 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::test::fixed_width_column_wrapper map{{1, 2, 0, 1}, stream, mr}; auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{ - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - - {{Init{0}}}, - - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + LCW expected{ + { + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + + {{{0}}}, + + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + }, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, @@ -527,13 +526,15 @@ TYPED_TEST(GatherTestListTyped, GatherSliced) cudf::test::fixed_width_column_wrapper map{{1, 0, 0, 1, 1, 0}, stream, mr}; auto result = cudf::gather(tbl, map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - Init expected{{{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{10, 20, 30}}, {Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, - {{{{{10, 20}, valids}}, {Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + LCW expected{{{{{{10, 20, 30}}, {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{10, 20, 30}}, {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}}, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->get_column(0).view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 8312d44b3bd7..e58f2e645dcb 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -41,12 +41,6 @@ using LCW = cudf::test::lists_column_wrapper; using namespace cudf::test::iterators; auto constexpr NULLIFY = cudf::out_of_bounds_policy::NULLIFY; -// Nested list values. Passing these to lists_column_wrapper builds every nesting level with the -// explicit stream and memory resources instead of the current device resource. -using I32Init = cudf::test::lists_column_initializer; -using I8Init = cudf::test::lists_column_initializer; -using StrInit = cudf::test::lists_column_initializer; - TYPED_TEST(SegmentedGatherTest, Gather) { using T = TypeParam; @@ -55,40 +49,33 @@ TYPED_TEST(SegmentedGatherTest, Gather) auto const mr = this->resources(); // List - I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list{{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, stream, mr}; { // Straight-line case. - I32Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}; - I32Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW gather_map{{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}}, stream, mr}; + LCW expected{{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}}, stream, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } { // Nullify out-of-bounds values. - I32Init gather_map{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}; - I32Init expected{{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, - NULLIFY, - stream, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW gather_map{{{3, 2, 4, 0}, {0}, {0, -3}, {0, 2, 1}}, stream, mr}; + LCW expected{ + {{{4, 3, 2, 1}, null_at(2)}, {5}, {{6, 7}, null_at(1)}, {8, 10, 9}}, stream, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -101,49 +88,46 @@ TYPED_TEST(SegmentedGatherTest, GatherNothing) // List { - I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; + LCW list{{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, stream, mr}; auto const gather_map = LCW{{}, {}, {}, {}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - auto const expected = LCW{{}, {}, {}, {}}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + auto const expected = LCW{{}, {}, {}, {}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List> { - I32Init list{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {I32Init{}, {8, 9, 10}}}; + LCW list{{{{1, 2, 3, 4}, {5}}, {{6, 7}}, {{}, {8, 9, 10}}}, stream, mr}; auto const gather_map = LCW{{}, {}, {}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); // hack to get column of empty list of list - I32Init expected_dummy{{{1, 2, 3, 4}, {5}}, I32Init{}, I32Init{}, I32Init{}}; - auto const col = LCW(expected_dummy, stream, mr); + LCW col{{{{1, 2, 3, 4}, {5}}, {}, {}, {}}, stream, mr}; + auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List>> { - I32Init list{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}; + LCW list{{{{{1, 2, 3, 4}, {5}}}, {{{6, 7}, {8, 9, 10}}}}, stream, mr}; auto const gather_map = LCW{{}, {}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{gather_map}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); // hack to get column of empty list of list of list - I32Init expected_dummy{{{{1, 2, 3, 4}}}, I32Init{}, I32Init{}}; - auto const col = LCW(expected_dummy, stream, mr); + LCW col{{{{{1, 2, 3, 4}}}, {}, {}}, stream, mr}; + auto const expected = cudf::split(col, {1}, stream)[1]; CUDF_TEST_EXPECT_COLUMNS_EQUAL( *results, expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -192,40 +176,32 @@ TYPED_TEST(SegmentedGatherTest, GatherNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); // List - I32Init list{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}; + LCW list{{{{1, 2, 3, 4}, valids}, {5}, {{6, 7}, valids}, {{8, 9, 10}, valids}}, stream, mr}; { // Test gathering on lists that contain nulls. - I32Init gather_map{{0, 1}, I32Init{}, {1}, {2, 1, 0}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - I32Init expected{{{1, 2}, valids}, I32Init{}, {{7}, valids + 1}, {{10, 9, 8}, valids}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW gather_map{{{0, 1}, {}, {1}, {2, 1, 0}}, stream, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + LCW expected{{{{1, 2}, valids}, {}, {{7}, valids + 1}, {{10, 9, 8}, valids}}, stream, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } { // Test gathering on lists that contain nulls, with out-of-bounds indices. - I32Init gather_map{{10, -10}, I32Init{}, {1}, {2, -10, 0}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, - NULLIFY, - stream, - mr.get_output_mr()); - I32Init expected{ - {{0, 0}, nulls_at({0, 1})}, I32Init{}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW gather_map{{{10, -10}, {}, {1}, {2, -10, 0}}, stream, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + stream, + mr.get_output_mr()); + LCW expected{ + {{{0, 0}, nulls_at({0, 1})}, {}, {{7}, valids + 1}, {{10, 0, 8}, null_at(1)}}, stream, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -239,21 +215,21 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List> { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - I32Init gather_map{{0, -2, -2}, {1}, {1, 0, -1, -5}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, stream, mr}; + LCW gather_map{{{0, -2, -2}, {1}, {1, 0, -1, -5}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{2, 3}, {2, 3}, {2, 3}}, + LCW expected{{{{2, 3}, {2, 3}, {2, 3}}, {{9, 10, 11}}, - {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}; + {{17, 18}, {15, 16}, {-17, -18}, {15, 16}}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -263,21 +239,21 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>, with out-of-bounds gather indices. { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}; - I32Init gather_map{{0, 2, -2}, {1}, {1, 0, -1, -6}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {-17, -18}}}, stream, mr}; + LCW gather_map{{{0, 2, -2}, {1}, {1, 0, -1, -6}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, NULLIFY, stream, mr.get_output_mr()); - I32Init expected{{{{2, 3}, I32Init{}, {2, 3}}, null_at(1)}, + LCW expected{{{{{2, 3}, {}, {2, 3}}, null_at(1)}, {{9, 10, 11}}, - {{{17, 18}, {15, 16}, {-17, -18}, I32Init{}}, null_at(3)}}; + {{{17, 18}, {15, 16}, {-17, -18}, {}}, null_at(3)}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -287,27 +263,27 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>> { // clang-format off - I32Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + LCW list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{I32Init{0}}}, + {{{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}}; - I32Init gather_map{{1}, I32Init{}, {0}, {1}, {0, -1, 1}}; + {{{10, 20}}, {{30}}, {{40, 50}, {60, 70, 80}}}}, stream, mr}; + LCW gather_map{{{1}, {}, {0}, {1}, {0, -1, 1}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - I32Init{}, - {{I32Init{0}}}, + LCW expected{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {}, + {{{0}}}, {{{0, 1, 3}, {5}}}, - {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {I32Init{30}}}}; + {{{10, 20}}, {{40, 50}, {60, 70, 80}}, {{30}}}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -316,31 +292,30 @@ TYPED_TEST(SegmentedGatherTest, GatherNested) // List>>, with out-of-bounds gather indices. { - I32Init list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + LCW list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, - {{I32Init{0}}}, + {{{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{10, 20}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}}; - I32Init gather_map{{1}, I32Init{}, {0}, {1}, {0, -1, 3, -4}}; - auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, - NULLIFY, - stream, - mr.get_output_mr()); - I32Init expected{ - {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - I32Init{}, - {{I32Init{0}}}, - {{{0, 1, 3}, {5}}}, - {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, I32Init{}, I32Init{}}, nulls_at({2, 3})}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + {{{10, 20}}, {{30}}, {{40, 50}, {60, 70, 80}}}}, + stream, + mr}; + LCW gather_map{{{1}, {}, {0}, {1}, {0, -1, 3, -4}}, stream, mr}; + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + stream, + mr.get_output_mr()); + LCW expected{{{{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + {}, + {{{0}}}, + {{{0, 1, 3}, {5}}}, + {{{{10, 20}}, {{40, 50}, {60, 70, 80}}, {}, {}}, nulls_at({2, 3})}}, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -354,21 +329,21 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) // List> { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - I32Init gather_map{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, stream, mr}; + LCW gather_map{{{1, 0}, {1, 2, 0}, {4, 3, 2, 1, 0}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{4, 5}, {2, 3}}, + LCW expected{{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; + {{17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -378,21 +353,21 @@ TYPED_TEST(SegmentedGatherTest, GatherOutOfOrder) // List>, with out-of-bounds gather indices. { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - I32Init gather_map{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, stream, mr}; + LCW gather_map{{{1, 0}, {3, -1, -4}, {5, 4, 3, 2, 1, 0}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, NULLIFY, stream, mr.get_output_mr()); - I32Init expected{{{4, 5}, {2, 3}}, - {{I32Init{}, {12, 13, 14}, I32Init{}}, nulls_at({0, 2})}, - {{I32Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + LCW expected{{{{4, 5}, {2, 3}}, + {{{}, {12, 13, 14}, {}}, nulls_at({0, 2})}, + {{{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -410,21 +385,21 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) // List> { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - I32Init gather_map{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, stream, mr}; + LCW gather_map{{{-1, 0}, {-2, -1, 0}, {-5, -4, -3, -2, -1, 0}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{4, 5}, {2, 3}}, + LCW expected{{{{4, 5}, {2, 3}}, {{9, 10, 11}, {12, 13, 14}, {6, 7, 8}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -433,21 +408,21 @@ TYPED_TEST(SegmentedGatherTest, GatherNegatives) // List>, with out-of-bounds gather indices. { // clang-format off - I32Init list{{{2, 3}, {4, 5}}, + LCW list{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, - {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}; - I32Init gather_map{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}; + {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}}, stream, mr}; + LCW gather_map{{{-1, 0}, {-2, -1, -4}, {-6, -4, -3, -2, -1, 0}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, NULLIFY, stream, mr.get_output_mr()); - I32Init expected{{{4, 5}, {2, 3}}, - {{{9, 10, 11}, {12, 13, 14}, I32Init{}}, null_at(2)}, - {{I32Init{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}; + LCW expected{{{{4, 5}, {2, 3}}, + {{{9, 10, 11}, {12, 13, 14}, {}}, null_at(2)}, + {{{}, {17, 18}, {17, 18}, {17, 18}, {17, 18}, {15, 16}}, null_at(0)}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -467,23 +442,23 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) // List> { // clang-format off - I32Init list{{{{2, 3}, valids}, {4, 5}}, + LCW list{{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, valids}, {{15, 16}, {17, 18}, {17, 18}, {17, 18}, {17, 18}}, - {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}; - I32Init gather_map{{0, 1}, {0, 2}, I32Init{}, {0, 1, 4}}; + {{{{25, 26}, valids}, {27, 28}, {{29, 30}, valids}, {31, 32}, {33, 34}}, valids}}, stream, mr}; + LCW gather_map{{{0, 1}, {0, 2}, {}, {0, 1, 4}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{{2, 3}, valids}, {4, 5}}, + LCW expected{{{{{2, 3}, valids}, {4, 5}}, {{{6, 7, 8}, {12, 13, 14}}, no_nulls()}, - I32Init{}, - {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}; + {}, + {{{{25, 26}, valids}, {27, 28}, {33, 34}}, valids}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -493,25 +468,25 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedNulls) // List>>> { // clang-format off - I32Init list{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + LCW list{{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{I32Init{0}}}, + {{{0}}}, {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, {{0, 1, 3}, {5}}, {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; - I32Init gather_map{{1, 2, 4}}; + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, stream, mr}; + LCW gather_map{{{1, 2, 4}}, stream, mr}; auto const results = - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(gather_map, stream, mr)}, + cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, - {{I32Init{0}}}, - {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}; + LCW expected{{{{{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}}, + {{{0}}}, + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}}}, stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), + expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); @@ -526,22 +501,24 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const stream = this->stream(); auto const mr = this->resources(); - auto const list = I32Init::nested( - {{{2, 3}, I32Init{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, I32Init::nested({I32Init{}})}); - // Per-row singleton lists: brace LCWs (I32Init{{0},{0},{0}} flattens to one list of three). - auto const gather_map = LCW({{0}, {0}, {0}}); - auto results = cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + LCW list{ + LCW::nested({{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, LCW::nested({{}})}), + stream, + mr}; + // Per-row singleton lists: {{0},{0},{0}} flattens to one list of three. + LCW gather_map({{0}, {0}, {0}}, stream, mr); + auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{gather_map}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - auto const expected = I32Init::nested( - {{{2, 3}}, {{6, 7, 8}}, I32Init::nested({I32Init{}})}); // skip one null, gather one null. - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), - LCW(expected, stream, mr), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW expected{ + LCW::nested( + {{{2, 3}}, {{6, 7, 8}}, LCW::nested({{}})}), // skip one null, gather one null. + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TYPED_TEST(SegmentedGatherTest, GatherSliced) @@ -552,56 +529,54 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) auto const mr = this->resources(); { - I32Init a{ - {{1, 1, 1}, {2, 2}, {3, 3}}, - {{4, 4, 4}, {5, 5}, {6, 6}}, - {{7, 7, 7}, {8, 8}, {9, 9}}, - {{10, 10, 10}, {11, 11}, {12, 12}}, - {{20, 20, 20, 20}, {25}}, - {{30, 30, 30, 30}, {40}}, - {{50, 50, 50, 50}, {6, 13}}, - {{70, 70, 70, 70}, {80}}, - }; - auto const col = LCW(a, stream, mr); + LCW col{{ + {{1, 1, 1}, {2, 2}, {3, 3}}, + {{4, 4, 4}, {5, 5}, {6, 6}}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{10, 10, 10}, {11, 11}, {12, 12}}, + {{20, 20, 20, 20}, {25}}, + {{30, 30, 30, 30}, {40}}, + {{50, 50, 50, 50}, {6, 13}}, + {{70, 70, 70, 70}, {80}}, + }, + stream, + mr}; + auto const split_a = cudf::split(col, {3}, stream); { - I32Init list{{1, 2}, {0, 2}, {0, 1}}; - auto const map_col = LCW(list, stream, mr); + LCW map_col{{{1, 2}, {0, 2}, {0, 1}}, stream, mr}; + auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[0]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{ - {{2, 2}, {3, 3}}, - {{4, 4, 4}, {6, 6}}, - {{7, 7, 7}, {8, 8}}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), - result->view(), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW expected{{ + {{2, 2}, {3, 3}}, + {{4, 4, 4}, {6, 6}}, + {{7, 7, 7}, {8, 8}}, + }, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } { - I32Init list{{0, 1}, I32Init{}, I32Init{}, {0, 1}, I32Init{}}; - auto const map_col = LCW(list, stream, mr); + LCW map_col{{{0, 1}, {}, {}, {0, 1}, {}}, stream, mr}; + auto const gather_map = cudf::lists_column_view{map_col}; auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{split_a[1]}, gather_map, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - I32Init expected{ - {{10, 10, 10}, {11, 11}}, I32Init{}, I32Init{}, {{50, 50, 50, 50}, {6, 13}}, I32Init{}}; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), - result->view(), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW expected{ + {{{10, 10, 10}, {11, 11}}, {}, {}, {{50, 50, 50, 50}, {6, 13}}, {}}, stream, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -609,38 +584,38 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // List>> { - I32Init list{ - // slice 0 - {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, - - {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, - {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, - - // slice 1 - {{I32Init{0}}}, - {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - - // slice 2 - {{{{{10, 20}, valids}}, {I32Init{30}}, {{40, 50}, {60, 70, 80}}}, valids}, - {{{{10, 20, 30}}, {I32Init{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}; + LCW col{ + {// slice 0 + {{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}, + + {{{15, 16}, {{27, 28}, valids}, {{37, 38}, valids}, {47, 48}, {57, 58}}, + {{11, 12}, {{42, 43, 44}, valids}, {{77, 78}, valids}}}, + + // slice 1 + {{{0}}}, + {{{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}}, + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + + // slice 2 + {{{{{10, 20}, valids}}, {{30}}, {{40, 50}, {60, 70, 80}}}, valids}, + {{{{10, 20, 30}}, {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, valids}}, + stream, + mr}; - auto const col = LCW(list, stream, mr); - auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); + auto sliced = cudf::slice(col, {0, 1, 2, 5, 5, 7}, stream); // gather from slice 0 { - I32Init map{{0, 1}}; - auto result = - cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, - cudf::lists_column_view{LCW(map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - I32Init expected{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + LCW map{{{0, 1}}, stream, mr}; + auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[0]}, + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + LCW expected{{{{{2, 3}, {4, 5}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}}}, stream, mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, @@ -650,24 +625,26 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // gather from slice 1 { - I32Init map{{0}, {1, 2, 0, 1}, {0, 1, 2}}; - auto result = - cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, - cudf::lists_column_view{LCW(map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - I32Init expected{ - {{I32Init{0}}}, - - {{{0, 1, 3}, {5}}, - {{11, 12, 13, 14, 15}, {16, 17}, {0}}, - {{10}, {20, 30, 40, 50}, {60, 70, 80}}, - {{0, 1, 3}, {5}}}, - - {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, - }; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + LCW map{{{0}, {1, 2, 0, 1}, {0, 1, 2}}, stream, mr}; + auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[1]}, + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + LCW expected{ + { + {{{0}}}, + + {{{0, 1, 3}, {5}}, + {{11, 12, 13, 14, 15}, {16, 17}, {0}}, + {{10}, {20, 30, 40, 50}, {60, 70, 80}}, + {{0, 1, 3}, {5}}}, + + {{{{1, 6}, {60, 70, 80, 100}}, {{10, 11, 13}, {15}}, {{11, 12, 13, 14, 15}}}, valids}, + }, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, @@ -677,30 +654,31 @@ TYPED_TEST(SegmentedGatherTest, GatherSliced) // gather from slice 2 { - I32Init map{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}; - auto result = - cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, - cudf::lists_column_view{LCW(map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); + LCW map{{{1, 0, 0, 1, 1, 0}, {1, 0, 0, 1, 1, 2}}, stream, mr}; + auto result = cudf::lists::segmented_gather(cudf::lists_column_view{sliced[2]}, + cudf::lists_column_view{map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); std::vector expected_valids = {false, true, true, false, false, true}; - I32Init expected{{{{I32Init{30}}, + LCW expected{{{{{{30}}, {{{10, 20}, valids}}, {{{10, 20}, valids}}, - {I32Init{30}}, - {I32Init{30}}, + {{30}}, + {{30}}, {{{10, 20}, valids}}}, expected_valids.begin()}, - {{{I32Init{30}}, + {{{{30}}, {{10, 20, 30}}, {{10, 20, 30}}, - {I32Init{30}}, - {I32Init{30}}, + {{30}}, + {{30}}, {{{20, 30}, valids}, {62, 72, 82}}}, - expected_valids.begin()}}; - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(LCW(expected, stream, mr), + expected_valids.begin()}}, + stream, + mr}; + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, @@ -720,40 +698,36 @@ TEST_F(SegmentedGatherTestString, StringGather) // List { - StrInit list{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; - I8Init gather_map{{0, 1, 3, 2}, {1, 0, 3, 2}, I8Init{}}; - StrInit expected{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, StrInit{}}; - auto const result = cudf::lists::segmented_gather( - cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{cudf::test::lists_column_wrapper(gather_map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), - result->view(), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + LCW list{{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, stream, mr}; + cudf::test::lists_column_wrapper gather_map{ + {{0, 1, 3, 2}, {1, 0, 3, 2}, {}}, stream, mr}; + LCW expected{{{"a", "b", "d", "c"}, {"22", "1", "4", "333"}, {}}, stream, mr}; + auto const result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // List, with out-of-order gather indices. { - StrInit list{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}; - I8Init gather_map{{0, 1, 3, 4}, {1, -5, 3, 2}, I8Init{}}; - StrInit expected{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, + LCW list{{{"a", "b", "c", "d"}, {"1", "22", "333", "4"}, {"x", "y", "z"}}, stream, mr}; + cudf::test::lists_column_wrapper gather_map{ + {{0, 1, 3, 4}, {1, -5, 3, 2}, {}}, stream, mr}; + LCW expected{{{{"a", "b", "d", "c"}, cudf::test::iterators::null_at(3)}, {{"22", "1", "4", "333"}, cudf::test::iterators::null_at(1)}, - StrInit{}}; - auto result = cudf::lists::segmented_gather( - cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{cudf::test::lists_column_wrapper(gather_map, stream, mr)}, - NULLIFY, - stream, - mr.get_output_mr()); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(LCW(expected, stream, mr), - result->view(), - cudf::test::debug_output_level::FIRST_ERROR, - stream, - mr); + {}}, + stream, + mr}; + auto result = cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{gather_map}, + NULLIFY, + stream, + mr.get_output_mr()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + expected, result->view(), cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -767,14 +741,13 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) // List { - I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - I32Init gather_map{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}; + LCW list_col{ + {{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, stream, mr}; + LCW gather_map_col{{{3, 2, 1, 0}, {0}, {0, 1}, {0, 2, 1}, {0}, {1}}, stream, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - I32Init expected{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}; - auto const list_col = LCW(list, stream, mr); - auto const gather_map_col = LCW(gather_map, stream, mr); - auto const expected_col = LCW(expected, stream, mr); - auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, + LCW expected_col{{{4, 3, 2, 1}, {5}, {6, 7}, {8, 10, 9}, {11}, {14}}, stream, mr}; + + auto const results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, cudf::lists_column_view{gather_map_col}, cudf::out_of_bounds_policy::DONT_CHECK, stream, @@ -823,14 +796,14 @@ TEST_F(SegmentedGatherTestFloat, GatherMapSliced) // List, with out-of-bounds gather indices. { - I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}; - I32Init gather_map{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}; + LCW list_col{ + {{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}, {11, 12}, {13, 14, 15, 16}}, stream, mr}; + LCW gather_map_col{{{3, -5, 1, 0}, {0}, {0, 1}, {0, 2, 3}, {0}, {1}}, stream, mr}; // gather_map.offset: 0, 4, 5, 7, 10, 11, 12 - I32Init expected{{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}; - auto const list_col = LCW(list, stream, mr); - auto const gather_map_col = LCW(gather_map, stream, mr); - auto const expected_col = LCW(expected, stream, mr); - auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, + LCW expected_col{ + {{{4, 0, 2, 1}, null_at(1)}, {5}, {6, 7}, {{8, 10, 9}, null_at(2)}, {11}, {14}}, stream, mr}; + + auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list_col}, cudf::lists_column_view{gather_map_col}, NULLIFY, stream, @@ -886,58 +859,55 @@ TEST_F(SegmentedGatherTestFloat, Fails) auto const mr = this->resources(); // List - I32Init list{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}; - I8Init size_mismatch_map{{3, 2, 1, 0}, {0}, {0, 1}}; + LCW list{{{1, 2, 3, 4}, {5}, {6, 7}, {8, 9, 10}}, stream, mr}; + cudf::test::lists_column_wrapper size_mismatch_map{ + {{3, 2, 1, 0}, {0}, {0, 1}}, stream, mr}; cudf::test::fixed_width_column_wrapper nonlist_map0{{1, 2, 0, 1}, stream, mr}; cudf::test::strings_column_wrapper nonlist_map1{{"1", "2", "0", "1"}, stream, mr}; - StrInit nonlist_map2{{"1", "2", "0", "1"}}; + LCW nonlist_map2{{{"1", "2", "0", "1"}}, stream, mr}; // Input must be a list of integer indices. It should fail for integers, // strings, or lists containing anything other than integers. - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nonlist_map0}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()), cudf::logic_error); - EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, cudf::lists_column_view{nonlist_map1}, cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()), cudf::logic_error); - EXPECT_THROW(cudf::lists::segmented_gather( - cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{LCW(nonlist_map2, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()), + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{nonlist_map2}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), cudf::logic_error); auto valids = cudf::test::iterators::valids_at_multiples_of(2); - I8Init nulls_map{{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}; + cudf::test::lists_column_wrapper nulls_map{ + {{{3, 2, 1, 0}, {0}, {0}, {0, 1}}, valids}, stream, mr}; // Nulls are not supported in the gather map. - EXPECT_THROW( - cudf::lists::segmented_gather( - cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{cudf::test::lists_column_wrapper(nulls_map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()), - std::invalid_argument); + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{nulls_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), + std::invalid_argument); // Gather map and list column sizes must be the same. - EXPECT_THROW( - cudf::lists::segmented_gather(cudf::lists_column_view{LCW(list, stream, mr)}, - cudf::lists_column_view{cudf::test::lists_column_wrapper( - size_mismatch_map, stream, mr)}, - cudf::out_of_bounds_policy::DONT_CHECK, - stream, - mr.get_output_mr()), - cudf::logic_error); + EXPECT_THROW(cudf::lists::segmented_gather(cudf::lists_column_view{list}, + cudf::lists_column_view{size_mismatch_map}, + cudf::out_of_bounds_policy::DONT_CHECK, + stream, + mr.get_output_mr()), + cudf::logic_error); } #if defined(__GNUC__) && (__GNUC__ >= 14) diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index d1accb9874e9..a9f749863fb0 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1606,3 +1606,25 @@ TEST_F(ListsColumnInitializerHarnessTest, SingleChildNestedInitUsesExplicitResou CUDF_TEST_EXPECT_COLUMNS_EQUAL( *built, expected, cudf::test::debug_output_level::FIRST_ERROR, st, mr); } + +TEST_F(ListsColumnInitializerHarnessTest, EmptyStringRowUsesExplicitResources) +{ + using LCW = cudf::test::lists_column_wrapper; + + auto const st = this->stream(); + auto const mr = this->resources(); + + std::unique_ptr built; + { + auto fail_on_current = this->harness().fail_on_current_device_resource_use(); + auto list = LCW::make_one_empty_row_column(false, st, mr); + this->harness().synchronize(st); + built = list.release(); + } + + cudf::lists_column_view list{*built}; + EXPECT_EQ(list.size(), 1); + EXPECT_EQ(list.null_count(), 1); + EXPECT_EQ(list.child().type().id(), cudf::type_id::STRING); + EXPECT_EQ(list.child().size(), 0); +} From f3cc7aadc94a06eb2e0fe779e9636ceba6c94080 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 22 Sep 2026 19:15:19 +0000 Subject: [PATCH 17/21] Preserve list test data with inline initializers --- cpp/tests/copying/concatenate_tests.cpp | 141 ++++++++++------ .../concatenate_list_elements_tests.cpp | 152 ++++++------------ .../lists_column_wrapper_tests.cpp | 27 ++-- 3 files changed, 154 insertions(+), 166 deletions(-) diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index 8c1a09938e29..295180a9f165 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -1314,35 +1314,46 @@ TEST_F(ListsColumnTest, SlicedColumns) } { - auto const empty = decltype(LCW::nested({})){}; - auto const a0 = - LCW::nested({{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}); - auto const a1 = LCW::nested({empty, LCW::nested({empty}), {{6, 6}, {2}}}); - auto const a2 = LCW::nested({{empty, empty}}); - auto const a3 = LCW::nested({empty, empty, {{10, 10, 10}, {11, 11}, {12, 12}}, empty}); - LCW a({a0, a1, a2, a3}); + LCW a{{{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, + {{}, {{}}, {{6, 6}, {2}}}, + {{}, {}}, + {{}, {}, {{10, 10, 10}, {11, 11}, {12, 12}}, {}}}; auto split_a = cudf::split(a, {2}); - auto const b0 = LCW::nested({LCW::nested({empty})}); - auto const b1 = LCW::nested({empty, LCW::nested({empty})}); - auto const b2 = LCW::nested({{{1, 2, 9}, empty}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}); - auto const b3 = LCW::nested({LCW::nested({empty})}); - LCW b({b0, b1, b2, b3}); + LCW b{ + {{{}}}, + {{}, {{}}}, + {{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, + {{{}}}, + }; auto split_b = cudf::split(b, {2}); - LCW expected0({a0, a1, b0, b1}); + LCW expected0{{{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, + {{}, {{}}, {{6, 6}, {2}}}, + {{{}}}, + {{}, {{}}}}; auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - LCW expected1({a0, a1, b2, b3}); + LCW expected1{ + {{{1, 1, 1}, {2, 2}}, {{3, 3}}, {{10, 9, 16}, {8, 7, 1}, {6, 8, 2}}}, + {{}, {{}}, {{6, 6}, {2}}}, + {{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, + {{{}}}, + }; auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - LCW expected2({a2, a3, b0, b1}); + LCW expected2{{{}, {}}, {{}, {}, {{10, 10, 10}, {11, 11}, {12, 12}}, {}}, {{{}}}, {{}, {{}}}}; auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - LCW expected3({a2, a3, b2, b3}); + LCW expected3{ + {{}, {}}, + {{}, {}, {{10, 10, 10}, {11, 11}, {12, 12}}, {}}, + {{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, + {{{}}}, + }; auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } @@ -1355,71 +1366,101 @@ TEST_F(ListsColumnTest, SlicedColumnsWithNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); { - auto const a0 = LCW::nested({{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}); - auto const a1 = LCW::nested({{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids); - auto const a2 = LCW::nested({{7, 7, 7}, {8, 8}, {9, 9}}); - auto const a3 = LCW::nested({{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids); - LCW a({a0, a1, a2, a3}); + LCW a{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, + {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}}; auto split_a = cudf::split(a, {3}); - auto const b0 = LCW::nested({{{-1, -1, -1, -1}, valids}, {-2}}, valids); - auto const b1 = LCW::nested({{{-3, -3, -3, -3}, valids}, {-4}}, valids); - auto const b2 = LCW::nested({{{-5, -5, -5, -5}, valids}, {-6}}, valids); - auto const b3 = LCW::nested({{{-7, -7, -7, -7}, valids}, {-8}}, valids); - LCW b({b0, b1, b2, b3}); + LCW b{{{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, + {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, + {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}, + {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; auto split_b = cudf::split(b, {3}); - LCW expected0({a0, a1, a2, b0, b1, b2}); + LCW expected0{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, + {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, + {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, + {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}}; auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - LCW expected1({a0, a1, a2, b3}); + LCW expected1{{{{1, 1, 1}, valids}, {2, 2}, {{3, 3}, valids}}, + {{{4, 4, 4}, {{5, 5}, valids}, {6, 6}}, valids}, + {{7, 7, 7}, {8, 8}, {9, 9}}, + {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - LCW expected2({a3, b0, b1, b2}); + LCW expected2{{{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}, + {{{{-1, -1, -1, -1}, valids}, {-2}}, valids}, + {{{{-3, -3, -3, -3}, valids}, {-4}}, valids}, + {{{{-5, -5, -5, -5}, valids}, {-6}}, valids}}; auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - LCW expected3({a3, b3}); + LCW expected3{{{{10, 10, 10}, {11, 11}, {{12, 12}, valids}}, valids}, + {{{{-7, -7, -7, -7}, valids}, {-8}}, valids}}; auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } { - auto const a0 = - LCW::nested({LCW::nested({{{1, 1, 1}, valids}, {2, 2}}), - LCW::nested({{3, 3}}, valids), - LCW::nested({{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}})}); - auto const a1 = - LCW::nested({{}, LCW::nested({{}}, valids), LCW::nested({{6, 6}, {2}})}, valids); - auto const a2 = LCW::nested({LCW::nested({{}, {}}, valids)}); - auto const a3 = - LCW::nested({{}, {}, LCW::nested({{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids), {}}); - LCW a({a0, a1, a2, a3}); + LCW a{{{{{1, 1, 1}, valids}, {2, 2}}, + {{{3, 3}}, valids}, + {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, + {{{}, LCW::nested({{}}, valids), {{6, 6}, {2}}}, valids}, + {LCW::nested({{}, {}}, valids)}, + {{}, {}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, {}}}; auto split_a = cudf::split(a, {3}); - auto const b0 = LCW::nested({LCW::nested({{}}, valids)}); - auto const b1 = LCW::nested({{}, LCW::nested({{}}, valids)}, valids); - auto const b2 = LCW::nested( - {LCW::nested({{1, 2, 9}, {}}), LCW::nested({{5, 6, 7, 8, 9}, {0}, {15, 17}})}, valids); - auto const b3 = LCW::nested({{}}); - LCW b({b0, b1, b2, b3}); + LCW b{ + {LCW::nested({{}}, valids)}, + {{{}, LCW::nested({{}}, valids)}, valids}, + {{{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, + {{{}}}, + }; auto split_b = cudf::split(b, {3}); - LCW expected0({a0, a1, a2, b0, b1, b2}); + LCW expected0{ + {{{{1, 1, 1}, valids}, {2, 2}}, + {{{3, 3}}, valids}, + {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, + {{{}, LCW::nested({{}}, valids), {{6, 6}, {2}}}, valids}, + {LCW::nested({{}, {}}, valids)}, + {LCW::nested({{}}, valids)}, + {{{}, LCW::nested({{}}, valids)}, valids}, + {{{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, + }; auto result0 = cudf::concatenate(std::vector({split_a[0], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result0, expected0); - LCW expected1({a0, a1, a2, b3}); + LCW expected1{ + {{{{1, 1, 1}, valids}, {2, 2}}, + {{{3, 3}}, valids}, + {{{10, 9, 16}, valids}, {8, 7, 1}, {{6, 8, 2}, valids}}}, + {{{}, LCW::nested({{}}, valids), {{6, 6}, {2}}}, valids}, + {LCW::nested({{}, {}}, valids)}, + {{{}}}, + }; auto result1 = cudf::concatenate(std::vector({split_a[0], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result1, expected1); - LCW expected2({a3, b0, b1, b2}); + LCW expected2{ + {{}, {}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, {}}, + {LCW::nested({{}}, valids)}, + {{{}, LCW::nested({{}}, valids)}, valids}, + {{{{1, 2, 9}, {}}, {{5, 6, 7, 8, 9}, {0}, {15, 17}}}, valids}, + }; auto result2 = cudf::concatenate(std::vector({split_a[1], split_b[0]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result2, expected2); - LCW expected3({a3, b3}); + LCW expected3{ + {{}, {}, {{{10, 10, 10}, {{11, 11}, valids}, {12, 12}}, valids}, {}}, + {{{}}}, + }; auto result3 = cudf::concatenate(std::vector({split_a[1], split_b[1]})); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result3, expected3); } diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index c88bb49499e8..82480efdf0ae 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -23,12 +23,6 @@ using IntCol = cudf::test::fixed_width_column_wrapper; constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::FIRST_ERROR}; constexpr int32_t null{0}; -template -auto build_lists_init(T const& list, Ts const&... lists) -{ - return T::nested({list, lists...}); -} - } // namespace struct ConcatenateListElementsTest : public cudf::test::BaseFixture {}; @@ -60,10 +54,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row1 = ListsCol::nested({{}}); - auto row2 = ListsCol::nested({{7, 8}, {9, 10}}); - auto const col = ListsCol(build_lists_init(row0, row1, row2)); + auto const col = ListsCol{{{1, 2}, {3}, {4, 5, 6}}, {{}}, {{7, 8}, {9, 10}}}; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol({{1, 2, 3, 4, 5, 6}, {}, {7, 8, 9, 10}}); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); @@ -73,22 +64,9 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsNoNull) { using ListsCol = cudf::test::lists_column_wrapper; - auto row00 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row01 = ListsCol::nested({{}}); - auto row02 = ListsCol::nested({{7, 8}, {9, 10}}); - auto row0 = build_lists_init(row00, row01, row02); - - auto row10 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row11 = ListsCol::nested({{}}); - auto row12 = ListsCol::nested({{7, 8}, {9, 10}}); - auto row1 = build_lists_init(row10, row11, row12); - - auto row20 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row21 = ListsCol::nested({{}}); - auto row22 = ListsCol::nested({{7, 8}, {9, 10}}); - auto row2 = build_lists_init(row20, row21, row22); - - auto const col = ListsCol(build_lists_init(row0, row1, row2)); + auto const col = ListsCol{{{{1, 2}, {3}, {4, 5, 6}}, {{}}, {{7, 8}, {9, 10}}}, + {{{1, 2}, {3}, {4, 5, 6}}, {{}}, {{7, 8}, {9, 10}}}, + {{{1, 2}, {3}, {4, 5, 6}}, {{}}, {{7, 8}, {9, 10}}}}; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = ListsCol({{{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, {{1, 2}, {3}, {4, 5, 6}, {}, {7, 8}, {9, 10}}, @@ -98,10 +76,9 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsNoNull) TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnNoNull) { - auto row0 = StrListsCol::nested({{"Tomato", "Apple"}, {"Orange"}}); - auto row1 = StrListsCol::nested({{"Banana", "Kiwi", "Cherry"}, {"Lemon", "Peach"}}); - auto row2 = StrListsCol::nested({{"Coconut"}, {}}); - auto const col = StrListsCol(build_lists_init(row0, row1, row2)); + auto const col = StrListsCol{{{"Tomato", "Apple"}, {"Orange"}}, + {{"Banana", "Kiwi", "Cherry"}, {"Lemon", "Peach"}}, + {{"Coconut"}, {}}}; auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = StrListsCol( {{"Tomato", "Apple", "Orange"}, {"Banana", "Kiwi", "Cherry", "Lemon", "Peach"}, {"Coconut"}}); @@ -111,22 +88,19 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnNoNull) TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol::nested( - {{{1, null, 3, 4}, null_at(1)}, {{10, 11, 12, null}, null_at(3)}, {} /*NULL*/}, null_at(2)); - auto row1 = ListsCol::nested({{{null, 2, 3, 4}, null_at(0)}, - {{13, 14, 15, 16, 17, null}, null_at(5)}, - {{20, null}, null_at(1)}}); - auto row2 = ListsCol::nested( - {{{null, 2, 3, 4}, null_at(0)}, {} /*NULL*/, {{null, 21, null, null}, nulls_at({0, 2, 3})}}, - null_at(1)); - auto row3 = ListsCol::nested({{} /*NULL*/, {{null, 18}, null_at(0)}}, null_at(0)); - auto row4 = ListsCol::nested( - {{{1, 2, null, 4}, null_at(2)}, {{19, 20, null}, null_at(2)}, {22, 23, 24, 25}}); - auto row5 = ListsCol::nested({{{1, 2, 3, null}, null_at(3)}, - {{null}, null_at(0)}, - {{null, null, null, null, null}, all_nulls()}}); - auto row6 = ListsCol::nested({{} /*NULL*/, {} /*NULL*/, {} /*NULL*/}, all_nulls()); - auto const col = ListsCol(build_lists_init(row0, row1, row2, row3, row4, row5, row6)); + auto const col = ListsCol{ + {{{{1, null, 3, 4}, null_at(1)}, {{10, 11, 12, null}, null_at(3)}, {} /*NULL*/}, null_at(2)}, + {{{null, 2, 3, 4}, null_at(0)}, + {{13, 14, 15, 16, 17, null}, null_at(5)}, + {{20, null}, null_at(1)}}, + {{{{null, 2, 3, 4}, null_at(0)}, {} /*NULL*/, {{null, 21, null, null}, nulls_at({0, 2, 3})}}, + null_at(1)}, + {{{} /*NULL*/, {{null, 18}, null_at(0)}}, null_at(0)}, + {{{1, 2, null, 4}, null_at(2)}, {{19, 20, null}, null_at(2)}, {22, 23, 24, 25}}, + {{{1, 2, 3, null}, null_at(3)}, + {{null}, null_at(0)}, + {{null, null, null, null, null}, all_nulls()}}, + ListsCol::nested({{} /*NULL*/, {} /*NULL*/, {} /*NULL*/}, all_nulls())}; // Ignore null list elements. { @@ -164,22 +138,10 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull { using ListsCol = cudf::test::lists_column_wrapper; - auto row00 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row01 = ListsCol::nested({{}}); /*NULL*/ - auto row02 = ListsCol::nested({{7, 8}, {9, 10}}); - auto row0 = ListsCol::nested({std::move(row00), std::move(row01), std::move(row02)}, null_at(1)); - - auto row10 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6} /*NULL*/}, null_at(2)); - auto row11 = ListsCol::nested({{}}); - auto row12 = ListsCol::nested({{7, 8}, {9, 10}}); - auto row1 = build_lists_init(row10, row11, row12); - - auto row20 = ListsCol::nested({{1, 2}, {3}, {4, 5, 6}}); - auto row21 = ListsCol::nested({{}}); - auto row22 = ListsCol::nested({{{null, 8}, null_at(0)}, {9, 10}}); - auto row2 = build_lists_init(row20, row21, row22); - - auto const col = ListsCol(build_lists_init(row0, row1, row2)); + auto const col = + ListsCol{{{{{1, 2}, {3}, {4, 5, 6}}, {{}} /*NULL*/, {{7, 8}, {9, 10}}}, null_at(1)}, + {{{{1, 2}, {3}, {4, 5, 6} /*NULL*/}, null_at(2)}, {{}}, {{7, 8}, {9, 10}}}, + {{{1, 2}, {3}, {4, 5, 6}}, {{}}, {{{null, 8}, null_at(0)}, {9, 10}}}}; // Ignore null list elements. { @@ -205,14 +167,12 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) { - auto row0 = StrListsCol::nested( + auto const col = StrListsCol{ {{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, - {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}); - auto row1 = StrListsCol::nested( + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}, {{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - {"Lemon", "Peach"}}); - auto row2 = StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1)); - auto const col = StrListsCol(build_lists_init(row0, row1, row2)); + {"Lemon", "Peach"}}, + StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1))}; // Ignore null list elements. { @@ -241,12 +201,10 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) } TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndNulls) { - auto row0 = StrListsCol::nested( - {{"", "", ""}, {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}}); - auto row1 = StrListsCol::nested( - {{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, {""}}); - auto row2 = StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1)); - auto const col = StrListsCol(build_lists_init(row0, row1, row2)); + auto const col = StrListsCol{ + {{"", "", ""}, {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}}, + {{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, {""}}, + StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1))}; // Ignore null list elements. { @@ -313,16 +271,15 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputWithNulls) { using ListsCol = cudf::test::lists_column_wrapper; - auto row0 = ListsCol::nested({{{null, 2, 3}, null_at(0)}, {2, 3}}); - auto row1 = ListsCol::nested({{{3, null, null, 6}, nulls_at({1, 2})}, - {{5, 6, null}, null_at(2)}, - {}, - {{7, null}, null_at(1)}}); - auto row2 = ListsCol::nested({{7, 7, 7}, {{7, 8, null, 0}, null_at(2)}, {1}}); - auto row3 = ListsCol::nested({{9, 10, 11}}); - auto row4 = ListsCol::nested({{}}); - auto row5 = ListsCol::nested({{{12, null, 14, 15}, null_at(1)}, {16}, {17}}); - auto const col_original = ListsCol(build_lists_init(row0, row1, row2, row3, row4, row5)); + auto const col_original = ListsCol{{{{null, 2, 3}, null_at(0)}, {2, 3}}, + {{{3, null, null, 6}, nulls_at({1, 2})}, + {{5, 6, null}, null_at(2)}, + {}, + {{7, null}, null_at(1)}}, + {{7, 7, 7}, {{7, 8, null, 0}, null_at(2)}, {1}}, + {{9, 10, 11}}, + {{}}, + {{{12, null, 14, 15}, null_at(1)}, {16}, {17}}}; { auto const col = cudf::slice(col_original, {0, 3})[0]; @@ -358,24 +315,20 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SlicedColumnsInputWithNulls) TEST_F(ConcatenateListElementsTest, SlicedStringsColumnsInputWithNulls) { - auto row0 = StrListsCol::nested( + auto const col_original = StrListsCol{ {{{"Tomato", "Bear" /*NULL*/, "Apple"}, null_at(1)}, {{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, - {"Coconut"}}); - auto row1 = StrListsCol::nested( + {"Coconut"}}, {{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, {"Coconut"}, - {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}); - auto row2 = StrListsCol::nested( + {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}, {{"Coconut"}, {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, - {"Lemon", "Peach"}}); - auto row3 = StrListsCol::nested( - {{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, - {"Lemon", "Peach"}, - {} /*NULL*/}, - null_at(2)); - auto const col_original = StrListsCol(build_lists_init(row0, row1, row2, row3)); + {"Lemon", "Peach"}}, + {{{{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}, + {"Lemon", "Peach"}, + {} /*NULL*/}, + null_at(2)}}; { auto const col = cudf::slice(col_original, {0, 2})[0]; @@ -789,10 +742,9 @@ TEST_F(ConcatenateListElementsTest, EmptyInnerListColumnChildSizeOne) { // list> with 1 outer row containing 1 empty inner list: [[]] // child.size() == 1; the new guard does not apply here. - // Use build_lists_init to create a proper list> (2-level nesting). - auto inner = IntListsCol::nested({{}}); // list with 1 empty row - auto const col = - IntListsCol(build_lists_init(inner)); // list> with 1 outer row: [[]] + // Use brace nesting to create a proper list> (2-level nesting). + // The child is a list with 1 empty row. + auto const col = IntListsCol{{{}}}; // list> with 1 outer row: [[]] auto const results = cudf::lists::concatenate_list_elements(col); auto const expected = IntListsCol{{}}; // list with 1 empty row: [[]] → [] CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, *results, verbosity); diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index a9f749863fb0..8690a5c043ad 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -688,8 +688,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) using T = TypeParam; // Use nested() to disambiguate between {} == 0 and {} == List{0}. - using LCW = cudf::test::lists_column_wrapper; - auto const empty = decltype(LCW::nested({})){}; + using LCW = cudf::test::lists_column_wrapper; // List>>: // Length : 3 @@ -704,7 +703,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // Offsets : 0, 0 // Children : { - LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}); + LCW list{{{{}}}, {{}}, {}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -749,7 +748,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // Offsets : 0, 0 // Children : { - LCW list({empty, LCW::nested({empty}), LCW::nested({LCW::nested({empty})})}); + LCW list{{}, {{}}, {{{}}}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -796,7 +795,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) // 1, 2, 3 { // { {}, {{{1,2,3}}}, {{}} } - LCW list({empty, LCW::nested({LCW::nested({{1, 2, 3}})}), LCW::nested({empty})}); + LCW list{{}, {{{1, 2, 3}}}, {{}}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -847,7 +846,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{}}}, {{}}, null } std::vector valids{true, true, false}; - LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}, valids.begin()); + LCW list({{{{}}}, {{}}, {}}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -894,7 +893,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{}}}, null, {} } std::vector valids{true, false, true}; - LCW list({LCW::nested({LCW::nested({empty})}), LCW::nested({empty}), empty}, valids.begin()); + LCW list({{{{}}}, {{}}, {}}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -937,7 +936,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, {{}}, {} } std::vector valids{false, true, true}; - LCW list({LCW::nested({}), LCW::nested({empty}), LCW::nested({})}, valids.begin()); + LCW list({{{{}}}, {{}}, {}}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -971,7 +970,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, null, null } std::vector valids{false, false, false}; - LCW list({LCW::nested({}), LCW::nested({}), LCW::nested({})}, valids.begin()); + LCW list({{{{}}}, {{}}, {}}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1000,7 +999,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { null, null, null } std::vector valids{false, false, false}; - LCW list({LCW::nested({}), LCW::nested({}), LCW::nested({})}, valids.begin()); + LCW list({{}, {{{}}}, {{}}}, valids.begin()); cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1033,8 +1032,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {null}, {{}}, {} } std::vector valids{false}; - auto const null_row = LCW::nested({LCW::nested({})}, valids.begin()); - LCW list({null_row, LCW::nested({LCW::nested({})}), LCW::nested({})}); + LCW list{LCW::nested({{{}}}, valids.begin()), {{}}, {}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); @@ -1076,10 +1074,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {{{1, 2, 3}, {4, 5}}}, {{}, {{}}}, {}, {{}, {}} } - LCW list({LCW::nested({{{1, 2, 3}, {4, 5}}}), - {LCW::nested({}), LCW::nested({empty})}, - LCW::nested({}), - {LCW::nested({}), LCW::nested({})}}); + LCW list{{{{1, 2, 3}, {4, 5}}}, {{}, {{}}}, {}, {{}, {}}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 4); From d77a2212b9ebf04d46975c905f2da2c28e2d9dab Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 22 Sep 2026 19:33:28 +0000 Subject: [PATCH 18/21] Move lists wrapper back into column wrapper header --- cpp/include/cudf_test/column_wrapper.hpp | 952 +++++++++++++++++ .../cudf_test/lists_column_wrapper.hpp | 988 ------------------ .../tests/streaming/test_cudf_utils.cpp | 1 - cpp/tests/column/column_test.cpp | 1 - cpp/tests/column/column_view_shallow_test.cpp | 1 - cpp/tests/column/factories_test.cpp | 1 - cpp/tests/copying/concatenate_tests.cpp | 1 - .../copying/copy_if_else_nested_tests.cpp | 1 - cpp/tests/copying/copy_tests.cpp | 1 - cpp/tests/copying/gather_list_tests.cpp | 1 - cpp/tests/copying/gather_struct_tests.cpp | 1 - cpp/tests/copying/get_value_tests.cpp | 1 - cpp/tests/copying/pack_tests.cpp | 1 - .../copying/purge_nonempty_nulls_tests.cpp | 1 - .../copying/scatter_list_scalar_tests.cpp | 1 - cpp/tests/copying/scatter_list_tests.cpp | 1 - .../copying/scatter_struct_scalar_tests.cpp | 1 - cpp/tests/copying/scatter_struct_tests.cpp | 1 - .../copying/segmented_gather_list_tests.cpp | 1 - cpp/tests/copying/slice_tests.cpp | 1 - cpp/tests/copying/split_tests.cpp | 1 - cpp/tests/copying/utility_tests.cpp | 1 - cpp/tests/groupby/collect_list_tests.cpp | 1 - cpp/tests/groupby/collect_set_tests.cpp | 1 - cpp/tests/groupby/keys_tests.cpp | 1 - cpp/tests/groupby/lists_tests.cpp | 1 - cpp/tests/groupby/max_tests.cpp | 1 - cpp/tests/groupby/merge_lists_tests.cpp | 1 - cpp/tests/groupby/merge_sets_tests.cpp | 1 - cpp/tests/groupby/min_tests.cpp | 1 - cpp/tests/groupby/nth_element_tests.cpp | 1 - cpp/tests/groupby/rank_scan_tests.cpp | 1 - cpp/tests/groupby/replace_nulls_tests.cpp | 1 - cpp/tests/groupby/structs_tests.cpp | 1 - cpp/tests/groupby/topk_tests.cpp | 1 - cpp/tests/hashing/md5_test.cpp | 1 - cpp/tests/hashing/murmurhash3_x86_32_test.cpp | 1 - cpp/tests/hashing/sha1_test.cpp | 1 - cpp/tests/hashing/sha224_test.cpp | 1 - cpp/tests/hashing/sha256_test.cpp | 1 - cpp/tests/hashing/sha384_test.cpp | 1 - cpp/tests/hashing/sha512_test.cpp | 1 - cpp/tests/interop/from_arrow_device_test.cpp | 1 - cpp/tests/interop/from_arrow_host_test.cpp | 1 - cpp/tests/interop/from_arrow_stream_test.cpp | 1 - cpp/tests/interop/to_arrow_device_test.cpp | 1 - cpp/tests/interop/to_arrow_host_test.cpp | 1 - cpp/tests/io/cudftable_test.cpp | 1 - .../io/experimental/variant_extract_test.cpp | 1 - cpp/tests/io/json/json_test.cpp | 1 - cpp/tests/io/json/json_writer.cpp | 1 - cpp/tests/io/orc_chunked_reader_test.cu | 1 - cpp/tests/io/orc_test.cpp | 1 - cpp/tests/io/parquet_chunked_reader_test.cu | 1 - cpp/tests/io/parquet_chunked_writer_test.cpp | 1 - cpp/tests/io/parquet_reader_test.cpp | 1 - cpp/tests/io/parquet_v2_test.cpp | 1 - cpp/tests/io/parquet_writer_test.cpp | 1 - cpp/tests/join/join_tests.cpp | 1 - .../concatenate_list_elements_tests.cpp | 1 - .../lists/combine/concatenate_rows_tests.cpp | 1 - cpp/tests/lists/contains_tests.cpp | 1 - cpp/tests/lists/count_elements_tests.cpp | 1 - cpp/tests/lists/explode_tests.cpp | 1 - cpp/tests/lists/extract_tests.cpp | 1 - cpp/tests/lists/reverse_tests.cpp | 1 - cpp/tests/lists/sequences_tests.cpp | 1 - .../difference_distinct_tests.cpp | 1 - .../set_operations/have_overlap_tests.cpp | 1 - .../intersect_distinct_tests.cpp | 1 - .../set_operations/union_distinct_tests.cpp | 1 - cpp/tests/lists/sort_lists_tests.cpp | 1 - .../stream_compaction/apply_mask_tests.cpp | 1 - .../stream_compaction/distinct_tests.cpp | 1 - cpp/tests/merge/merge_test.cpp | 1 - .../partitioning/hash_partition_test.cpp | 1 - cpp/tests/partitioning/partition_test.cpp | 1 - .../quantiles/percentile_approx_test.cpp | 1 - cpp/tests/reductions/collect_ops_tests.cpp | 1 - cpp/tests/reductions/distinct_count_tests.cpp | 1 - cpp/tests/reductions/list_rank_test.cpp | 1 - cpp/tests/reductions/reduction_tests.cpp | 1 - cpp/tests/reductions/unique_count_tests.cpp | 1 - cpp/tests/reshape/byte_cast_tests.cpp | 1 - .../reshape/interleave_columns_tests.cpp | 1 - cpp/tests/rolling/collect_ops_test.cpp | 1 - cpp/tests/rolling/empty_input_test.cpp | 1 - cpp/tests/rolling/lead_lag_test.cpp | 1 - cpp/tests/rolling/offset_row_window_test.cpp | 1 - .../rolling/range_rolling_window_test.cpp | 1 - cpp/tests/scalar/factories_test.cpp | 1 - cpp/tests/scalar/scalar_test.cpp | 1 - cpp/tests/search/search_list_test.cpp | 1 - cpp/tests/search/search_struct_test.cpp | 1 - cpp/tests/sort/is_sorted_tests.cpp | 1 - cpp/tests/sort/rank_test.cpp | 1 - cpp/tests/sort/sort_nested_types_tests.cpp | 1 - cpp/tests/sort/sort_test.cpp | 1 - cpp/tests/sort/top_k_tests.cpp | 1 - .../stream_compaction/apply_mask_tests.cpp | 1 - .../stream_compaction/distinct_tests.cpp | 1 - .../stable_distinct_tests.cpp | 1 - cpp/tests/stream_compaction/unique_tests.cpp | 1 - cpp/tests/streams/copying_test.cpp | 1 - .../io/experimental/hybrid_scan_test.cpp | 1 - cpp/tests/streams/io/orc_test.cpp | 1 - cpp/tests/streams/io/parquet_test.cpp | 1 - cpp/tests/streams/lists_test.cpp | 1 - cpp/tests/streams/strings/combine_test.cpp | 1 - cpp/tests/streams/strings/convert_test.cpp | 1 - .../combine/join_list_elements_tests.cpp | 1 - cpp/tests/strings/extract_tests.cpp | 1 - cpp/tests/strings/find_multiple_tests.cpp | 1 - cpp/tests/strings/findall_tests.cpp | 1 - cpp/tests/strings/format_lists_tests.cpp | 1 - cpp/tests/strings/split_tests.cpp | 1 - cpp/tests/structs/structs_column_tests.cpp | 1 - cpp/tests/structs/utilities_tests.cpp | 1 - cpp/tests/table/table_tests.cpp | 1 - cpp/tests/text/minhash_tests.cpp | 1 - cpp/tests/text/ngrams_tests.cpp | 1 - cpp/tests/text/subword_tests.cpp | 1 - cpp/tests/text/tokenize_tests.cpp | 1 - cpp/tests/transform/one_hot_encode_tests.cpp | 1 - cpp/tests/transform/row_bit_count_test.cu | 1 - cpp/tests/unary/math_ops_test.cpp | 1 - .../column_utilities_tests.cpp | 1 - .../lists_column_wrapper_tests.cpp | 1 - .../utilities_tests/type_check_tests.cpp | 1 - 129 files changed, 952 insertions(+), 1115 deletions(-) delete mode 100644 cpp/include/cudf_test/lists_column_wrapper.hpp diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index d57388aa50e7..9366d40b1ea0 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -40,7 +40,9 @@ #include #include #include +#include #include +#include #include namespace CUDF_EXPORT cudf { @@ -1634,5 +1636,955 @@ class structs_column_wrapper : public detail::column_wrapper { } }; +//! @cond Doxygen_Suppress + +// Forward declaration for lists_column_initializer +template +class lists_column_wrapper; + +template +concept iterator_like = requires(Iterator i) { + *i; + ++i; +}; + +template +concept validity_iterator = + iterator_like && requires(Iterator i) { static_cast(*i); }; + +/** + * @brief Host-side recursive initializer tree for constructing list columns with an + * explicit stream and memory resources at every nesting level. + * + * Example: + * @code{.cpp} + * using LCW = cudf::test::lists_column_wrapper; + * LCW col{{{1, 2}, {3}}, stream, mr}; + * @endcode + * + * Leaf and nested constructors accept the existing validity iterators + * (`valids`, `null_at(...)`, etc.) and materialize them into owned storage. + * + * @tparam T Host leaf element type (e.g. `int32_t` or `std::string`) + */ +template +class lists_column_initializer { + public: + using value_type = T; + + struct string_element { + string_element(char const* value) : value_{value} {} + string_element(std::string value) : value_{std::move(value)} {} + + std::string value_; + }; + /** + * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested + * empty `initializer_list` constructors. + */ + lists_column_initializer() = default; + + /** + * @brief Construct a leaf from scalar values. + * + * @param values Leaf element values + */ + template + lists_column_initializer(std::initializer_list values) + requires(!std::is_same_v && std::is_convertible_v) + : values_(values.begin(), values.end()) + { + } + + template + lists_column_initializer(First first, Rest... rest) + requires(sizeof...(Rest) > 0 && !std::is_same_v && + std::is_convertible_v && (std::is_convertible_v && ...)) + : values_{static_cast(first), static_cast(rest)...} + { + } + + lists_column_initializer(std::initializer_list values) + requires(std::is_same_v) + { + values_.reserve(values.size()); + std::transform( + values.begin(), values.end(), std::back_inserter(values_), [](auto const& value) { + return value.value_; + }); + } + + template + lists_column_initializer(InputIterator begin, InputIterator end) : values_(begin, end) + { + } + + /** + * @brief Construct a leaf from scalar values and a validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param values Leaf element values + * @param v Validity iterator over `values.size()` elements + */ + template + lists_column_initializer(std::initializer_list values, ValidityIterator v) + requires(!std::is_same_v) + : values_{values}, has_validity_{true} + { + value_validity_.reserve(values_.size()); + for (std::size_t i = 0; i < values_.size(); ++i) { + value_validity_.push_back(static_cast(*v++)); + } + } + + template + lists_column_initializer(std::initializer_list values, ValidityIterator v) + requires(std::is_same_v) + : has_validity_{true} + { + values_.reserve(values.size()); + value_validity_.reserve(values.size()); + for (auto const& value : values) { + values_.push_back(value.value_); + value_validity_.push_back(static_cast(*v++)); + } + } + + lists_column_initializer(std::initializer_list values, std::initializer_list validity) + requires(!std::is_same_v) + : lists_column_initializer(values, validity.begin()) + { + } + + lists_column_initializer(std::initializer_list values, + std::initializer_list validity) + requires(std::is_same_v) + : lists_column_initializer(values, validity.begin()) + { + } + + /** + * @brief Construct a nested node from child initializers. + * + * This constructor is a template so the non-template leaf + * `initializer_list` constructor is preferred for scalar lists such as + * `{1, 2, 3}`. Otherwise both overloads are non-templates and constructing + * `Init` from an `int` via the nested overload recurses until the stack + * overflows. + * + * @param children Child list initializers + */ + template + lists_column_initializer(std::initializer_list children) + requires(std::is_same_v) + : children_{children.begin(), children.end()}, nested_{true} + { + } + + static lists_column_initializer nested(std::initializer_list children) + { + return lists_column_initializer(children); + } + + template + static lists_column_initializer nested(std::initializer_list children, + ValidityIterator v) + { + return lists_column_initializer(children, v); + } + + /** + * @brief Construct a nested node from child initializers and a row-validity iterator. + * + * @tparam ValidityIterator Iterator convertible to `bool` + * @param children Child list initializers + * @param v Validity iterator over `children.size()` rows + */ + template + lists_column_initializer(std::initializer_list children, ValidityIterator v) + requires(std::is_same_v) + : nested_{true}, has_validity_{true} + { + children_.reserve(children.size()); + for (auto const& child : children) { + children_.push_back(child); + children_.back().valid_ = static_cast(*v++); + } + } + + template + lists_column_initializer(std::initializer_list children, + std::initializer_list validity) + requires(std::is_same_v) + : lists_column_initializer(children, validity.begin()) + { + } + + /** + * @brief True if this node holds nested child initializers rather than leaf values. + * @return Whether this node is nested + */ + [[nodiscard]] bool nested() const { return nested_; } + /** + * @brief True if this row is valid (non-null) in its parent list. + * @return Whether this row is valid + */ + [[nodiscard]] bool valid() const { return valid_; } + /** + * @brief Leaf element values when `nested()` is false. + * @return Reference to the leaf values + */ + [[nodiscard]] auto const& values() const { return values_; } + /** + * @brief Per-element validity for leaf values; empty when all leaf values are valid. + * @return Reference to the leaf validity mask + */ + [[nodiscard]] auto const& value_validity() const { return value_validity_; } + /** + * @brief True if validity was explicitly provided. + * @return Whether this initializer has explicit validity + */ + [[nodiscard]] bool has_validity() const { return has_validity_; } + /** + * @brief Child initializers when `nested()` is true. + * @return Reference to the child initializers + */ + [[nodiscard]] auto const& children() const { return children_; } + + /** + * @brief Recursively build child list wrappers and row validity for a nested node. + * + * Each valid child is allocated with the provided `stream` and `mr`. Null children are + * represented as default-constructed wrappers (skipped during concatenate). + * + * @tparam ElementT List wrapper element type + * @tparam SourceElementT Source type used by the list wrapper + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate child columns + * @return Child wrappers and an empty validity vector when all rows are valid, + * otherwise a validity mask matching `children().size()` + */ + template + [[nodiscard]] std::pair>, + std::vector> + build(cuda::stream_ref stream, cudf::memory_resources mr) && + { + std::vector> children; + std::vector validity; + children.reserve(children_.size()); + validity.reserve(children_.size()); + for (auto&& child : children_) { + validity.push_back(child.valid()); + children.emplace_back(std::move(child), stream, mr); + } + return {std::move(children), has_validity_ ? std::move(validity) : std::vector{}}; + } + + private: + template + lists_column_initializer with_validity(ValidityIterator validity) && + { + has_validity_ = true; + if (nested_) { + for (auto& child : children_) { + child.valid_ = static_cast(*validity++); + } + } else { + value_validity_.clear(); + value_validity_.reserve(values_.size()); + std::transform(validity, + validity + values_.size(), + std::back_inserter(value_validity_), + [](auto const& value) { return static_cast(value); }); + } + return std::move(*this); + } + + template + friend class lists_column_wrapper; + + std::vector values_; + std::vector value_validity_; + std::vector children_; + bool nested_{false}; + bool valid_{true}; + bool has_validity_{false}; +}; + +/** + * @brief `column_wrapper` derived class for wrapping columns of lists. + * + * Nested rows can normally be expressed directly with braces. Use `nested()` when a + * single-child initializer would otherwise make the intended depth ambiguous. + * + * @code{.cpp} + * using LCW = cudf::test::lists_column_wrapper; + * LCW lists{{{1}, {2}}, {}, {{3}, {4, 5}}}; + * LCW deeper{LCW::nested({{1}}), {}}; + * @endcode + */ +template +class lists_column_wrapper : public detail::column_wrapper { + public: + /** + * @brief Cast to lists_column_view + */ + operator lists_column_view() const { return cudf::lists_column_view{wrapped->view()}; } + + /** + * @brief Host-side leaf element type (`std::string` for string lists, else `SourceElementT`). + */ + using host_element_t = + std::conditional_t, std::string, SourceElementT>; + using initializer_type = lists_column_initializer; + + static initializer_type nested(std::initializer_list children) + { + return initializer_type::nested(children); + } + + template + static initializer_type nested(std::initializer_list children, + ValidityIterator validity) + { + return initializer_type::nested(children, validity); + } + + /** + * @brief Column wrapper type used to materialize leaf list contents. + */ + using leaf_wrapper_t = std::conditional_t, + strings_column_wrapper, + fixed_width_column_wrapper>; + + /** + * @brief Construct a lists column containing a single list from an initializer + * list of values. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total integers + * // [{0, 1}] + * lists_column_wrapper l{0, 1}; + * @endcode + * + * These leaf constructors are templates (via `requires`) so that recursive initializer + * construction is preferred for ambiguous cases such as + * `lists_column_wrapper{{}, {}}`. + * + * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width() && std::is_convertible_v) + : column_wrapper{} + { + build_from_non_nested( + fixed_width_column_wrapper(elements.begin(), elements.end(), stream, mr) + .release(), + stream, + mr); + } + + template + lists_column_wrapper(First first, Rest... rest) + requires(cudf::is_fixed_width() && (std::is_convertible_v && ... && + std::is_convertible_v)) + : lists_column_wrapper(std::initializer_list{ + static_cast(first), static_cast(rest)...}) + { + } + + /** + * @brief Construct a lists column containing a single list from an iterator range. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * // [{0, 1, 2, 3, 4}] + * lists_column_wrapper l(elements, elements+5); + * @endcode + * + * @param begin Beginning of the sequence + * @param end End of the sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + requires requires(InputIterator i) { + *i; + ++i; + } + lists_column_wrapper(InputIterator begin, + InputIterator end, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + build_from_non_nested(leaf_wrapper_t(begin, end, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list from an initializer + * list of values and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total integers + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, NULL}] + * lists_column_wrapper l{{0, 1}, validity}; + * @endcode + * + * @param elements The list of elements + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(cudf::is_fixed_width() && std::is_convertible_v) + : column_wrapper{} + { + build_from_non_nested( + fixed_width_column_wrapper(elements.begin(), elements.end(), v, stream, mr) + .release(), + stream, + mr); + } + + /** + * @brief Construct a lists column containing a single list from an iterator + * range and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 5 total integers + * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, NULL, 2, NULL, 4}] + * lists_column_wrapper l(elements, elements+5, validity); + * @endcode + * + * @param begin Beginning of the sequence + * @param end End of the sequence + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + requires requires(InputIterator i) { + *i; + ++i; + } + lists_column_wrapper(InputIterator begin, + InputIterator end, + ValidityIterator v, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list of strings. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 1 list composed of 2 total strings + * // [{"abc", "def"}] + * lists_column_wrapper s{"abc", "def"}; + * @endcode + * + * @param elements The list of strings + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v && std::is_constructible_v) + : column_wrapper{} + { + build_from_non_nested( + strings_column_wrapper(elements.begin(), elements.end(), stream, mr).release(), stream, mr); + } + + /** + * @brief Construct a lists column containing a single list of strings and a + * validity iterator. + * + * Example: + * @code{.cpp} + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{"abc", NULL}] + * lists_column_wrapper l{{"abc", "def"}, validity}; + * @endcode + * + * @param elements The list of strings + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(std::is_same_v && std::is_constructible_v) + : column_wrapper{} + { + build_from_non_nested( + strings_column_wrapper(elements.begin(), elements.end(), v, stream, mr).release(), + stream, + mr); + } + + /** + * @brief Construct a lists column of nested lists from an initializer list of values. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 3 lists + * // [{0, 1}, {2, 3}, {4, 5}] + * lists_column_wrapper l{ {0, 1}, {2, 3}, {4, 5} }; + * @endcode + * + * Automatically handles nesting + * Example: + * @code{.cpp} + * // Creates a LIST of LIST columns with 2 lists on the top level and + * // 4 below + * // [ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} ] + * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; + * @endcode + * + * An explicit stream and memory resource are propagated through every nesting level: + * `lists_column_wrapper l{{{0, 1}, {2, 3}, {4, 5}}, stream, mr};` + * + * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(std::initializer_list elements, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : lists_column_wrapper(initializer_type(elements), stream, mr) + { + } + + /** + * @brief Construct an empty lists column + * + * Example: + * @code{.cpp} + * // Creates an empty LIST column + * // [] + * lists_column_wrapper l{}; + * @endcode + */ + lists_column_wrapper() : column_wrapper{} + { + // Mark as a root so nesting unwraps to the empty child, matching + // build_from_non_nested on an empty leaf. + root = true; + depth = 0; + wrapped = make_empty_lists_column(data_type{type_to_id()}); + } + + /** + * @brief Construct an empty lists column with an explicit stream and memory resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(cuda::stream_ref stream, cudf::memory_resources mr) + : lists_column_wrapper(initializer_type{}, stream, mr) + { + } + + /** + * @brief Construct a lists column of nested lists from an initializer list of values + * and a validity iterator. + * + * Example: + * @code{.cpp} + * // Creates a LIST column with 3 lists + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [{0, 1}, NULL, {4, 5}] + * lists_column_wrapper l{ {{0, 1}, {2, 3}, {4, 5}, validity} }; + * @endcode + * + * Automatically handles nesting + * Example: + * @code{.cpp} + * // Creates a LIST of LIST columns with 2 lists on the top level and + * // 4 below + * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); + * // [ {{0, 1}, NULL}, {{4, 5}, NULL} ] + * lists_column_wrapper l{ {{{0, 1}, {2, 3}}, validity}, {{{4, 5}, {6, 7}}, validity} }; + * @endcode + * + * @param elements The list of elements + * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + template + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : lists_column_wrapper(initializer_type(elements, v), stream, mr) + { + } + + /** + * @brief Construct a lists column from a recursive `lists_column_initializer` tree. + * + * Every nesting level is allocated with the provided `stream` and `mr`. Prefer this over + * brace-nested `lists_column_wrapper` constructions that pass resources only at the outer + * level. + * + * Example: + * @code{.cpp} + * using LCW = cudf::test::lists_column_wrapper; + * LCW lists{{{0, 1}, {2, 3}, {4, 5}}, stream, mr}; + * LCW nested{{LCW::nested({{0, 1}, {2}}), LCW::nested({{3}})}, stream, mr}; + * @endcode + * + * @param init Host-side nested values (and optional validity) + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + lists_column_wrapper(initializer_type init, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} + { + if (!init.nested()) { + if (!init.has_validity()) { + *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); + } else { + *this = lists_column_wrapper( + init.values().begin(), init.values().end(), init.value_validity().begin(), stream, mr); + } + return; + } + + if (init.children().empty()) { + wrapped = make_empty_lists_column(data_type{type_to_id()}); + depth = 1; + return; + } + + auto [children, validity] = std::move(init).template build(stream, mr); + build_from_nested(children, validity, stream, mr); + } + + template + lists_column_wrapper(initializer_type init, + ValidityIterator validity, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : lists_column_wrapper(std::move(init).with_validity(validity), stream, mr) + { + } + + /** + * @brief Construct a list column containing a single empty, optionally null row. + * + * @param valid Whether or not the empty row is also null + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * @return A list column containing a single empty row + */ + static lists_column_wrapper make_one_empty_row_column( + bool valid = true, + cuda::stream_ref stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + { + cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); + leaf_wrapper_t values(std::initializer_list{}, stream, mr); + return lists_column_wrapper( + 1, + offsets.release(), + values.release(), + valid ? 0 : 1, + valid ? rmm::device_buffer{} + : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr())); + } + + private: + /** + * @brief Construct a list column from constituent parts. + * + * @param num_rows The number of lists the column represents + * @param offsets The column of offset values for this column + * @param values The column of values bounded by the offsets + * @param null_count The number of null list entries + * @param null_mask The bits specifying the null lists in device memory + */ + lists_column_wrapper(size_type num_rows, + std::unique_ptr&& offsets, + std::unique_ptr&& values, + size_type null_count, + rmm::device_buffer&& null_mask) + { + // construct the list column + wrapped = make_lists_column( + num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); + } + + /** + * @brief Initialize as a nested list column composed of other list columns. + * + * This function handles a special case. For convenience of declaration, we want to treat these + * two cases as equivalent + * + * List = { 0, 1 } + * List = { {0, 1} } + * + * while at the same time, allowing further nesting + * List = { {{0, 1}} } + * + * @param elements Input columns to be wrapped + * @param v The validity of each row + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * + */ + template + void build_from_nested(ListsRange const& elements, + std::vector const& v, + cuda::stream_ref stream, + cudf::memory_resources mr) + { + auto valids = cudf::detail::make_counting_transform_iterator( + 0, [&v](auto i) { return v.empty() ? true : v[i]; }); + + // compute the expected hierarchy and depth + auto const hierarchy_and_depth = + std::accumulate(elements.begin(), + elements.end(), + std::pair{{}, -1}, + [](auto acc, lists_column_wrapper const& lcw) { + return lcw.depth > acc.second ? std::pair(lcw.get_view(), lcw.depth) : acc; + }); + column_view expected_hierarchy = hierarchy_and_depth.first; + int32_t const expected_depth = hierarchy_and_depth.second; + + // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy + auto [cols, stubs] = preprocess_columns( + elements, expected_hierarchy, expected_depth, stream, mr.get_temporary_mr()); + + // generate offsets + size_type count = 0; + std::vector offsetv; + std::transform(cols.cbegin(), + cols.cend(), + valids, + std::back_inserter(offsetv), + [&](cudf::column_view const& col, bool valid) { + // nulls are represented as a repeated offset + size_type ret = count; + if (valid) { count += col.size(); } + return ret; + }); + // add the final offset + offsetv.push_back(count); + auto offsets = + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); + + // concatenate them together, skipping children that are null. + std::vector children; + thrust::copy_if(std::cbegin(cols), + std::cend(cols), + valids, + std::back_inserter(children), + cuda::std::identity{}); + + auto data = children.empty() ? cudf::empty_like(expected_hierarchy) + : cudf::concatenate(children, stream, mr.get_output_mr()); + + // increment depth + depth = expected_depth + 1; + + auto [null_mask, null_count] = [&] { + if (v.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); + return cudf::test::detail::make_null_mask(v.begin(), v.end(), stream, mr); + }(); + + // construct the list column + wrapped = make_lists_column( + cols.size(), std::move(offsets), std::move(data), null_count, std::move(null_mask)); + } + + /** + * @brief Initialize as a "root" list column from a non-list input column. Root columns + * will be "unwrapped" when used in the nesting (list of lists) case. + * + * @param c Input column to be wrapped + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + * + */ + void build_from_non_nested(std::unique_ptr c, + cuda::stream_ref stream, + cudf::memory_resources mr) + { + CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), + "Unexpected type"); + + std::vector offsetv; + if (c->size() > 0) { + offsetv.push_back(0); + offsetv.push_back(c->size()); + } + auto offsets = + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); + + // construct the list column. mark this as a root + root = true; + depth = 0; + + size_type num_elements = offsets->size() == 0 ? 0 : offsets->size() - 1; + wrapped = + make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{}); + } + + /** + * @brief Given an input column that may be an "incomplete hierarchy" due to being empty + * at a level before the leaf, normalize it so that it matches the expected hierarchy of + * sibling columns. + * + * cudf functions that handle lists expect that all columns are fully formed hierarchies, + * even if they are empty somewhere in the middle of the hierarchy. + * If we had the following lists_column_wrapper declaration: + * + * @code{.pseudo} + * [ {{{1, 2, 3}}}, {} ] + * Row 0 in this case is a List>>, where row 1 appears to be just a List<>. + * @endcode + * + * These two columns will end up getting passed to cudf::concatenate() to merge. But + * concatenate() will throw an exception because row 1 will appear to have a child type + * of nothing, while row 0 will appear to have a child type of List>. + * To handle this cleanly, we want to "normalize" row 1 so that it appears as a + * List>> column even though it has 0 elements at the top level. + * + * This function also detects the case where the user has constructed a truly invalid + * pair of columns, such as + * + * @code{.pseudo} + * [ {{{1, 2, 3}}}, {4, 5} ] + * Row 0 in this case is a List>>, and row 1 is a concrete List with + * elements. This is purely an invalid way of constructing a lists column. + * @endcode + * + * @param col Input column to be normalized + * @param expected_hierarchy Input column which represents the expected hierarchy + * @param stream CUDA stream used for device memory operations + * @param temp_mr Device memory resource used for temporary normalized copies + * + * @return A new column representing a normalized copy of col + */ + std::unique_ptr normalize_column(column_view const& col, + column_view const& expected_hierarchy, + cuda::stream_ref stream, + rmm::device_async_resource_ref temp_mr) + { + // if are at the bottom of the short column, it must be empty + if (col.type().id() != type_id::LIST) { + CUDF_EXPECTS(col.is_empty(), "Encountered mismatched column!"); + + auto remainder = empty_like(expected_hierarchy); + return remainder; + } + + lists_column_view lcv(col); + return make_lists_column(col.size(), + std::make_unique(lcv.offsets(), stream, temp_mr), + normalize_column(lists_column_view(col).child(), + lists_column_view(expected_hierarchy).child(), + stream, + temp_mr), + col.null_count(), + cudf::copy_bitmask(col, stream, temp_mr)); + } + + template + std::pair, std::vector>> preprocess_columns( + ListsRange const& elements, + column_view& expected_hierarchy, + int expected_depth, + cuda::stream_ref stream, + rmm::device_async_resource_ref temp_mr) + { + std::vector> stubs; + std::vector cols; + + // preprocess the incoming lists. + // - unwrap any "root" lists + // - handle incomplete hierarchies + std::transform( + elements.begin(), + elements.end(), + std::back_inserter(cols), + [&](lists_column_wrapper const& l) -> column_view { + // depth mismatch. attempt to normalize the short column. + // this function will also catch if this is a legitimately broken + // set of input + if (l.depth < expected_depth) { + if (l.root) { + // this exception distinguishes between the following two cases: + // + // { {{{1, 2, 3}}}, {} } + // In this case, row 0 is a List>>, whereas row 1 is + // just a List<> which is an apparent mismatch. However, because row 1 + // is empty we will allow that to semantically mean + // "a List>> that's empty at the top level" + // + // { {{{1, 2, 3}}}, {4, 5, 6} } + // In this case, row 1 is a concrete List with actual values. + // There is no way to rectify the differences so we will treat it as a + // true column mismatch. + CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); + stubs.push_back(empty_like(expected_hierarchy)); + } else { + stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, temp_mr)); + } + return *(stubs.back()); + } + // the empty hierarchy case + return l.get_view(); + }); + + return {std::move(cols), std::move(stubs)}; + } + + [[nodiscard]] column_view get_view() const + { + return root ? lists_column_view(*wrapped).child() : *wrapped; + } + + int depth = 0; + bool root = false; +}; + +//! @endcond + } // namespace test } // namespace CUDF_EXPORT cudf diff --git a/cpp/include/cudf_test/lists_column_wrapper.hpp b/cpp/include/cudf_test/lists_column_wrapper.hpp deleted file mode 100644 index 528ff0383afd..000000000000 --- a/cpp/include/cudf_test/lists_column_wrapper.hpp +++ /dev/null @@ -1,988 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace CUDF_EXPORT cudf { -namespace test { - -// Forward declaration for lists_column_initializer -template -class lists_column_wrapper; - -template -concept iterator_like = requires(Iterator i) { - *i; - ++i; -}; - -template -concept validity_iterator = - iterator_like && requires(Iterator i) { static_cast(*i); }; - -/** - * @brief Host-side recursive initializer tree for constructing list columns with an - * explicit stream and memory resources at every nesting level. - * - * Example: - * @code{.cpp} - * using LCW = cudf::test::lists_column_wrapper; - * LCW col{{{1, 2}, {3}}, stream, mr}; - * @endcode - * - * Leaf and nested constructors accept the existing validity iterators - * (`valids`, `null_at(...)`, etc.) and materialize them into owned storage. - * - * @tparam T Host leaf element type (e.g. `int32_t` or `std::string`) - */ -template -class lists_column_initializer { - public: - using value_type = T; - - struct string_element { - string_element(char const* value) : value_{value} {} - string_element(std::string value) : value_{std::move(value)} {} - - std::string value_; - }; - /** - * @brief Construct an empty leaf. Avoids ambiguity between the leaf and nested - * empty `initializer_list` constructors. - */ - lists_column_initializer() = default; - - /** - * @brief Construct a leaf from scalar values. - * - * @param values Leaf element values - */ - template - lists_column_initializer(std::initializer_list values) - requires(!std::is_same_v && std::is_convertible_v) - : values_(values.begin(), values.end()) - { - } - - template - lists_column_initializer(First first, Rest... rest) - requires(sizeof...(Rest) > 0 && !std::is_same_v && - std::is_convertible_v && (std::is_convertible_v && ...)) - : values_{static_cast(first), static_cast(rest)...} - { - } - - lists_column_initializer(std::initializer_list values) - requires(std::is_same_v) - { - values_.reserve(values.size()); - std::transform( - values.begin(), values.end(), std::back_inserter(values_), [](auto const& value) { - return value.value_; - }); - } - - template - lists_column_initializer(InputIterator begin, InputIterator end) : values_(begin, end) - { - } - - /** - * @brief Construct a leaf from scalar values and a validity iterator. - * - * @tparam ValidityIterator Iterator convertible to `bool` - * @param values Leaf element values - * @param v Validity iterator over `values.size()` elements - */ - template - lists_column_initializer(std::initializer_list values, ValidityIterator v) - requires(!std::is_same_v) - : values_{values}, has_validity_{true} - { - value_validity_.reserve(values_.size()); - for (std::size_t i = 0; i < values_.size(); ++i) { - value_validity_.push_back(static_cast(*v++)); - } - } - - template - lists_column_initializer(std::initializer_list values, ValidityIterator v) - requires(std::is_same_v) - : has_validity_{true} - { - values_.reserve(values.size()); - value_validity_.reserve(values.size()); - for (auto const& value : values) { - values_.push_back(value.value_); - value_validity_.push_back(static_cast(*v++)); - } - } - - lists_column_initializer(std::initializer_list values, std::initializer_list validity) - requires(!std::is_same_v) - : lists_column_initializer(values, validity.begin()) - { - } - - lists_column_initializer(std::initializer_list values, - std::initializer_list validity) - requires(std::is_same_v) - : lists_column_initializer(values, validity.begin()) - { - } - - /** - * @brief Construct a nested node from child initializers. - * - * This constructor is a template so the non-template leaf - * `initializer_list` constructor is preferred for scalar lists such as - * `{1, 2, 3}`. Otherwise both overloads are non-templates and constructing - * `Init` from an `int` via the nested overload recurses until the stack - * overflows. - * - * @param children Child list initializers - */ - template - lists_column_initializer(std::initializer_list children) - requires(std::is_same_v) - : children_{children.begin(), children.end()}, nested_{true} - { - } - - static lists_column_initializer nested(std::initializer_list children) - { - return lists_column_initializer(children); - } - - template - static lists_column_initializer nested(std::initializer_list children, - ValidityIterator v) - { - return lists_column_initializer(children, v); - } - - /** - * @brief Construct a nested node from child initializers and a row-validity iterator. - * - * @tparam ValidityIterator Iterator convertible to `bool` - * @param children Child list initializers - * @param v Validity iterator over `children.size()` rows - */ - template - lists_column_initializer(std::initializer_list children, ValidityIterator v) - requires(std::is_same_v) - : nested_{true}, has_validity_{true} - { - children_.reserve(children.size()); - for (auto const& child : children) { - children_.push_back(child); - children_.back().valid_ = static_cast(*v++); - } - } - - template - lists_column_initializer(std::initializer_list children, - std::initializer_list validity) - requires(std::is_same_v) - : lists_column_initializer(children, validity.begin()) - { - } - - /** - * @brief True if this node holds nested child initializers rather than leaf values. - * @return Whether this node is nested - */ - [[nodiscard]] bool nested() const { return nested_; } - /** - * @brief True if this row is valid (non-null) in its parent list. - * @return Whether this row is valid - */ - [[nodiscard]] bool valid() const { return valid_; } - /** - * @brief Leaf element values when `nested()` is false. - * @return Reference to the leaf values - */ - [[nodiscard]] auto const& values() const { return values_; } - /** - * @brief Per-element validity for leaf values; empty when all leaf values are valid. - * @return Reference to the leaf validity mask - */ - [[nodiscard]] auto const& value_validity() const { return value_validity_; } - /** - * @brief True if validity was explicitly provided. - * @return Whether this initializer has explicit validity - */ - [[nodiscard]] bool has_validity() const { return has_validity_; } - /** - * @brief Child initializers when `nested()` is true. - * @return Reference to the child initializers - */ - [[nodiscard]] auto const& children() const { return children_; } - - /** - * @brief Recursively build child list wrappers and row validity for a nested node. - * - * Each valid child is allocated with the provided `stream` and `mr`. Null children are - * represented as default-constructed wrappers (skipped during concatenate). - * - * @tparam ElementT List wrapper element type - * @tparam SourceElementT Source type used by the list wrapper - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate child columns - * @return Child wrappers and an empty validity vector when all rows are valid, - * otherwise a validity mask matching `children().size()` - */ - template - [[nodiscard]] std::pair>, - std::vector> - build(cuda::stream_ref stream, cudf::memory_resources mr) && - { - std::vector> children; - std::vector validity; - children.reserve(children_.size()); - validity.reserve(children_.size()); - for (auto&& child : children_) { - validity.push_back(child.valid()); - children.emplace_back(std::move(child), stream, mr); - } - return {std::move(children), has_validity_ ? std::move(validity) : std::vector{}}; - } - - private: - template - lists_column_initializer with_validity(ValidityIterator validity) && - { - has_validity_ = true; - if (nested_) { - for (auto& child : children_) { - child.valid_ = static_cast(*validity++); - } - } else { - value_validity_.clear(); - value_validity_.reserve(values_.size()); - std::transform(validity, - validity + values_.size(), - std::back_inserter(value_validity_), - [](auto const& value) { return static_cast(value); }); - } - return std::move(*this); - } - - template - friend class lists_column_wrapper; - - std::vector values_; - std::vector value_validity_; - std::vector children_; - bool nested_{false}; - bool valid_{true}; - bool has_validity_{false}; -}; - -/** - * @brief `column_wrapper` derived class for wrapping columns of lists. - * - * Nested rows can normally be expressed directly with braces. Use `nested()` when a - * single-child initializer would otherwise make the intended depth ambiguous. - * - * @code{.cpp} - * using LCW = cudf::test::lists_column_wrapper; - * LCW lists{{{1}, {2}}, {}, {{3}, {4, 5}}}; - * LCW deeper{LCW::nested({{1}}), {}}; - * @endcode - */ -template -class lists_column_wrapper : public detail::column_wrapper { - public: - /** - * @brief Cast to lists_column_view - */ - operator lists_column_view() const { return cudf::lists_column_view{wrapped->view()}; } - - /** - * @brief Host-side leaf element type (`std::string` for string lists, else `SourceElementT`). - */ - using host_element_t = - std::conditional_t, std::string, SourceElementT>; - using initializer_type = lists_column_initializer; - - static initializer_type nested(std::initializer_list children) - { - return initializer_type::nested(children); - } - - template - static initializer_type nested(std::initializer_list children, - ValidityIterator validity) - { - return initializer_type::nested(children, validity); - } - - /** - * @brief Column wrapper type used to materialize leaf list contents. - */ - using leaf_wrapper_t = std::conditional_t, - strings_column_wrapper, - fixed_width_column_wrapper>; - - /** - * @brief Construct a lists column containing a single list from an initializer - * list of values. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total integers - * // [{0, 1}] - * lists_column_wrapper l{0, 1}; - * @endcode - * - * These leaf constructors are templates (via `requires`) so that recursive initializer - * construction is preferred for ambiguous cases such as - * `lists_column_wrapper{{}, {}}`. - * - * @param elements The list of elements - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width() && std::is_convertible_v) - : column_wrapper{} - { - build_from_non_nested( - fixed_width_column_wrapper(elements.begin(), elements.end(), stream, mr) - .release(), - stream, - mr); - } - - template - lists_column_wrapper(First first, Rest... rest) - requires(cudf::is_fixed_width() && (std::is_convertible_v && ... && - std::is_convertible_v)) - : lists_column_wrapper(std::initializer_list{ - static_cast(first), static_cast(rest)...}) - { - } - - /** - * @brief Construct a lists column containing a single list from an iterator range. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); - * // [{0, 1, 2, 3, 4}] - * lists_column_wrapper l(elements, elements+5); - * @endcode - * - * @param begin Beginning of the sequence - * @param end End of the sequence - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - requires requires(InputIterator i) { - *i; - ++i; - } - lists_column_wrapper(InputIterator begin, - InputIterator end, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - build_from_non_nested(leaf_wrapper_t(begin, end, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list from an initializer - * list of values and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total integers - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL}] - * lists_column_wrapper l{{0, 1}, validity}; - * @endcode - * - * @param elements The list of elements - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(cudf::is_fixed_width() && std::is_convertible_v) - : column_wrapper{} - { - build_from_non_nested( - fixed_width_column_wrapper(elements.begin(), elements.end(), v, stream, mr) - .release(), - stream, - mr); - } - - /** - * @brief Construct a lists column containing a single list from an iterator - * range and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 5 total integers - * auto elements = make_counting_transform_iterator(0, [](auto i){return i*2;}); - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, NULL, 2, NULL, 4}] - * lists_column_wrapper l(elements, elements+5, validity); - * @endcode - * - * @param begin Beginning of the sequence - * @param end End of the sequence - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - requires requires(InputIterator i) { - *i; - ++i; - } - lists_column_wrapper(InputIterator begin, - InputIterator end, - ValidityIterator v, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - build_from_non_nested(leaf_wrapper_t(begin, end, v, stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list of strings. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 1 list composed of 2 total strings - * // [{"abc", "def"}] - * lists_column_wrapper s{"abc", "def"}; - * @endcode - * - * @param elements The list of strings - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v && std::is_constructible_v) - : column_wrapper{} - { - build_from_non_nested( - strings_column_wrapper(elements.begin(), elements.end(), stream, mr).release(), stream, mr); - } - - /** - * @brief Construct a lists column containing a single list of strings and a - * validity iterator. - * - * Example: - * @code{.cpp} - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{"abc", NULL}] - * lists_column_wrapper l{{"abc", "def"}, validity}; - * @endcode - * - * @param elements The list of strings - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - requires(std::is_same_v && std::is_constructible_v) - : column_wrapper{} - { - build_from_non_nested( - strings_column_wrapper(elements.begin(), elements.end(), v, stream, mr).release(), - stream, - mr); - } - - /** - * @brief Construct a lists column of nested lists from an initializer list of values. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 3 lists - * // [{0, 1}, {2, 3}, {4, 5}] - * lists_column_wrapper l{ {0, 1}, {2, 3}, {4, 5} }; - * @endcode - * - * Automatically handles nesting - * Example: - * @code{.cpp} - * // Creates a LIST of LIST columns with 2 lists on the top level and - * // 4 below - * // [ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} ] - * lists_column_wrapper l{ {{0, 1}, {2, 3}}, {{4, 5}, {6, 7}} }; - * @endcode - * - * An explicit stream and memory resource are propagated through every nesting level: - * `lists_column_wrapper l{{{0, 1}, {2, 3}, {4, 5}}, stream, mr};` - * - * @param elements The list of elements - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - lists_column_wrapper(std::initializer_list elements, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : lists_column_wrapper(initializer_type(elements), stream, mr) - { - } - - /** - * @brief Construct an empty lists column - * - * Example: - * @code{.cpp} - * // Creates an empty LIST column - * // [] - * lists_column_wrapper l{}; - * @endcode - */ - lists_column_wrapper() : column_wrapper{} - { - // Mark as a root so nesting unwraps to the empty child, matching - // build_from_non_nested on an empty leaf. - root = true; - depth = 0; - wrapped = make_empty_lists_column(data_type{type_to_id()}); - } - - /** - * @brief Construct an empty lists column with an explicit stream and memory resource - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - lists_column_wrapper(cuda::stream_ref stream, cudf::memory_resources mr) - : lists_column_wrapper(initializer_type{}, stream, mr) - { - } - - /** - * @brief Construct a lists column of nested lists from an initializer list of values - * and a validity iterator. - * - * Example: - * @code{.cpp} - * // Creates a LIST column with 3 lists - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [{0, 1}, NULL, {4, 5}] - * lists_column_wrapper l{ {{0, 1}, {2, 3}, {4, 5}, validity} }; - * @endcode - * - * Automatically handles nesting - * Example: - * @code{.cpp} - * // Creates a LIST of LIST columns with 2 lists on the top level and - * // 4 below - * auto validity = make_counting_transform_iterator(0, [](auto i){return i%2;}); - * // [ {{0, 1}, NULL}, {{4, 5}, NULL} ] - * lists_column_wrapper l{ {{{0, 1}, {2, 3}}, validity}, {{{4, 5}, {6, 7}}, validity} }; - * @endcode - * - * @param elements The list of elements - * @param v The validity iterator - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - template - lists_column_wrapper(std::initializer_list elements, - ValidityIterator v, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : lists_column_wrapper(initializer_type(elements, v), stream, mr) - { - } - - /** - * @brief Construct a lists column from a recursive `lists_column_initializer` tree. - * - * Every nesting level is allocated with the provided `stream` and `mr`. Prefer this over - * brace-nested `lists_column_wrapper` constructions that pass resources only at the outer - * level. - * - * Example: - * @code{.cpp} - * using LCW = cudf::test::lists_column_wrapper; - * LCW lists{{{0, 1}, {2, 3}, {4, 5}}, stream, mr}; - * LCW nested{{LCW::nested({{0, 1}, {2}}), LCW::nested({{3}})}, stream, mr}; - * @endcode - * - * @param init Host-side nested values (and optional validity) - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - lists_column_wrapper(initializer_type init, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} - { - if (!init.nested()) { - if (!init.has_validity()) { - *this = lists_column_wrapper(init.values().begin(), init.values().end(), stream, mr); - } else { - *this = lists_column_wrapper( - init.values().begin(), init.values().end(), init.value_validity().begin(), stream, mr); - } - return; - } - - if (init.children().empty()) { - wrapped = make_empty_lists_column(data_type{type_to_id()}); - depth = 1; - return; - } - - auto [children, validity] = std::move(init).template build(stream, mr); - build_from_nested(children, validity, stream, mr); - } - - template - lists_column_wrapper(initializer_type init, - ValidityIterator validity, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : lists_column_wrapper(std::move(init).with_validity(validity), stream, mr) - { - } - - /** - * @brief Construct a list column containing a single empty, optionally null row. - * - * @param valid Whether or not the empty row is also null - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * @return A list column containing a single empty row - */ - static lists_column_wrapper make_one_empty_row_column( - bool valid = true, - cuda::stream_ref stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - { - cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); - leaf_wrapper_t values(std::initializer_list{}, stream, mr); - return lists_column_wrapper( - 1, - offsets.release(), - values.release(), - valid ? 0 : 1, - valid ? rmm::device_buffer{} - : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr())); - } - - private: - /** - * @brief Construct a list column from constituent parts. - * - * @param num_rows The number of lists the column represents - * @param offsets The column of offset values for this column - * @param values The column of values bounded by the offsets - * @param null_count The number of null list entries - * @param null_mask The bits specifying the null lists in device memory - */ - lists_column_wrapper(size_type num_rows, - std::unique_ptr&& offsets, - std::unique_ptr&& values, - size_type null_count, - rmm::device_buffer&& null_mask) - { - // construct the list column - wrapped = make_lists_column( - num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); - } - - /** - * @brief Initialize as a nested list column composed of other list columns. - * - * This function handles a special case. For convenience of declaration, we want to treat these - * two cases as equivalent - * - * List = { 0, 1 } - * List = { {0, 1} } - * - * while at the same time, allowing further nesting - * List = { {{0, 1}} } - * - * @param elements Input columns to be wrapped - * @param v The validity of each row - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * - */ - template - void build_from_nested(ListsRange const& elements, - std::vector const& v, - cuda::stream_ref stream, - cudf::memory_resources mr) - { - auto valids = cudf::detail::make_counting_transform_iterator( - 0, [&v](auto i) { return v.empty() ? true : v[i]; }); - - // compute the expected hierarchy and depth - auto const hierarchy_and_depth = - std::accumulate(elements.begin(), - elements.end(), - std::pair{{}, -1}, - [](auto acc, lists_column_wrapper const& lcw) { - return lcw.depth > acc.second ? std::pair(lcw.get_view(), lcw.depth) : acc; - }); - column_view expected_hierarchy = hierarchy_and_depth.first; - int32_t const expected_depth = hierarchy_and_depth.second; - - // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy - auto [cols, stubs] = preprocess_columns( - elements, expected_hierarchy, expected_depth, stream, mr.get_temporary_mr()); - - // generate offsets - size_type count = 0; - std::vector offsetv; - std::transform(cols.cbegin(), - cols.cend(), - valids, - std::back_inserter(offsetv), - [&](cudf::column_view const& col, bool valid) { - // nulls are represented as a repeated offset - size_type ret = count; - if (valid) { count += col.size(); } - return ret; - }); - // add the final offset - offsetv.push_back(count); - auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) - .release(); - - // concatenate them together, skipping children that are null. - std::vector children; - thrust::copy_if(std::cbegin(cols), - std::cend(cols), - valids, - std::back_inserter(children), - cuda::std::identity{}); - - auto data = children.empty() ? cudf::empty_like(expected_hierarchy) - : cudf::concatenate(children, stream, mr.get_output_mr()); - - // increment depth - depth = expected_depth + 1; - - auto [null_mask, null_count] = [&] { - if (v.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); - return cudf::test::detail::make_null_mask(v.begin(), v.end(), stream, mr); - }(); - - // construct the list column - wrapped = make_lists_column( - cols.size(), std::move(offsets), std::move(data), null_count, std::move(null_mask)); - } - - /** - * @brief Initialize as a "root" list column from a non-list input column. Root columns - * will be "unwrapped" when used in the nesting (list of lists) case. - * - * @param c Input column to be wrapped - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - * - */ - void build_from_non_nested(std::unique_ptr c, - cuda::stream_ref stream, - cudf::memory_resources mr) - { - CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), - "Unexpected type"); - - std::vector offsetv; - if (c->size() > 0) { - offsetv.push_back(0); - offsetv.push_back(c->size()); - } - auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) - .release(); - - // construct the list column. mark this as a root - root = true; - depth = 0; - - size_type num_elements = offsets->size() == 0 ? 0 : offsets->size() - 1; - wrapped = - make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{}); - } - - /** - * @brief Given an input column that may be an "incomplete hierarchy" due to being empty - * at a level before the leaf, normalize it so that it matches the expected hierarchy of - * sibling columns. - * - * cudf functions that handle lists expect that all columns are fully formed hierarchies, - * even if they are empty somewhere in the middle of the hierarchy. - * If we had the following lists_column_wrapper declaration: - * - * @code{.pseudo} - * [ {{{1, 2, 3}}}, {} ] - * Row 0 in this case is a List>>, where row 1 appears to be just a List<>. - * @endcode - * - * These two columns will end up getting passed to cudf::concatenate() to merge. But - * concatenate() will throw an exception because row 1 will appear to have a child type - * of nothing, while row 0 will appear to have a child type of List>. - * To handle this cleanly, we want to "normalize" row 1 so that it appears as a - * List>> column even though it has 0 elements at the top level. - * - * This function also detects the case where the user has constructed a truly invalid - * pair of columns, such as - * - * @code{.pseudo} - * [ {{{1, 2, 3}}}, {4, 5} ] - * Row 0 in this case is a List>>, and row 1 is a concrete List with - * elements. This is purely an invalid way of constructing a lists column. - * @endcode - * - * @param col Input column to be normalized - * @param expected_hierarchy Input column which represents the expected hierarchy - * @param stream CUDA stream used for device memory operations - * @param temp_mr Device memory resource used for temporary normalized copies - * - * @return A new column representing a normalized copy of col - */ - std::unique_ptr normalize_column(column_view const& col, - column_view const& expected_hierarchy, - cuda::stream_ref stream, - rmm::device_async_resource_ref temp_mr) - { - // if are at the bottom of the short column, it must be empty - if (col.type().id() != type_id::LIST) { - CUDF_EXPECTS(col.is_empty(), "Encountered mismatched column!"); - - auto remainder = empty_like(expected_hierarchy); - return remainder; - } - - lists_column_view lcv(col); - return make_lists_column(col.size(), - std::make_unique(lcv.offsets(), stream, temp_mr), - normalize_column(lists_column_view(col).child(), - lists_column_view(expected_hierarchy).child(), - stream, - temp_mr), - col.null_count(), - cudf::copy_bitmask(col, stream, temp_mr)); - } - - template - std::pair, std::vector>> preprocess_columns( - ListsRange const& elements, - column_view& expected_hierarchy, - int expected_depth, - cuda::stream_ref stream, - rmm::device_async_resource_ref temp_mr) - { - std::vector> stubs; - std::vector cols; - - // preprocess the incoming lists. - // - unwrap any "root" lists - // - handle incomplete hierarchies - std::transform( - elements.begin(), - elements.end(), - std::back_inserter(cols), - [&](lists_column_wrapper const& l) -> column_view { - // depth mismatch. attempt to normalize the short column. - // this function will also catch if this is a legitimately broken - // set of input - if (l.depth < expected_depth) { - if (l.root) { - // this exception distinguishes between the following two cases: - // - // { {{{1, 2, 3}}}, {} } - // In this case, row 0 is a List>>, whereas row 1 is - // just a List<> which is an apparent mismatch. However, because row 1 - // is empty we will allow that to semantically mean - // "a List>> that's empty at the top level" - // - // { {{{1, 2, 3}}}, {4, 5, 6} } - // In this case, row 1 is a concrete List with actual values. - // There is no way to rectify the differences so we will treat it as a - // true column mismatch. - CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); - stubs.push_back(empty_like(expected_hierarchy)); - } else { - stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, temp_mr)); - } - return *(stubs.back()); - } - // the empty hierarchy case - return l.get_view(); - }); - - return {std::move(cols), std::move(stubs)}; - } - - [[nodiscard]] column_view get_view() const - { - return root ? lists_column_view(*wrapped).child() : *wrapped; - } - - int depth = 0; - bool root = false; -}; - -} // namespace test -} // namespace CUDF_EXPORT cudf diff --git a/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp b/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp index fcd40eeaf577..a07b6fe75ede 100644 --- a/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp +++ b/cpp/libcudf_streaming/tests/streaming/test_cudf_utils.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include diff --git a/cpp/tests/column/column_test.cpp b/cpp/tests/column/column_test.cpp index 04e4eadf9988..edf20f138906 100644 --- a/cpp/tests/column/column_test.cpp +++ b/cpp/tests/column/column_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/column/column_view_shallow_test.cpp b/cpp/tests/column/column_view_shallow_test.cpp index 491a6ce735d7..b2346a5a0fb1 100644 --- a/cpp/tests/column/column_view_shallow_test.cpp +++ b/cpp/tests/column/column_view_shallow_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index 8b5ddd08b6e2..636e8fdfdd08 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index 295180a9f165..a0054ddf18ec 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/copying/copy_if_else_nested_tests.cpp b/cpp/tests/copying/copy_if_else_nested_tests.cpp index a81445ebec11..91ea0440bfd8 100644 --- a/cpp/tests/copying/copy_if_else_nested_tests.cpp +++ b/cpp/tests/copying/copy_if_else_nested_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/copy_tests.cpp b/cpp/tests/copying/copy_tests.cpp index 3df2a3e24c8c..e3397952b26d 100644 --- a/cpp/tests/copying/copy_tests.cpp +++ b/cpp/tests/copying/copy_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/gather_list_tests.cpp b/cpp/tests/copying/gather_list_tests.cpp index b98d2456c5d9..f2b2a6931fd5 100644 --- a/cpp/tests/copying/gather_list_tests.cpp +++ b/cpp/tests/copying/gather_list_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/gather_struct_tests.cpp b/cpp/tests/copying/gather_struct_tests.cpp index f70e27233ccd..81ead171a905 100644 --- a/cpp/tests/copying/gather_struct_tests.cpp +++ b/cpp/tests/copying/gather_struct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/get_value_tests.cpp b/cpp/tests/copying/get_value_tests.cpp index f3062612de84..91b8273e2862 100644 --- a/cpp/tests/copying/get_value_tests.cpp +++ b/cpp/tests/copying/get_value_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/pack_tests.cpp b/cpp/tests/copying/pack_tests.cpp index 7c6915275a21..49c7d4d26d45 100644 --- a/cpp/tests/copying/pack_tests.cpp +++ b/cpp/tests/copying/pack_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp index 1460da4092d4..8d8ba386b252 100644 --- a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp +++ b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/scatter_list_scalar_tests.cpp b/cpp/tests/copying/scatter_list_scalar_tests.cpp index b954cbe58f88..0c2cad19615b 100644 --- a/cpp/tests/copying/scatter_list_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_list_scalar_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/scatter_list_tests.cpp b/cpp/tests/copying/scatter_list_tests.cpp index 167796e73d3d..083e5fecf680 100644 --- a/cpp/tests/copying/scatter_list_tests.cpp +++ b/cpp/tests/copying/scatter_list_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/scatter_struct_scalar_tests.cpp b/cpp/tests/copying/scatter_struct_scalar_tests.cpp index db46f276cc3d..654df73f5066 100644 --- a/cpp/tests/copying/scatter_struct_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_struct_scalar_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/scatter_struct_tests.cpp b/cpp/tests/copying/scatter_struct_tests.cpp index bbfbed13408f..25312a39d0c2 100644 --- a/cpp/tests/copying/scatter_struct_tests.cpp +++ b/cpp/tests/copying/scatter_struct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index e58f2e645dcb..854781bc7088 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/slice_tests.cpp b/cpp/tests/copying/slice_tests.cpp index 0c1d3b000603..6266d76437e2 100644 --- a/cpp/tests/copying/slice_tests.cpp +++ b/cpp/tests/copying/slice_tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index 42c1ca03a9d3..eeb15d0aa4e6 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/copying/utility_tests.cpp b/cpp/tests/copying/utility_tests.cpp index 6d79f4590625..45cf58cab6ae 100644 --- a/cpp/tests/copying/utility_tests.cpp +++ b/cpp/tests/copying/utility_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/groupby/collect_list_tests.cpp b/cpp/tests/groupby/collect_list_tests.cpp index 4217c5030d37..bd341d88ce66 100644 --- a/cpp/tests/groupby/collect_list_tests.cpp +++ b/cpp/tests/groupby/collect_list_tests.cpp @@ -7,7 +7,6 @@ #include #include -#include #include template diff --git a/cpp/tests/groupby/collect_set_tests.cpp b/cpp/tests/groupby/collect_set_tests.cpp index 4e3018571baa..fdb6ad6984a7 100644 --- a/cpp/tests/groupby/collect_set_tests.cpp +++ b/cpp/tests/groupby/collect_set_tests.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/cpp/tests/groupby/keys_tests.cpp b/cpp/tests/groupby/keys_tests.cpp index 18fabef769fd..934716a02928 100644 --- a/cpp/tests/groupby/keys_tests.cpp +++ b/cpp/tests/groupby/keys_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/lists_tests.cpp b/cpp/tests/groupby/lists_tests.cpp index c4bfebec43e0..412fc9f2927f 100644 --- a/cpp/tests/groupby/lists_tests.cpp +++ b/cpp/tests/groupby/lists_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/max_tests.cpp b/cpp/tests/groupby/max_tests.cpp index 4bfd3c1b40df..6e6fdb0f0921 100644 --- a/cpp/tests/groupby/max_tests.cpp +++ b/cpp/tests/groupby/max_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/merge_lists_tests.cpp b/cpp/tests/groupby/merge_lists_tests.cpp index a58dbeb09106..82292fffced7 100644 --- a/cpp/tests/groupby/merge_lists_tests.cpp +++ b/cpp/tests/groupby/merge_lists_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/merge_sets_tests.cpp b/cpp/tests/groupby/merge_sets_tests.cpp index 6ffd9f794a63..5bbecc8e104a 100644 --- a/cpp/tests/groupby/merge_sets_tests.cpp +++ b/cpp/tests/groupby/merge_sets_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/min_tests.cpp b/cpp/tests/groupby/min_tests.cpp index 75c4c2e75517..5e7d69ce4bb9 100644 --- a/cpp/tests/groupby/min_tests.cpp +++ b/cpp/tests/groupby/min_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/nth_element_tests.cpp b/cpp/tests/groupby/nth_element_tests.cpp index 40bca1d85de9..411569b626b7 100644 --- a/cpp/tests/groupby/nth_element_tests.cpp +++ b/cpp/tests/groupby/nth_element_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/rank_scan_tests.cpp b/cpp/tests/groupby/rank_scan_tests.cpp index 36cbfa532b20..b0d3a8443a38 100644 --- a/cpp/tests/groupby/rank_scan_tests.cpp +++ b/cpp/tests/groupby/rank_scan_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/replace_nulls_tests.cpp b/cpp/tests/groupby/replace_nulls_tests.cpp index e11177c997b6..05e596ecd23f 100644 --- a/cpp/tests/groupby/replace_nulls_tests.cpp +++ b/cpp/tests/groupby/replace_nulls_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/structs_tests.cpp b/cpp/tests/groupby/structs_tests.cpp index 13af4124f5ee..c4f5f77555c3 100644 --- a/cpp/tests/groupby/structs_tests.cpp +++ b/cpp/tests/groupby/structs_tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/groupby/topk_tests.cpp b/cpp/tests/groupby/topk_tests.cpp index c462685f59ec..490868507081 100644 --- a/cpp/tests/groupby/topk_tests.cpp +++ b/cpp/tests/groupby/topk_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include template diff --git a/cpp/tests/hashing/md5_test.cpp b/cpp/tests/hashing/md5_test.cpp index 6bca307e122d..37c8ed7617fa 100644 --- a/cpp/tests/hashing/md5_test.cpp +++ b/cpp/tests/hashing/md5_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/murmurhash3_x86_32_test.cpp b/cpp/tests/hashing/murmurhash3_x86_32_test.cpp index bef8bd35332d..6ce28ee7f4b0 100644 --- a/cpp/tests/hashing/murmurhash3_x86_32_test.cpp +++ b/cpp/tests/hashing/murmurhash3_x86_32_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/sha1_test.cpp b/cpp/tests/hashing/sha1_test.cpp index cee1418e44ca..0a5277a89d72 100644 --- a/cpp/tests/hashing/sha1_test.cpp +++ b/cpp/tests/hashing/sha1_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/sha224_test.cpp b/cpp/tests/hashing/sha224_test.cpp index 2c4d161e3b67..ad284f42927f 100644 --- a/cpp/tests/hashing/sha224_test.cpp +++ b/cpp/tests/hashing/sha224_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/sha256_test.cpp b/cpp/tests/hashing/sha256_test.cpp index be5c8884f0e9..c6092b8b9e7a 100644 --- a/cpp/tests/hashing/sha256_test.cpp +++ b/cpp/tests/hashing/sha256_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/sha384_test.cpp b/cpp/tests/hashing/sha384_test.cpp index 54fdd85a58fc..bcb5d43cd2a9 100644 --- a/cpp/tests/hashing/sha384_test.cpp +++ b/cpp/tests/hashing/sha384_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/hashing/sha512_test.cpp b/cpp/tests/hashing/sha512_test.cpp index 8c0a880d0da2..0aae46dbaf3d 100644 --- a/cpp/tests/hashing/sha512_test.cpp +++ b/cpp/tests/hashing/sha512_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/interop/from_arrow_device_test.cpp b/cpp/tests/interop/from_arrow_device_test.cpp index b42eb680d3d8..01b0b0471a24 100644 --- a/cpp/tests/interop/from_arrow_device_test.cpp +++ b/cpp/tests/interop/from_arrow_device_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/interop/from_arrow_host_test.cpp b/cpp/tests/interop/from_arrow_host_test.cpp index 0d53ccb2a216..d953b045db68 100644 --- a/cpp/tests/interop/from_arrow_host_test.cpp +++ b/cpp/tests/interop/from_arrow_host_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/interop/from_arrow_stream_test.cpp b/cpp/tests/interop/from_arrow_stream_test.cpp index 66db7c3052bb..3311b3d68417 100644 --- a/cpp/tests/interop/from_arrow_stream_test.cpp +++ b/cpp/tests/interop/from_arrow_stream_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/cpp/tests/interop/to_arrow_device_test.cpp b/cpp/tests/interop/to_arrow_device_test.cpp index 04bcfa337d5a..22a9e07fe651 100644 --- a/cpp/tests/interop/to_arrow_device_test.cpp +++ b/cpp/tests/interop/to_arrow_device_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/interop/to_arrow_host_test.cpp b/cpp/tests/interop/to_arrow_host_test.cpp index 542ff6ed9d23..f7fdb83584fe 100644 --- a/cpp/tests/interop/to_arrow_host_test.cpp +++ b/cpp/tests/interop/to_arrow_host_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/cudftable_test.cpp b/cpp/tests/io/cudftable_test.cpp index e75e48b52c49..c373b1ecf054 100644 --- a/cpp/tests/io/cudftable_test.cpp +++ b/cpp/tests/io/cudftable_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/experimental/variant_extract_test.cpp b/cpp/tests/io/experimental/variant_extract_test.cpp index ce8d6b0f0ed0..2d7459243faf 100644 --- a/cpp/tests/io/experimental/variant_extract_test.cpp +++ b/cpp/tests/io/experimental/variant_extract_test.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/json/json_test.cpp b/cpp/tests/io/json/json_test.cpp index 9b37361a743d..e49fe0e7eb08 100644 --- a/cpp/tests/io/json/json_test.cpp +++ b/cpp/tests/io/json/json_test.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/io/json/json_writer.cpp b/cpp/tests/io/json/json_writer.cpp index aca97abd4cd3..7a4bf0501201 100644 --- a/cpp/tests/io/json/json_writer.cpp +++ b/cpp/tests/io/json/json_writer.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/orc_chunked_reader_test.cu b/cpp/tests/io/orc_chunked_reader_test.cu index 9841134c8eed..4d1a20c89c74 100644 --- a/cpp/tests/io/orc_chunked_reader_test.cu +++ b/cpp/tests/io/orc_chunked_reader_test.cu @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/orc_test.cpp b/cpp/tests/io/orc_test.cpp index ae05b7a6fc55..41657e652337 100644 --- a/cpp/tests/io/orc_test.cpp +++ b/cpp/tests/io/orc_test.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/io/parquet_chunked_reader_test.cu b/cpp/tests/io/parquet_chunked_reader_test.cu index 716647d68b32..e6f0cdebe212 100644 --- a/cpp/tests/io/parquet_chunked_reader_test.cu +++ b/cpp/tests/io/parquet_chunked_reader_test.cu @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/parquet_chunked_writer_test.cpp b/cpp/tests/io/parquet_chunked_writer_test.cpp index 27b3c7a208de..dd33cf4789d4 100644 --- a/cpp/tests/io/parquet_chunked_writer_test.cpp +++ b/cpp/tests/io/parquet_chunked_writer_test.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/parquet_reader_test.cpp b/cpp/tests/io/parquet_reader_test.cpp index 33443afe4a44..4d4b59b80be0 100644 --- a/cpp/tests/io/parquet_reader_test.cpp +++ b/cpp/tests/io/parquet_reader_test.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/parquet_v2_test.cpp b/cpp/tests/io/parquet_v2_test.cpp index 2c000b4f02f2..192001eab91a 100644 --- a/cpp/tests/io/parquet_v2_test.cpp +++ b/cpp/tests/io/parquet_v2_test.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/io/parquet_writer_test.cpp b/cpp/tests/io/parquet_writer_test.cpp index 5e0b34386d33..426e5e09b04f 100644 --- a/cpp/tests/io/parquet_writer_test.cpp +++ b/cpp/tests/io/parquet_writer_test.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/join/join_tests.cpp b/cpp/tests/join/join_tests.cpp index 9dbce3c4fad4..e0f760b19e0b 100644 --- a/cpp/tests/join/join_tests.cpp +++ b/cpp/tests/join/join_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index 82480efdf0ae..7824a06f4abe 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index 042e5a13bb5b..a0716e3cba16 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/contains_tests.cpp b/cpp/tests/lists/contains_tests.cpp index 6c562699bef4..10609ab207fa 100644 --- a/cpp/tests/lists/contains_tests.cpp +++ b/cpp/tests/lists/contains_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/count_elements_tests.cpp b/cpp/tests/lists/count_elements_tests.cpp index 6c1ec1dcbea8..465458d63f9d 100644 --- a/cpp/tests/lists/count_elements_tests.cpp +++ b/cpp/tests/lists/count_elements_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/explode_tests.cpp b/cpp/tests/lists/explode_tests.cpp index a827b0a8559f..b41104503e48 100644 --- a/cpp/tests/lists/explode_tests.cpp +++ b/cpp/tests/lists/explode_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/extract_tests.cpp b/cpp/tests/lists/extract_tests.cpp index 257bab31de58..d6abed10bf5e 100644 --- a/cpp/tests/lists/extract_tests.cpp +++ b/cpp/tests/lists/extract_tests.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/reverse_tests.cpp b/cpp/tests/lists/reverse_tests.cpp index 767011b88465..f5e9346346c6 100644 --- a/cpp/tests/lists/reverse_tests.cpp +++ b/cpp/tests/lists/reverse_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/sequences_tests.cpp b/cpp/tests/lists/sequences_tests.cpp index 45d585cd2520..09df344ef864 100644 --- a/cpp/tests/lists/sequences_tests.cpp +++ b/cpp/tests/lists/sequences_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp index 8afb20ff8677..c4c6cb149ef8 100644 --- a/cpp/tests/lists/set_operations/difference_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/difference_distinct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/set_operations/have_overlap_tests.cpp b/cpp/tests/lists/set_operations/have_overlap_tests.cpp index 68681e157cbb..e881248c6d37 100644 --- a/cpp/tests/lists/set_operations/have_overlap_tests.cpp +++ b/cpp/tests/lists/set_operations/have_overlap_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp index 2855c23837f2..e0f3ba1c4c21 100644 --- a/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/intersect_distinct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/set_operations/union_distinct_tests.cpp b/cpp/tests/lists/set_operations/union_distinct_tests.cpp index 7756ebecd2aa..2c3499b84c5e 100644 --- a/cpp/tests/lists/set_operations/union_distinct_tests.cpp +++ b/cpp/tests/lists/set_operations/union_distinct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/sort_lists_tests.cpp b/cpp/tests/lists/sort_lists_tests.cpp index aaa277097e3f..492f82c1319a 100644 --- a/cpp/tests/lists/sort_lists_tests.cpp +++ b/cpp/tests/lists/sort_lists_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/stream_compaction/apply_mask_tests.cpp b/cpp/tests/lists/stream_compaction/apply_mask_tests.cpp index 02e670d29f44..ae731516f3e9 100644 --- a/cpp/tests/lists/stream_compaction/apply_mask_tests.cpp +++ b/cpp/tests/lists/stream_compaction/apply_mask_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/lists/stream_compaction/distinct_tests.cpp b/cpp/tests/lists/stream_compaction/distinct_tests.cpp index 28be28465d57..a77c08f59d24 100644 --- a/cpp/tests/lists/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/lists/stream_compaction/distinct_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/merge/merge_test.cpp b/cpp/tests/merge/merge_test.cpp index 90038a371c95..60df928f86ec 100644 --- a/cpp/tests/merge/merge_test.cpp +++ b/cpp/tests/merge/merge_test.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index b8cee03fea28..df3ae6fcbbec 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/partitioning/partition_test.cpp b/cpp/tests/partitioning/partition_test.cpp index 6066b06acff4..1655373280dd 100644 --- a/cpp/tests/partitioning/partition_test.cpp +++ b/cpp/tests/partitioning/partition_test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/quantiles/percentile_approx_test.cpp b/cpp/tests/quantiles/percentile_approx_test.cpp index 702c45510599..9d51b0ed7b29 100644 --- a/cpp/tests/quantiles/percentile_approx_test.cpp +++ b/cpp/tests/quantiles/percentile_approx_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/reductions/collect_ops_tests.cpp b/cpp/tests/reductions/collect_ops_tests.cpp index a60b7ad8e1a9..befc1d973709 100644 --- a/cpp/tests/reductions/collect_ops_tests.cpp +++ b/cpp/tests/reductions/collect_ops_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/reductions/distinct_count_tests.cpp b/cpp/tests/reductions/distinct_count_tests.cpp index 5e3f60d75c8c..12655805adaf 100644 --- a/cpp/tests/reductions/distinct_count_tests.cpp +++ b/cpp/tests/reductions/distinct_count_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index d1ab5b73e546..a8b1f1f6dce5 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include diff --git a/cpp/tests/reductions/reduction_tests.cpp b/cpp/tests/reductions/reduction_tests.cpp index 6b1261e26dd2..d3926b068d2c 100644 --- a/cpp/tests/reductions/reduction_tests.cpp +++ b/cpp/tests/reductions/reduction_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/reductions/unique_count_tests.cpp b/cpp/tests/reductions/unique_count_tests.cpp index b1a791d10a8b..bb364acfbeee 100644 --- a/cpp/tests/reductions/unique_count_tests.cpp +++ b/cpp/tests/reductions/unique_count_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/reshape/byte_cast_tests.cpp b/cpp/tests/reshape/byte_cast_tests.cpp index 8916fd067e32..850d2ac8c969 100644 --- a/cpp/tests/reshape/byte_cast_tests.cpp +++ b/cpp/tests/reshape/byte_cast_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index dfe198cb5487..32f140d92726 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/rolling/collect_ops_test.cpp b/cpp/tests/rolling/collect_ops_test.cpp index ae2112f5fd8b..ca1f1ba827c8 100644 --- a/cpp/tests/rolling/collect_ops_test.cpp +++ b/cpp/tests/rolling/collect_ops_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/rolling/empty_input_test.cpp b/cpp/tests/rolling/empty_input_test.cpp index f313bb8ad4f1..73c32c9d3504 100644 --- a/cpp/tests/rolling/empty_input_test.cpp +++ b/cpp/tests/rolling/empty_input_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/cpp/tests/rolling/lead_lag_test.cpp b/cpp/tests/rolling/lead_lag_test.cpp index 127d68d04f24..126b3ef4679d 100644 --- a/cpp/tests/rolling/lead_lag_test.cpp +++ b/cpp/tests/rolling/lead_lag_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/rolling/offset_row_window_test.cpp b/cpp/tests/rolling/offset_row_window_test.cpp index 8b272a24c953..59d11972ce60 100644 --- a/cpp/tests/rolling/offset_row_window_test.cpp +++ b/cpp/tests/rolling/offset_row_window_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/rolling/range_rolling_window_test.cpp b/cpp/tests/rolling/range_rolling_window_test.cpp index 0c6586843c9c..e73291c1114c 100644 --- a/cpp/tests/rolling/range_rolling_window_test.cpp +++ b/cpp/tests/rolling/range_rolling_window_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/scalar/factories_test.cpp b/cpp/tests/scalar/factories_test.cpp index b93704177233..91057d81743e 100644 --- a/cpp/tests/scalar/factories_test.cpp +++ b/cpp/tests/scalar/factories_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include diff --git a/cpp/tests/scalar/scalar_test.cpp b/cpp/tests/scalar/scalar_test.cpp index a49d338480ab..df5c8e35e4ef 100644 --- a/cpp/tests/scalar/scalar_test.cpp +++ b/cpp/tests/scalar/scalar_test.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include #include diff --git a/cpp/tests/search/search_list_test.cpp b/cpp/tests/search/search_list_test.cpp index 40cec6d3383d..927ccc3e2d68 100644 --- a/cpp/tests/search/search_list_test.cpp +++ b/cpp/tests/search/search_list_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/search/search_struct_test.cpp b/cpp/tests/search/search_struct_test.cpp index 70ac0e1e04f3..c4f26a3eb7d6 100644 --- a/cpp/tests/search/search_struct_test.cpp +++ b/cpp/tests/search/search_struct_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/sort/is_sorted_tests.cpp b/cpp/tests/sort/is_sorted_tests.cpp index 197eced80c6b..6adc49f60c98 100644 --- a/cpp/tests/sort/is_sorted_tests.cpp +++ b/cpp/tests/sort/is_sorted_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/sort/rank_test.cpp b/cpp/tests/sort/rank_test.cpp index b714afbcb556..27a24033e77c 100644 --- a/cpp/tests/sort/rank_test.cpp +++ b/cpp/tests/sort/rank_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/sort/sort_nested_types_tests.cpp b/cpp/tests/sort/sort_nested_types_tests.cpp index 920ea41e3b91..6b083e59ef34 100644 --- a/cpp/tests/sort/sort_nested_types_tests.cpp +++ b/cpp/tests/sort/sort_nested_types_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index 548bce6ef439..e1434ca8239e 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/sort/top_k_tests.cpp b/cpp/tests/sort/top_k_tests.cpp index 3b30170c2ff9..8293e019353b 100644 --- a/cpp/tests/sort/top_k_tests.cpp +++ b/cpp/tests/sort/top_k_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/stream_compaction/apply_mask_tests.cpp b/cpp/tests/stream_compaction/apply_mask_tests.cpp index 88e1fbcc0e65..f6feb0e7a1b2 100644 --- a/cpp/tests/stream_compaction/apply_mask_tests.cpp +++ b/cpp/tests/stream_compaction/apply_mask_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/stream_compaction/distinct_tests.cpp b/cpp/tests/stream_compaction/distinct_tests.cpp index 5c2e4711c13c..c905244103d3 100644 --- a/cpp/tests/stream_compaction/distinct_tests.cpp +++ b/cpp/tests/stream_compaction/distinct_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/stream_compaction/stable_distinct_tests.cpp b/cpp/tests/stream_compaction/stable_distinct_tests.cpp index 3b8b9103c9b7..206bbac7800d 100644 --- a/cpp/tests/stream_compaction/stable_distinct_tests.cpp +++ b/cpp/tests/stream_compaction/stable_distinct_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/stream_compaction/unique_tests.cpp b/cpp/tests/stream_compaction/unique_tests.cpp index 631b1d43f82e..648fd605a9e4 100644 --- a/cpp/tests/stream_compaction/unique_tests.cpp +++ b/cpp/tests/stream_compaction/unique_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/copying_test.cpp b/cpp/tests/streams/copying_test.cpp index 48624cfb1b0d..80ac01aca25f 100644 --- a/cpp/tests/streams/copying_test.cpp +++ b/cpp/tests/streams/copying_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp b/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp index 2ee203264fec..3bf7df56793b 100644 --- a/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp +++ b/cpp/tests/streams/io/experimental/hybrid_scan_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/io/orc_test.cpp b/cpp/tests/streams/io/orc_test.cpp index 0539500c0e75..a0ebbaf0c523 100644 --- a/cpp/tests/streams/io/orc_test.cpp +++ b/cpp/tests/streams/io/orc_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/io/parquet_test.cpp b/cpp/tests/streams/io/parquet_test.cpp index ee94d8e9f0e6..314c7b9b5019 100644 --- a/cpp/tests/streams/io/parquet_test.cpp +++ b/cpp/tests/streams/io/parquet_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/lists_test.cpp b/cpp/tests/streams/lists_test.cpp index 1706a7f3c880..34e76bf40186 100644 --- a/cpp/tests/streams/lists_test.cpp +++ b/cpp/tests/streams/lists_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/strings/combine_test.cpp b/cpp/tests/streams/strings/combine_test.cpp index fddcfd126518..5652a885f81b 100644 --- a/cpp/tests/streams/strings/combine_test.cpp +++ b/cpp/tests/streams/strings/combine_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/streams/strings/convert_test.cpp b/cpp/tests/streams/strings/convert_test.cpp index 83d6200ccd8e..9a514d3e7f48 100644 --- a/cpp/tests/streams/strings/convert_test.cpp +++ b/cpp/tests/streams/strings/convert_test.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/combine/join_list_elements_tests.cpp b/cpp/tests/strings/combine/join_list_elements_tests.cpp index 421a27ca773c..34c9f8cf2322 100644 --- a/cpp/tests/strings/combine/join_list_elements_tests.cpp +++ b/cpp/tests/strings/combine/join_list_elements_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/extract_tests.cpp b/cpp/tests/strings/extract_tests.cpp index 1c777083f589..ee57dd110431 100644 --- a/cpp/tests/strings/extract_tests.cpp +++ b/cpp/tests/strings/extract_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/find_multiple_tests.cpp b/cpp/tests/strings/find_multiple_tests.cpp index 7f55f0a0a83b..786358f226d9 100644 --- a/cpp/tests/strings/find_multiple_tests.cpp +++ b/cpp/tests/strings/find_multiple_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/findall_tests.cpp b/cpp/tests/strings/findall_tests.cpp index a0a236979ec3..6f4899107363 100644 --- a/cpp/tests/strings/findall_tests.cpp +++ b/cpp/tests/strings/findall_tests.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/format_lists_tests.cpp b/cpp/tests/strings/format_lists_tests.cpp index 75a3304bf1ab..bd6f2d27c6e4 100644 --- a/cpp/tests/strings/format_lists_tests.cpp +++ b/cpp/tests/strings/format_lists_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/strings/split_tests.cpp b/cpp/tests/strings/split_tests.cpp index 6f24c206ac88..11b689926c85 100644 --- a/cpp/tests/strings/split_tests.cpp +++ b/cpp/tests/strings/split_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/structs/structs_column_tests.cpp b/cpp/tests/structs/structs_column_tests.cpp index 016d72c5d54f..563ddb11ff44 100644 --- a/cpp/tests/structs/structs_column_tests.cpp +++ b/cpp/tests/structs/structs_column_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/structs/utilities_tests.cpp b/cpp/tests/structs/utilities_tests.cpp index 691edcb57dd8..dc750f05c5c7 100644 --- a/cpp/tests/structs/utilities_tests.cpp +++ b/cpp/tests/structs/utilities_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/table/table_tests.cpp b/cpp/tests/table/table_tests.cpp index ce0ee70e9332..71fda287d8e4 100644 --- a/cpp/tests/table/table_tests.cpp +++ b/cpp/tests/table/table_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/text/minhash_tests.cpp b/cpp/tests/text/minhash_tests.cpp index c4242853f650..c70979a6b99a 100644 --- a/cpp/tests/text/minhash_tests.cpp +++ b/cpp/tests/text/minhash_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/text/ngrams_tests.cpp b/cpp/tests/text/ngrams_tests.cpp index bc8c19dfdee8..53f864af8495 100644 --- a/cpp/tests/text/ngrams_tests.cpp +++ b/cpp/tests/text/ngrams_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/text/subword_tests.cpp b/cpp/tests/text/subword_tests.cpp index 43ae17bfc250..28aeb2eee7a5 100644 --- a/cpp/tests/text/subword_tests.cpp +++ b/cpp/tests/text/subword_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/text/tokenize_tests.cpp b/cpp/tests/text/tokenize_tests.cpp index b630297d39a0..606b82934b3a 100644 --- a/cpp/tests/text/tokenize_tests.cpp +++ b/cpp/tests/text/tokenize_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/transform/one_hot_encode_tests.cpp b/cpp/tests/transform/one_hot_encode_tests.cpp index 77fa9c35edfe..6704c1788cc2 100644 --- a/cpp/tests/transform/one_hot_encode_tests.cpp +++ b/cpp/tests/transform/one_hot_encode_tests.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/transform/row_bit_count_test.cu b/cpp/tests/transform/row_bit_count_test.cu index 3552a3592fc5..20e329808f0e 100644 --- a/cpp/tests/transform/row_bit_count_test.cu +++ b/cpp/tests/transform/row_bit_count_test.cu @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/unary/math_ops_test.cpp b/cpp/tests/unary/math_ops_test.cpp index 04568abf1069..32d7bdffcd5e 100644 --- a/cpp/tests/unary/math_ops_test.cpp +++ b/cpp/tests/unary/math_ops_test.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index b8f6355fcd7b..b986069f8d4b 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index 8690a5c043ad..e908e65b9d21 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/cpp/tests/utilities_tests/type_check_tests.cpp b/cpp/tests/utilities_tests/type_check_tests.cpp index 02faeeec23fe..ad0d717d0520 100644 --- a/cpp/tests/utilities_tests/type_check_tests.cpp +++ b/cpp/tests/utilities_tests/type_check_tests.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include From 99b9de4df6e177297b38871ed4a79fbdcf1bf166 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 22 Sep 2026 15:17:48 -0500 Subject: [PATCH 19/21] Revert copyright changes --- cpp/tests/copying/gather_struct_tests.cpp | 2 +- cpp/tests/groupby/topk_tests.cpp | 2 +- cpp/tests/search/search_struct_test.cpp | 2 +- cpp/tests/streams/io/parquet_test.cpp | 2 +- cpp/tests/transform/one_hot_encode_tests.cpp | 2 +- cpp/tests/unary/math_ops_test.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/tests/copying/gather_struct_tests.cpp b/cpp/tests/copying/gather_struct_tests.cpp index 81ead171a905..83934b81675d 100644 --- a/cpp/tests/copying/gather_struct_tests.cpp +++ b/cpp/tests/copying/gather_struct_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/groupby/topk_tests.cpp b/cpp/tests/groupby/topk_tests.cpp index 490868507081..3b032988526c 100644 --- a/cpp/tests/groupby/topk_tests.cpp +++ b/cpp/tests/groupby/topk_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/search/search_struct_test.cpp b/cpp/tests/search/search_struct_test.cpp index c4f26a3eb7d6..11f870778811 100644 --- a/cpp/tests/search/search_struct_test.cpp +++ b/cpp/tests/search/search_struct_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/streams/io/parquet_test.cpp b/cpp/tests/streams/io/parquet_test.cpp index 314c7b9b5019..817d1f82dfc6 100644 --- a/cpp/tests/streams/io/parquet_test.cpp +++ b/cpp/tests/streams/io/parquet_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/transform/one_hot_encode_tests.cpp b/cpp/tests/transform/one_hot_encode_tests.cpp index 6704c1788cc2..fb35743938da 100644 --- a/cpp/tests/transform/one_hot_encode_tests.cpp +++ b/cpp/tests/transform/one_hot_encode_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/unary/math_ops_test.cpp b/cpp/tests/unary/math_ops_test.cpp index 32d7bdffcd5e..f93cc3872753 100644 --- a/cpp/tests/unary/math_ops_test.cpp +++ b/cpp/tests/unary/math_ops_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ From 2413ce7e9134936c636e88e4e95059e495f8abce Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 23 Sep 2026 07:59:22 +0000 Subject: [PATCH 20/21] Simplify empty nested list initializers in tests --- cpp/tests/copying/concatenate_tests.cpp | 24 +++---- cpp/tests/copying/pack_tests.cpp | 12 ++-- .../copying/segmented_gather_list_tests.cpp | 12 ++-- cpp/tests/copying/slice_tests.cpp | 12 ++-- cpp/tests/copying/split_tests.cpp | 11 ++- cpp/tests/groupby/collect_list_tests.cpp | 2 +- cpp/tests/groupby/merge_lists_tests.cpp | 2 +- cpp/tests/io/json/json_test.cpp | 8 +-- cpp/tests/io/parquet_chunked_writer_test.cpp | 4 +- cpp/tests/io/parquet_v2_test.cpp | 69 ++++++++----------- .../concatenate_list_elements_tests.cpp | 2 +- .../lists/combine/concatenate_rows_tests.cpp | 14 ++-- cpp/tests/lists/count_elements_tests.cpp | 2 +- cpp/tests/lists/extract_tests.cpp | 2 +- cpp/tests/reductions/list_rank_test.cpp | 8 +-- cpp/tests/sort/sort_test.cpp | 6 +- cpp/tests/strings/format_lists_tests.cpp | 2 +- .../lists_column_wrapper_tests.cpp | 3 +- 18 files changed, 84 insertions(+), 111 deletions(-) diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index a0054ddf18ec..eb9ec8c2b2dd 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -1150,7 +1150,6 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists) // to disambiguate between {} == 0 and {} == List{0} // Also, see note about compiler issues when declaring nested // empty lists in lists_column_wrapper documentation - using LCW = cudf::test::lists_column_wrapper; { cudf::test::lists_column_wrapper a{{{}}, {{0, 1}, {2, 3}}}; cudf::test::lists_column_wrapper b{{{6, 7}}, {{}, {11, 12}}}; @@ -1165,23 +1164,23 @@ TEST_F(ListsColumnTest, ConcatenateNestedEmptyLists) { cudf::test::lists_column_wrapper a{ {{{0, 1, 2}, {}}, {{5}, {6, 7}}, {{8, 9}}}, - {LCW::nested({{}}), {{17, 18}, {19, 20}}}, - {LCW::nested({{}})}, + {{{}}, {{17, 18}, {19, 20}}}, + {{{}}}, {{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}}}; cudf::test::lists_column_wrapper b{ {{{21, 22}, {23, 24}}, {{}, {26, 27}}, {{28, 29, 30}}}, {{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}}, - {LCW::nested({{}})}}; + {{{}}}}; cudf::test::lists_column_wrapper expected{ {{{0, 1, 2}, {}}, {{5}, {6, 7}}, {{8, 9}}}, - {LCW::nested({{}}), {{17, 18}, {19, 20}}}, - {LCW::nested({{}})}, + {{{}}, {{17, 18}, {19, 20}}}, + {{{}}}, {{{50}, {51, 52}}, {{53, 54}, {55, 16, 17}}, {{59, 60}}}, {{{21, 22}, {23, 24}}, {{}, {26, 27}}, {{28, 29, 30}}}, {{{31, 32}, {33, 34}}, {{35, 36}, {37, 38}, {1, 2}}, {{39, 40}}}, - {LCW::nested({{}})}}; + {{{}}}}; auto result = cudf::concatenate(std::vector({a, b})); @@ -1226,10 +1225,9 @@ TEST_F(ListsColumnTest, ConcatenateMismatchedHierarchies) // to disambiguate between {} == 0 and {} == List{0} // Also, see note about compiler issues when declaring nested // empty lists in lists_column_wrapper documentation - using LCW = cudf::test::lists_column_wrapper; { - cudf::test::lists_column_wrapper a{{{LCW::nested({{}})}}}; - cudf::test::lists_column_wrapper b{{LCW::nested({{}})}}; + cudf::test::lists_column_wrapper a{{{{{}}}}}; + cudf::test::lists_column_wrapper b{{{{}}}}; cudf::test::lists_column_wrapper c{{{}}}; EXPECT_THROW(cudf::concatenate(std::vector({a, b, c})), cudf::data_type_error); @@ -1237,15 +1235,15 @@ TEST_F(ListsColumnTest, ConcatenateMismatchedHierarchies) { std::vector valids{false}; - cudf::test::lists_column_wrapper a{{{{LCW::nested({{}})}}, valids.begin()}}; - cudf::test::lists_column_wrapper b{{LCW::nested({{}})}}; + cudf::test::lists_column_wrapper a{{{{{{}}}}, valids.begin()}}; + cudf::test::lists_column_wrapper b{{{{}}}}; cudf::test::lists_column_wrapper c{{{}}}; EXPECT_THROW(cudf::concatenate(std::vector({a, b, c})), cudf::data_type_error); } { - cudf::test::lists_column_wrapper a{{{LCW::nested({{}})}}}; + cudf::test::lists_column_wrapper a{{{{{}}}}}; cudf::test::lists_column_wrapper b{1, 2, 3}; cudf::test::lists_column_wrapper c{{3, 4, 5}}; diff --git a/cpp/tests/copying/pack_tests.cpp b/cpp/tests/copying/pack_tests.cpp index 49c7d4d26d45..00066822b799 100644 --- a/cpp/tests/copying/pack_tests.cpp +++ b/cpp/tests/copying/pack_tests.cpp @@ -153,7 +153,7 @@ std::vector> generate_lists(bool include_validity) LCW::nested({{6}}), {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}, {{-10, -200}, {}, {8, 9}}, {{8}, {}, {9}, {5, 6}}}; @@ -172,7 +172,7 @@ std::vector> generate_lists(bool include_validity) LCW::nested({{6}}), {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}, {{-10, -200}, {}, {8, 9}}, {{8}, {}, {9}, {5, 6}}}; @@ -240,10 +240,10 @@ std::vector> generate_struct_of_list() cudf::test::lists_column_wrapper list( {{{"abc", "d", "edf"}, {"jjj"}}, {{"dgaer", "-7"}, {}}, - LCW::nested({{}}), + {{}}, {{"qwerty"}, {"ral", "ort", "tal"}, {"five", "six"}}, {{}, {}, {"eight", "nine"}}, - LCW::nested({{}}), + {{}}, {{"fun"}, {"a", "bc", "def", "ghij", "klmno", "pqrstu"}}, {{"seven", "zz"}, {}, {"xyzzy"}}, LCW::nested({{"negative 3", " ", "cleveland"}})}, @@ -513,14 +513,12 @@ TEST_F(PackUnpackTest, NestedSliced) { auto valids = cudf::test::iterators::valids_at_multiples_of(2); - using LCW = cudf::test::lists_column_wrapper; - cudf::test::lists_column_wrapper col0{{{{1, 2, 3}, valids}, {4, 5}}, {{{}, {}, {7, 8}, {}}, valids}, {{6, 12}}, {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; cudf::test::strings_column_wrapper col1{ diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index 854781bc7088..a64a5ff27e4b 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -501,9 +501,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const mr = this->resources(); LCW list{ - LCW::nested({{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, LCW::nested({{}})}), - stream, - mr}; + LCW::nested({{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{}}}), stream, mr}; // Per-row singleton lists: {{0},{0},{0}} flattens to one list of three. LCW gather_map({{0}, {0}, {0}}, stream, mr); auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, @@ -511,11 +509,9 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{ - LCW::nested( - {{{2, 3}}, {{6, 7, 8}}, LCW::nested({{}})}), // skip one null, gather one null. - stream, - mr}; + LCW expected{LCW::nested({{{2, 3}}, {{6, 7, 8}}, {{}}}), // skip one null, gather one null. + stream, + mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( results->view(), expected, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } diff --git a/cpp/tests/copying/slice_tests.cpp b/cpp/tests/copying/slice_tests.cpp index 6266d76437e2..6a789d3c5156 100644 --- a/cpp/tests/copying/slice_tests.cpp +++ b/cpp/tests/copying/slice_tests.cpp @@ -193,15 +193,14 @@ TEST_F(SliceListTest, Lists) LCW::nested({{6}}), {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; std::vector indices{1, 3, 3, 6}; std::vector> expected; expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); - expected.push_back( - LCW{{{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, LCW::nested({{}})}); + expected.push_back(LCW{{{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, {{}}}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); @@ -252,16 +251,15 @@ TEST_F(SliceListTest, ListsWithNulls) LCW::nested({{6}}), {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; std::vector indices{1, 3, 3, 6}; std::vector> expected; expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); - expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, - {{{}, {-1, -2, -3, -4, -5}}, valids}, - LCW::nested({{}})}); + expected.push_back(LCW{ + {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}}); std::vector result = cudf::slice(list, indices); EXPECT_EQ(expected.size(), result.size()); diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index eeb15d0aa4e6..37af8a0b52f6 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -784,7 +784,7 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) LCW::nested({{6}}), {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; if (split) { @@ -794,7 +794,7 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) expected.push_back(LCW{{{1, 2, 3}, {4, 5}}}); expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); expected.push_back(LCW{{{7, 8}, {9, 10, 11}, {}}}); - expected.push_back(LCW{{{}, {-1, -2, -3, -4, -5}}, LCW::nested({{}}), {{-10}, {-100, -200}}}); + expected.push_back(LCW{{{}, {-1, -2, -3, -4, -5}}, {{}}, {{-10}, {-100, -200}}}); auto result = Split(list, splits); EXPECT_EQ(expected.size(), result.size()); @@ -860,7 +860,7 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t LCW::nested({{6}}), {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; if (split) { @@ -870,8 +870,7 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t expected.push_back(LCW{{{{1, 2, 3}, valids}, {4, 5}}}); expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}}); - expected.push_back( - LCW{{{{}, {-1, -2, -3, -4, -5}}, valids}, LCW::nested({{}}), {{-10}, {-100, -200}}}); + expected.push_back(LCW{{{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}, {{-10}, {-100, -200}}}); auto result = Split(list, splits); EXPECT_EQ(expected.size(), result.size()); @@ -2178,7 +2177,7 @@ TEST_F(ContiguousSplitTableCornerCases, PreSplitTable) LCW::nested({{6}}), {{{7, 8}, {}, {{9, 10, 11}, valids}}, valids}, {{{-1, -2, -3, -4, -5}, {}}, valids}, - LCW::nested({{}}), + {{}}, {{-10}, {-100, -200}}}; cudf::test::strings_column_wrapper col1{ diff --git a/cpp/tests/groupby/collect_list_tests.cpp b/cpp/tests/groupby/collect_list_tests.cpp index bd341d88ce66..ca67f16ef257 100644 --- a/cpp/tests/groupby/collect_list_tests.cpp +++ b/cpp/tests/groupby/collect_list_tests.cpp @@ -117,7 +117,7 @@ TYPED_TEST(groupby_collect_list_test, CollectListsWithNullExclusion) cudf::test::fixed_width_column_wrapper expect_keys{1, 2, 3, 4}; - LCW expect_vals{{{1, 2}}, LCW::nested({{}}), {{9, 10}, {11}}, {}}; + LCW expect_vals{{{1, 2}}, {{}}, {{9, 10}, {11}}, {}}; auto agg = cudf::make_collect_list_aggregation(cudf::null_policy::EXCLUDE); diff --git a/cpp/tests/groupby/merge_lists_tests.cpp b/cpp/tests/groupby/merge_lists_tests.cpp index 82292fffced7..91c5c62494c8 100644 --- a/cpp/tests/groupby/merge_lists_tests.cpp +++ b/cpp/tests/groupby/merge_lists_tests.cpp @@ -255,7 +255,7 @@ TYPED_TEST(GroupbyMergeListsTypedTest, InputHasListsOfLists) }; auto const lists3 = lists_col{ {{14}, {15, 16, 17, 18}}, // key = 2 - lists_col::nested({{}}), // key = 3 + {{}}, // key = 3 {{17, 18, 19, 20, 21}, {18, 19, 20}} // key = 4 }; diff --git a/cpp/tests/io/json/json_test.cpp b/cpp/tests/io/json/json_test.cpp index e49fe0e7eb08..cbc8befec0ed 100644 --- a/cpp/tests/io/json/json_test.cpp +++ b/cpp/tests/io/json/json_test.cpp @@ -2523,12 +2523,12 @@ TEST_F(JsonReaderTest, MixedTypes) // so, even if mixed types are present, their row offset will be correct. LCWS expected_list({LCWS::nested({{"1", "2", "3"}, {"4", "5", "6"}}), - LCWS::nested({{}}), - LCWS::nested({{}}), // null - LCWS::nested({{}}), // null + {{}}, + {{}}, // null + {{}}, // null LCWS::nested({{"{\"c\": -1}"}, {"5"}}), LCWS::nested({{"7"}, {"8", "9"}}), - LCWS::nested({{}})}, // null + {{}}}, // null valid_t{1, 1, 0, 0, 1, 1, 0}.begin()); test_fn(R"( {"b": [ [1, 2, 3], [ 4, 5, 6] ]} diff --git a/cpp/tests/io/parquet_chunked_writer_test.cpp b/cpp/tests/io/parquet_chunked_writer_test.cpp index dd33cf4789d4..353487f503c4 100644 --- a/cpp/tests/io/parquet_chunked_writer_test.cpp +++ b/cpp/tests/io/parquet_chunked_writer_test.cpp @@ -279,7 +279,7 @@ TEST_F(ParquetChunkedWriterTest, ListOfStructOfStructOfListOfList) // [[1, 2, 3], [], [4, 5], [], [0, 6, 0]] // [[7, 8], []] // [[]] - lcw flats_1{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, lcw::nested({{}})}; + lcw flats_1{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, {{}}}; auto weight_1 = cudf::test::fixed_width_column_wrapper{{57.5, 51.1, 15.3, 1.1}}; auto ages_1 = cudf::test::fixed_width_column_wrapper{{30, 27, 5, 31}}; @@ -429,7 +429,7 @@ TEST_F(ParquetChunkedWriterTest, MismatchedStructureList) // [[7, 8]] // [] // [[]] - lcw col01{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; + lcw col01{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, {{}}}; // COL2 (non-nested columns to test proper schema construction) size_t num_rows = static_cast(col00).size(); diff --git a/cpp/tests/io/parquet_v2_test.cpp b/cpp/tests/io/parquet_v2_test.cpp index 192001eab91a..16be6c00a7ee 100644 --- a/cpp/tests/io/parquet_v2_test.cpp +++ b/cpp/tests/io/parquet_v2_test.cpp @@ -294,12 +294,12 @@ TEST_P(ParquetV2Test, SlicedTable) lcw col4{{ {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, - lcw::nested({lcw::nested({{}})}), + {{{{}}, {}, {}, {{}}}, valids}, + {{{}}}, {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - lcw::nested({lcw::nested({{}})}), - {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, + {{{}}}, + {{{{}}, {}, {}, {{}}}, valids}, }, valids2}; @@ -333,8 +333,8 @@ TEST_P(ParquetV2Test, SlicedTable) lcw flats{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, - lcw::nested({{}}), - lcw::nested({{}}), + {{}}, + {{}}, {{}, {}, {}}, lcw::nested({{10}}), {{13, 14}, {15}}}; @@ -397,23 +397,21 @@ TEST_P(ParquetV2Test, ListColumn) // [[7, 8]] // [] // [[]] - lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; + lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, {{}}}; // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] // [[7, 8]] // [] // [[]] - lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, valids2}, {{7, 8}}, {}, lcw::nested({{}})}; + lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, valids2}, {{7, 8}}, {}, {{}}}; // [[1, 2, 3], [], [4, 5], NULL, [NULL, 6, NULL]] // [[7, 8]] // [] // [[]] using dlcw = cudf::test::lists_column_wrapper; - dlcw col3{{{{1., 2., 3.}, {}, {4., 5.}, {}, {{0., 6., 0.}, valids}}, valids2}, - {{7., 8.}}, - {}, - dlcw::nested({{}})}; + dlcw col3{ + {{{1., 2., 3.}, {}, {4., 5.}, {}, {{0., 6., 0.}, valids}}, valids2}, {{7., 8.}}, {}, {{}}}; // TODO: uint16_t lists are not read properly in parquet reader // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -429,16 +427,14 @@ TEST_P(ParquetV2Test, ListColumn) // [[7, 8]] // [] // NULL - lcw col5{ - {{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, valids}}, valids2}, {{7, 8}}, {}, lcw::nested({{}})}, - valids2}; + lcw col5{{{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, valids}}, valids2}, {{7, 8}}, {}, {{}}}, + valids2}; - using strlcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col6{ {{"Monday", "Monday", "Friday"}, {}, {"Monday", "Friday"}, {}, {"Sunday", "Funday"}}, {{"bee", "sting"}}, {}, - strlcw::nested({{}})}; + {{}}}; // [[[NULL,2,NULL,4]], [[NULL,6,NULL], [8,9]]] // [NULL, [[13],[14,15,16]], NULL] @@ -447,8 +443,8 @@ TEST_P(ParquetV2Test, ListColumn) lcw col7{{ {{{{1, 2, 3, 4}, valids}}, {{{5, 6, 7}, valids}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, valids}, - {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, valids}, - lcw::nested({lcw::nested({{}})}), + {{{{}}, {}, {}, {{}}}, valids}, + {{{}}}, }, valids2}; @@ -516,12 +512,7 @@ TEST_P(ParquetV2Test, StructOfList) // [[]] // [[]] // [[], [], []] - lcw flats{{}, - {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, - {{7, 8}, {}}, - lcw::nested({{}}), - lcw::nested({{}}), - {{}, {}, {}}}; + lcw flats{{}, {{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}, {}}, {{}}, {{}}, {{}, {}, {}}}; auto struct_1 = cudf::test::structs_column_wrapper{{weights_col, ages_col, land_unit, flats}, {true, true, true, true, false, true}}; @@ -1188,7 +1179,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // [[]] // def histogram [1, 3, 10] // rep histogram [4, 4, 6] - lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, lcw::nested({{}})}; + lcw col1{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, {{7, 8}}, {}, {{}}}; // 4 nulls // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -1197,7 +1188,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // [[]] // def histogram [1, 1, 2, 10] // rep histogram [4, 4, 6] - lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, lcw::nested({{}})}; + lcw col2{{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, {{}}}; // 6 nulls // [[1, 2, 3], [], [4, 5], NULL, [NULL, 6, NULL]] @@ -1210,7 +1201,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) dlcw col3{{{{1., 2., 3.}, {}, {4., 5.}, {}, {{0., 6., 0.}, nulls_at({0, 2})}}, null_at(3)}, {{7., 8.}}, {}, - dlcw::nested({{}})}; + {{}}}; // 4 nulls // [[1, 2, 3], [], [4, 5], NULL, [0, 6, 0]] @@ -1219,10 +1210,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // NULL // def histogram [1, 1, 1, 1, 10] // rep histogram [4, 4, 6] - using ui16lcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col4{ - {{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, ui16lcw::nested({{}})}, - null_at(3)}; + {{{{1, 2, 3}, {}, {4, 5}, {}, {0, 6, 0}}, null_at(3)}, {{7, 8}}, {}, {{}}}, null_at(3)}; // 6 nulls // [[1, 2, 3], [], [4, 5], NULL, [NULL, 6, NULL]] @@ -1231,26 +1220,22 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) // NULL // def histogram [1, 1, 1, 1, 2, 8] // rep histogram [4, 4, 6] - lcw col5{{{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, nulls_at({0, 2})}}, null_at(3)}, - {{7, 8}}, - {}, - lcw::nested({{}})}, - null_at(3)}; + lcw col5{ + {{{{1, 2, 3}, {}, {4, 5}, {}, {{0, 6, 0}, nulls_at({0, 2})}}, null_at(3)}, {{7, 8}}, {}, {{}}}, + null_at(3)}; // 4 nulls // def histogram [1, 3, 9] // rep histogram [4, 4, 5] - using strlcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col6{ {{"Monday", "Monday", "Friday"}, {}, {"Monday", "Friday"}, {}, {"Sunday", "Funday"}}, {{"bee", "sting"}}, {}, - strlcw::nested({{}})}; + {{}}}; // 5 nulls // def histogram [1, 3, 1, 8] // rep histogram [4, 4, 5] - using strlcw = cudf::test::lists_column_wrapper; cudf::test::lists_column_wrapper col7{{{"Monday", "Monday", "Friday"}, {}, {{"Monday", "Friday"}, null_at(1)}, @@ -1258,7 +1243,7 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) {"Sunday", "Funday"}}, {{"bee", "sting"}}, {}, - strlcw::nested({{}})}; + {{}}}; // 11 nulls // D 5 6 5 6 5 6 5 6 6 @@ -1278,8 +1263,8 @@ TEST_P(ParquetV2Test, CheckColumnIndexListWithNulls) lcw col8{{ {{{{1, 2, 3, 4}, nulls_at({0, 2})}}, {{{5, 6, 7}, nulls_at({0, 2})}, {8, 9}}}, {{{{10, 11}, {12}}, {{13}, {14, 15, 16}}, {{17, 18}}}, nulls_at({0, 2})}, - {{lcw::nested({{}}), {}, {}, lcw::nested({{}})}, nulls_at({0, 2})}, - lcw::nested({lcw::nested({{}})}), + {{{{}}, {}, {}, {{}}}, nulls_at({0, 2})}, + {{{}}}, }, null_at(3)}; diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index 7824a06f4abe..2fe52dc519a9 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -156,7 +156,7 @@ TYPED_TEST(ConcatenateListElementsTypedTest, SimpleInputNestedManyLevelsWithNull { auto const results = cudf::lists::concatenate_list_elements( col, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); - auto const expected = ListsCol({ListsCol::nested({{}}), /*NULL*/ + auto const expected = ListsCol({{{}}, /*NULL*/ {{{1, 2}, {3}, {} /*NULL*/, {}, {7, 8}, {9, 10}}, null_at(2)}, {{1, 2}, {3}, {4, 5, 6}, {}, {{null, 8}, null_at(0)}, {9, 10}}}, null_at(0)); diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index a0716e3cba16..49bb03d23bd9 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -512,7 +512,7 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) // col 0 StrListsCol l0({{{{"whee", "yay", "bananas"}, nulls_at({1})}, {}}, - StrListsCol::nested({{}}), + {{}}, {{{"abc"}, {"def", "g", "xyw", "ijk"}, {"x", "y", "", "column"}}, nulls_at({0, 2})}, {{"f", "tesla"}}, @@ -520,14 +520,14 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) nulls_at({3, 4})); // col1 - StrListsCol l1({StrListsCol::nested({{}}), + StrListsCol l1({{{}}, {{"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}}, {{{{"", "hhh"}, nulls_at({0})}, {"www"}}, nulls_at({1})}, {{"warp", "donuts", "parking"}, {"", "apply", "twelve", "mouse", "bbb"}, {"bbb", "pom"}, {}}, - StrListsCol::nested({{}})}, + {{}}}, nulls_at({4})); // col2 @@ -563,7 +563,7 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) {}, {"ram", "cpu", "disk"}, {}}, - StrListsCol::nested({{}})}, + {{}}}, nulls_at({4})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, expected); @@ -576,7 +576,7 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) auto result = cudf::lists::concatenate_rows(t, cudf::lists::concatenate_null_policy::NULLIFY_OUTPUT_ROW); // expected - StrListsCol expected({StrListsCol::nested({{}}), + StrListsCol expected({{{}}, {{}, {"arg"}, {"mno", "ampere"}, {"gpu"}, {"def"}, {"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, {{{"abc"}, {"def", "g", "xyw", "ijk"}, @@ -587,8 +587,8 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) {"abc"}, {"mno", "pqr"}}, nulls_at({0, 2, 4})}, - StrListsCol::nested({{}}), - StrListsCol::nested({{}})}, + {{}}, + {{}}}, nulls_at({0, 3, 4})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, expected); diff --git a/cpp/tests/lists/count_elements_tests.cpp b/cpp/tests/lists/count_elements_tests.cpp index 465458d63f9d..6cd01f39107e 100644 --- a/cpp/tests/lists/count_elements_tests.cpp +++ b/cpp/tests/lists/count_elements_tests.cpp @@ -68,7 +68,7 @@ TYPED_TEST(ListsElementsNumericsTest, CountElementsNestedLists) std::vector validity{1, 0, 1, 1}; using LCW = cudf::test::lists_column_wrapper; LCW list({{{2, 3}, {4, 5}}, - LCW::nested({{}}), + {{}}, {{6, 7, 8}, {9, 10, 11}, {{12, 13, 14}, validity.begin()}}, {{15, 16}, {17, 18}, {19, 20}, {21, 22}, {23, 24}}}, validity.begin()); diff --git a/cpp/tests/lists/extract_tests.cpp b/cpp/tests/lists/extract_tests.cpp index d6abed10bf5e..acbf3b11d9b9 100644 --- a/cpp/tests/lists/extract_tests.cpp +++ b/cpp/tests/lists/extract_tests.cpp @@ -163,7 +163,7 @@ TYPED_TEST(ListsExtractNumericsTest, ExtractElementNestedLists) std::vector validity{1, 0, 1, 1}; using LCW = cudf::test::lists_column_wrapper; LCW list({{{2, 3}, {4, 5}}, - LCW::nested({{}}), + {{}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{15, 16}, {17, 18}, {19, 20}, {21, 22}, {23, 24}}}, validity.begin()); diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index a8b1f1f6dce5..c9d34d021610 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -43,9 +43,9 @@ TEST_F(ListRankScanTest, DeepList) {{1, 2, 3}, {}, {4, 5}, {0, 6, 0}}, {{7, 8}, {}}, {{}, {}, {}}, - lcw::nested({{}}), - lcw::nested({{}}), - lcw::nested({{}}), + {{}}, + {{}}, + {{}}, {{}, {}, {}}, {{}, {}, {}}, lcw::nested({{10}}), @@ -53,7 +53,7 @@ TEST_F(ListRankScanTest, DeepList) {{13, 14}, {15}}, {{13, 14}, {16}}, {}, - lcw::nested({{}}), + {{}}, }; { // Non-sliced diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index e1434ca8239e..2ee8581a1df0 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -742,7 +742,7 @@ TYPED_TEST(Sort, WithListColumn) {{1, 2}, {3}, {4, 5}, {0, 6, 0}}, {{7, 8}, {}}, {{}, {}, {}}, - lcw::nested({{}}), + {{}}, lcw::nested({{10}}), {}}; @@ -784,7 +784,7 @@ TYPED_TEST(Sort, WithNullableListColumn) {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0})}}, // 4 {{7, 8}, {}}, // 5 {{}, {}, {}}, // 6 - lcw::nested({{}}), // 7 + {{}}, // 7 lcw::nested({{10}}), // 8 {}, // 9 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 10 @@ -924,7 +924,7 @@ TYPED_TEST(Sort, WithSlicedListColumn) {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0})}}, // 3 {{7, 8}, {}}, // 4 {{}, {}, {}}, // 5 - lcw::nested({{}}), // 6 + {{}}, // 6 lcw::nested({{10}}), // 7 {}, // 8 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 9 diff --git a/cpp/tests/strings/format_lists_tests.cpp b/cpp/tests/strings/format_lists_tests.cpp index bd6f2d27c6e4..5b3eb3592a43 100644 --- a/cpp/tests/strings/format_lists_tests.cpp +++ b/cpp/tests/strings/format_lists_tests.cpp @@ -29,7 +29,7 @@ TEST_F(StringsFormatListsTest, EmptyNestedList) { using STR_LISTS = cudf::test::lists_column_wrapper; - auto const input = STR_LISTS{{{}, {}}, STR_LISTS::nested({{}})}; + auto const input = STR_LISTS{{{}, {}}, {{}}}; auto const view = cudf::lists_column_view(input); auto results = cudf::strings::format_list_column(view); diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index e908e65b9d21..ff793fb055ac 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -569,7 +569,6 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) using T = TypeParam; // Use nested() to disambiguate between {} == 0 and {} == List{0}. - using LCW = cudf::test::lists_column_wrapper; auto valids = cudf::test::iterators::valids_at_multiples_of(2); @@ -656,7 +655,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, EmptyListsWithValidity) { // equivalent to { {{}}, NULL, {{}, {5, 6, 7, 8}, {}} } cudf::test::lists_column_wrapper list{ - {LCW::nested({{}}), {{1, 2}, {}, {3, 4}}, {{}, {5, 6, 7, 8}, {}}}, valids}; + {{{}}, {{1, 2}, {}, {3, 4}}, {{}, {5, 6, 7, 8}, {}}}, valids}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); From 9a48c6667f2431cf58899e3bccca54e2feb0b8cc Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 23 Sep 2026 15:02:51 +0000 Subject: [PATCH 21/21] Avoid nested calls --- cpp/tests/copying/get_value_tests.cpp | 24 +++++++------- cpp/tests/copying/pack_tests.cpp | 9 ++---- .../copying/scatter_list_scalar_tests.cpp | 12 +++---- .../copying/segmented_gather_list_tests.cpp | 5 ++- cpp/tests/copying/slice_tests.cpp | 8 ++--- cpp/tests/copying/split_tests.cpp | 16 ++++------ cpp/tests/interop/from_arrow_device_test.cpp | 2 +- cpp/tests/interop/from_arrow_host_test.cpp | 2 +- cpp/tests/interop/to_arrow_device_test.cpp | 2 +- cpp/tests/interop/to_arrow_host_test.cpp | 2 +- cpp/tests/io/json/json_test.cpp | 4 +-- cpp/tests/io/parquet_v2_test.cpp | 2 +- .../concatenate_list_elements_tests.cpp | 4 +-- .../lists/combine/concatenate_rows_tests.cpp | 8 ++--- cpp/tests/lists/explode_tests.cpp | 32 +++++++------------ cpp/tests/merge/merge_test.cpp | 17 +++------- cpp/tests/reductions/list_rank_test.cpp | 4 +-- cpp/tests/reductions/reduction_tests.cpp | 3 +- cpp/tests/sort/sort_test.cpp | 10 +++--- .../lists_column_wrapper_tests.cpp | 2 +- .../utilities_tests/type_check_tests.cpp | 8 ++--- 21 files changed, 76 insertions(+), 100 deletions(-) diff --git a/cpp/tests/copying/get_value_tests.cpp b/cpp/tests/copying/get_value_tests.cpp index 91b8273e2862..5447bdf55c06 100644 --- a/cpp/tests/copying/get_value_tests.cpp +++ b/cpp/tests/copying/get_value_tests.cpp @@ -233,8 +233,8 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullNonEmpty) LCW col{ {{1, 2}, {34}}, {}, - LCW::nested({{1}}), - LCW::nested({{42}, {10}}) + {{1}}, + {{42}, {10}} }; // clang-format on LCW expected_data({{42}, {10}}); @@ -257,8 +257,8 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullNonEmptyPreserveNull) LCW col{ {{1, 2}, {34}}, {}, - LCW::nested({{1}}), - LCW::nested({{42}, {10}, {{1, 3, 2}, this->nth_valid(1)}}, valid.begin()) + {{1}}, + {{{42}, {10}, {{1, 3, 2}, this->nth_valid(1)}}, valid.begin()} }; // clang-format on LCW expected_data({{42}, {10}, {{1, 3, 2}, this->nth_valid(1)}}, valid.begin()); @@ -279,8 +279,8 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNonNullEmpty) LCW col{ {{1, 2}, {34}}, {}, - LCW::nested({{1}}), - LCW::nested({{42}, {10}}) + {{1}}, + {{42}, {10}} }; // clang-format on LCW expected_data{}; @@ -303,10 +303,10 @@ TYPED_TEST(ListGetFixedWidthValueTest, NestedGetNull) // clang-format off LCW col( { - LCW::nested({{1, 2}, {34}}), + {{1, 2}, {34}}, {}, - LCW::nested({{1}}), - LCW::nested({{42}, {10}}) + {{1}}, + {{42}, {10}} }, valid.begin()); // clang-format on cudf::size_type index = 1; @@ -384,7 +384,7 @@ TEST_F(ListGetStringValueTest, NestedGetNonNullNonEmpty) LCW col{ {{"aaa", "Héllo"}}, {}, - LCW::nested({{""}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}), + {{""}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}, LCW::nested({{"42"}, {"21"}}) }; // clang-format on @@ -407,7 +407,7 @@ TEST_F(ListGetStringValueTest, NestedGetNonNullNonEmptyPreserveNull) LCW col{ {{"aaa", "Héllo"}}, {}, - LCW::nested({{""}, {"cc"}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}, valid.begin()), + {{{""}, {"cc"}, {{"string", "str2", "xyz"}, this->nth_valid(0)}}, valid.begin()}, LCW::nested({{"42"}, {"21"}}) }; // clang-format on @@ -455,7 +455,7 @@ TEST_F(ListGetStringValueTest, NestedGetNull) // clang-format off LCW col( { - LCW::nested({{"aaa", "Héllo"}}), + {{"aaa", "Héllo"}}, LCW::nested({{""}}), LCW::nested({{"42"}, {"21"}}), {} diff --git a/cpp/tests/copying/pack_tests.cpp b/cpp/tests/copying/pack_tests.cpp index 00066822b799..c2b2fb6f93b4 100644 --- a/cpp/tests/copying/pack_tests.cpp +++ b/cpp/tests/copying/pack_tests.cpp @@ -134,8 +134,6 @@ TEST_F(PackUnpackTest, EmptyColumns) std::vector> generate_lists(bool include_validity) { - using LCW = cudf::test::lists_column_wrapper; - if (include_validity) { auto valids = cudf::test::iterators::valids_at_multiples_of(2); cudf::test::lists_column_wrapper list0{{1, 2, 3}, @@ -150,7 +148,7 @@ std::vector> generate_lists(bool include_validity) cudf::test::lists_column_wrapper list1{{{{1, 2, 3}, valids}, {4, 5}}, {{{}, {}, {7, 8}, {}}, valids}, - LCW::nested({{6}}), + {{6}}, {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}, @@ -169,7 +167,7 @@ std::vector> generate_lists(bool include_validity) cudf::test::lists_column_wrapper list1{{{1, 2, 3}, {4, 5}}, {{}, {}, {7, 8}, {}}, - LCW::nested({{6}}), + {{6}}, {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, {{}}, @@ -235,7 +233,6 @@ std::vector> generate_struct_of_list() cudf::test::fixed_width_column_wrapper(ages.begin(), ages.end(), ages_validity.begin()); // 3. List column - using LCW = cudf::test::lists_column_wrapper; std::vector list_validity{true, true, true, true, true, false, true, false, true}; cudf::test::lists_column_wrapper list( {{{"abc", "d", "edf"}, {"jjj"}}, @@ -246,7 +243,7 @@ std::vector> generate_struct_of_list() {{}}, {{"fun"}, {"a", "bc", "def", "ghij", "klmno", "pqrstu"}}, {{"seven", "zz"}, {}, {"xyzzy"}}, - LCW::nested({{"negative 3", " ", "cleveland"}})}, + {{"negative 3", " ", "cleveland"}}}, list_validity.begin()); // Assemble struct column. diff --git a/cpp/tests/copying/scatter_list_scalar_tests.cpp b/cpp/tests/copying/scatter_list_scalar_tests.cpp index 0c2cad19615b..87b841449221 100644 --- a/cpp/tests/copying/scatter_list_scalar_tests.cpp +++ b/cpp/tests/copying/scatter_list_scalar_tests.cpp @@ -190,7 +190,7 @@ TYPED_TEST(ScatterListOfListScalarTest, Basic) LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, {{55, 55}, {}, {10, 10, 10}}, - LCW::nested({{44, 44}})}); + {{44, 44}}}); size_column scatter_map{1, 2, 3}; @@ -211,7 +211,7 @@ TYPED_TEST(ScatterListOfListScalarTest, EmptyValidScalar) LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, {{55, 55}, {}, {10, 10, 10}}, - LCW::nested({{44, 44}})}); + {{44, 44}}}); size_column scatter_map{3, 0}; @@ -231,11 +231,11 @@ TYPED_TEST(ScatterListOfListScalarTest, NullScalar) auto slr = std::make_unique(LCW{}, false); LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, - LCW::nested({{44, 44}})}); + {{44, 44}}}); size_column scatter_map{1, 0}; - LCW expected({{}, {}, LCW::nested({{44, 44}})}, mask_vector{0, 0, 1}.begin()); + LCW expected({{}, {}, {{44, 44}}}, mask_vector{0, 0, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*result, expected); @@ -250,14 +250,14 @@ TYPED_TEST(ScatterListOfListScalarTest, NullableTargetRows) LCW col({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, {{66}, {}, {{77, 77, 77, 77}, mask_vector{1, 0, 0, 1}.begin()}}, - LCW::nested({{44, 44}})}, + {{44, 44}}}, mask_vector{1, 0, 1}.begin()); size_column scatter_map{1}; LCW expected({{{{88, 88}, {}, {9, 9, 9}}, mask_vector{1, 0, 1}.begin()}, {{{1, 1, 1}, {3, 3}, {}, {4}}, mask_vector{1, 1, 0, 1}.begin()}, - LCW::nested({{44, 44}})}, + {{44, 44}}}, mask_vector{1, 1, 1}.begin()); auto result = single_scalar_scatter(col, *slr, scatter_map); diff --git a/cpp/tests/copying/segmented_gather_list_tests.cpp b/cpp/tests/copying/segmented_gather_list_tests.cpp index a64a5ff27e4b..be45993f1077 100644 --- a/cpp/tests/copying/segmented_gather_list_tests.cpp +++ b/cpp/tests/copying/segmented_gather_list_tests.cpp @@ -500,8 +500,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) auto const stream = this->stream(); auto const mr = this->resources(); - LCW list{ - LCW::nested({{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{}}}), stream, mr}; + LCW list{{{{2, 3}, {}}, {{6, 7, 8}, {9, 10, 11}, {12, 13, 14}}, {{}}}, stream, mr}; // Per-row singleton lists: {{0},{0},{0}} flattens to one list of three. LCW gather_map({{0}, {0}, {0}}, stream, mr); auto results = cudf::lists::segmented_gather(cudf::lists_column_view{list}, @@ -509,7 +508,7 @@ TYPED_TEST(SegmentedGatherTest, GatherNestedWithEmpties) cudf::out_of_bounds_policy::DONT_CHECK, stream, mr.get_output_mr()); - LCW expected{LCW::nested({{{2, 3}}, {{6, 7, 8}}, {{}}}), // skip one null, gather one null. + LCW expected{{{{2, 3}}, {{6, 7, 8}}, {{}}}, // skip one null, gather one null. stream, mr}; CUDF_TEST_EXPECT_COLUMNS_EQUAL( diff --git a/cpp/tests/copying/slice_tests.cpp b/cpp/tests/copying/slice_tests.cpp index 6a789d3c5156..e0df2e439599 100644 --- a/cpp/tests/copying/slice_tests.cpp +++ b/cpp/tests/copying/slice_tests.cpp @@ -190,7 +190,7 @@ TEST_F(SliceListTest, Lists) { cudf::test::lists_column_wrapper list{{{1, 2, 3}, {4, 5}}, {{}, {}, {7, 8}, {}}, - LCW::nested({{6}}), + {{6}}, {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, {{}}, @@ -199,7 +199,7 @@ TEST_F(SliceListTest, Lists) std::vector indices{1, 3, 3, 6}; std::vector> expected; - expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); + expected.push_back(LCW{{{}, {}, {7, 8}, {}}, {{6}}}); expected.push_back(LCW{{{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, {{}}}); std::vector result = cudf::slice(list, indices); @@ -248,7 +248,7 @@ TEST_F(SliceListTest, ListsWithNulls) { cudf::test::lists_column_wrapper list{{{{1, 2, 3}, valids}, {4, 5}}, {{{}, {}, {7, 8}, {}}, valids}, - LCW::nested({{6}}), + {{6}}, {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}, @@ -257,7 +257,7 @@ TEST_F(SliceListTest, ListsWithNulls) std::vector indices{1, 3, 3, 6}; std::vector> expected; - expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); + expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, {{6}}}); expected.push_back(LCW{ {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}}); diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index 37af8a0b52f6..08c9b8e85667 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -781,7 +781,7 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) { cudf::test::lists_column_wrapper list{{{1, 2, 3}, {4, 5}}, {{}, {}, {7, 8}, {}}, - LCW::nested({{6}}), + {{6}}, {{7, 8}, {9, 10, 11}, {}}, {{}, {-1, -2, -3, -4, -5}}, {{}}, @@ -792,7 +792,7 @@ void split_lists(SplitFunc Split, CompareFunc Compare, bool split = true) std::vector> expected; expected.push_back(LCW{{{1, 2, 3}, {4, 5}}}); - expected.push_back(LCW{{{}, {}, {7, 8}, {}}, LCW::nested({{6}})}); + expected.push_back(LCW{{{}, {}, {7, 8}, {}}, {{6}}}); expected.push_back(LCW{{{7, 8}, {9, 10, 11}, {}}}); expected.push_back(LCW{{{}, {-1, -2, -3, -4, -5}}, {{}}, {{-10}, {-100, -200}}}); @@ -857,7 +857,7 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t { cudf::test::lists_column_wrapper list{{{{1, 2, 3}, valids}, {4, 5}}, {{{}, {}, {7, 8}, {}}, valids}, - LCW::nested({{6}}), + {{6}}, {{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}, {{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}, @@ -868,7 +868,7 @@ void split_lists_with_nulls(SplitFunc Split, CompareFunc Compare, bool split = t std::vector> expected; expected.push_back(LCW{{{{1, 2, 3}, valids}, {4, 5}}}); - expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, LCW::nested({{6}})}); + expected.push_back(LCW{{{{}, {}, {7, 8}, {}}, valids}, {{6}}}); expected.push_back(LCW{{{{7, 8}, {{9, 10, 11}, valids}, {}}, valids}}); expected.push_back(LCW{{{{}, {-1, -2, -3, -4, -5}}, valids}, {{}}, {{-10}, {-100, -200}}}); @@ -1082,7 +1082,7 @@ void split_nested_struct_of_list(SplitFunc Split, CompareFunc Compare, bool spli {}, {{8}, {10, 9, 8, 7, 6, 5}}, {{5, 6}, {}, {8}}, - LCW::nested({{-3, 4, -5}})}, + {{-3, 4, -5}}}, list_validity.begin()); // Assemble struct column. @@ -1107,7 +1107,7 @@ void split_nested_struct_of_list(SplitFunc Split, CompareFunc Compare, bool spli {{8}, {10, 9, 8, 7, 6, 5}}, {{5, 6}, {}, {8}}}, ex_v.begin())); - expected_lists.push_back(LCW({LCW::nested({{-3, 4, -5}})})); + expected_lists.push_back(LCW({{{-3, 4, -5}}})); auto expected_struct_validity = create_expected_validity(splits, struct_validity); EXPECT_EQ(expected_names.size(), result.size()); @@ -2170,11 +2170,9 @@ TEST_F(ContiguousSplitTableCornerCases, PreSplitTable) { auto valids = cudf::test::iterators::valids_at_multiples_of(2); - using LCW = cudf::test::lists_column_wrapper; - cudf::test::lists_column_wrapper col0{{{1, 2, 3}, {4, 5}}, {{{}, {}, {7, 8}, {}}, valids}, - LCW::nested({{6}}), + {{6}}, {{{7, 8}, {}, {{9, 10, 11}, valids}}, valids}, {{{-1, -2, -3, -4, -5}, {}}, valids}, {{}}, diff --git a/cpp/tests/interop/from_arrow_device_test.cpp b/cpp/tests/interop/from_arrow_device_test.cpp index 01b0b0471a24..21b654a130c2 100644 --- a/cpp/tests/interop/from_arrow_device_test.cpp +++ b/cpp/tests/interop/from_arrow_device_test.cpp @@ -536,7 +536,7 @@ TEST_F(FromArrowDeviceTest, StructColumn) cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); using LCW = cudf::test::lists_column_wrapper; - auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, {{6}}, {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/from_arrow_host_test.cpp b/cpp/tests/interop/from_arrow_host_test.cpp index d953b045db68..b1a90872885e 100644 --- a/cpp/tests/interop/from_arrow_host_test.cpp +++ b/cpp/tests/interop/from_arrow_host_test.cpp @@ -802,7 +802,7 @@ TEST_F(FromArrowHostDeviceTest, StructColumn) cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); using LCW = cudf::test::lists_column_wrapper; - auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, {{6}}, {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/to_arrow_device_test.cpp b/cpp/tests/interop/to_arrow_device_test.cpp index 22a9e07fe651..e48abd2e25c6 100644 --- a/cpp/tests/interop/to_arrow_device_test.cpp +++ b/cpp/tests/interop/to_arrow_device_test.cpp @@ -369,7 +369,7 @@ TEST_F(ToArrowDeviceTest, StructColumn) cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); using LCW = cudf::test::lists_column_wrapper; - auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, {{6}}, {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/interop/to_arrow_host_test.cpp b/cpp/tests/interop/to_arrow_host_test.cpp index f7fdb83584fe..95f0cc91132a 100644 --- a/cpp/tests/interop/to_arrow_host_test.cpp +++ b/cpp/tests/interop/to_arrow_host_test.cpp @@ -584,7 +584,7 @@ TEST_F(ToArrowHostDeviceTest, StructColumn) cudf::test::fixed_width_column_wrapper{{12, 24, 47}, {1, 0, 1}}.release(); auto bool_col = cudf::test::fixed_width_column_wrapper{{true, true, false}}.release(); using LCW = cudf::test::lists_column_wrapper; - auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, LCW::nested({{6}}), {{7}, {8, 9}}}.release(); + auto list_col = LCW{{{1, 2}, {3, 4}, {5}}, {{6}}, {{7}, {8, 9}}}.release(); vector_of_columns cols2; cols2.push_back(std::move(str_col2)); cols2.push_back(std::move(int_col2)); diff --git a/cpp/tests/io/json/json_test.cpp b/cpp/tests/io/json/json_test.cpp index cbc8befec0ed..829b8bd125b2 100644 --- a/cpp/tests/io/json/json_test.cpp +++ b/cpp/tests/io/json/json_test.cpp @@ -2522,12 +2522,12 @@ TEST_F(JsonReaderTest, MixedTypes) // max_rowoffsets is generated based on parent col id, // so, even if mixed types are present, their row offset will be correct. - LCWS expected_list({LCWS::nested({{"1", "2", "3"}, {"4", "5", "6"}}), + LCWS expected_list({{{"1", "2", "3"}, {"4", "5", "6"}}, {{}}, {{}}, // null {{}}, // null LCWS::nested({{"{\"c\": -1}"}, {"5"}}), - LCWS::nested({{"7"}, {"8", "9"}}), + {{"7"}, {"8", "9"}}, {{}}}, // null valid_t{1, 1, 0, 0, 1, 1, 0}.begin()); test_fn(R"( diff --git a/cpp/tests/io/parquet_v2_test.cpp b/cpp/tests/io/parquet_v2_test.cpp index 16be6c00a7ee..a19a816fc762 100644 --- a/cpp/tests/io/parquet_v2_test.cpp +++ b/cpp/tests/io/parquet_v2_test.cpp @@ -336,7 +336,7 @@ TEST_P(ParquetV2Test, SlicedTable) {{}}, {{}}, {{}, {}, {}}, - lcw::nested({{10}}), + {{10}}, {{13, 14}, {15}}}; auto struct_1 = cudf::test::structs_column_wrapper{land, flats}; diff --git a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp index 2fe52dc519a9..21eb06c17f84 100644 --- a/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_list_elements_tests.cpp @@ -171,7 +171,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithNulls) {{"Orange", "Dog" /*NULL*/, "Fox" /*NULL*/, "Duck" /*NULL*/}, nulls_at({1, 2, 3})}}, {{{"Banana", "Pig" /*NULL*/, "Kiwi", "Cherry", "Whale" /*NULL*/}, nulls_at({1, 4})}, {"Lemon", "Peach"}}, - StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1))}; + {{{"Coconut"}, {} /*NULL*/}, null_at(1)}}; // Ignore null list elements. { @@ -203,7 +203,7 @@ TEST_F(ConcatenateListElementsTest, SimpleInputStringsColumnWithEmptyStringsAndN auto const col = StrListsCol{ {{"", "", ""}, {{"Orange", "" /*NULL*/, "" /*NULL*/, "" /*NULL*/}, nulls_at({1, 2, 3})}}, {{{"Banana", "" /*NULL*/, "Kiwi", "Cherry", "" /*NULL*/}, nulls_at({1, 4})}, {""}}, - StrListsCol::nested({{"Coconut"}, {} /*NULL*/}, null_at(1))}; + {{{"Coconut"}, {} /*NULL*/}, null_at(1)}}; // Ignore null list elements. { diff --git a/cpp/tests/lists/combine/concatenate_rows_tests.cpp b/cpp/tests/lists/combine/concatenate_rows_tests.cpp index 49bb03d23bd9..cf7b204aded2 100644 --- a/cpp/tests/lists/combine/concatenate_rows_tests.cpp +++ b/cpp/tests/lists/combine/concatenate_rows_tests.cpp @@ -531,10 +531,10 @@ TEST_F(ListConcatenateRowsNestedTypesTest, ListWithNulls) nulls_at({4})); // col2 - StrListsCol l2({StrListsCol::nested({{"monitor", "sugar"}}), - StrListsCol::nested({{"spurs", "garlic"}, {"onion", "shallot", "carrot"}}), - StrListsCol::nested({{"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}), - StrListsCol::nested({{}, {"ram", "cpu", "disk"}, {}}), + StrListsCol l2({{{"monitor", "sugar"}}, + {{"spurs", "garlic"}, {"onion", "shallot", "carrot"}}, + {{"cars", "trucks", "planes"}, {"abc"}, {"mno", "pqr"}}, + {{}, {"ram", "cpu", "disk"}, {}}, StrListsCol::nested({{"round"}, {"square"}})}, nulls_at({0, 4})); diff --git a/cpp/tests/lists/explode_tests.cpp b/cpp/tests/lists/explode_tests.cpp index b41104503e48..06c1626e702e 100644 --- a/cpp/tests/lists/explode_tests.cpp +++ b/cpp/tests/lists/explode_tests.cpp @@ -188,7 +188,7 @@ TEST_F(ExplodeTest, Nested) // [[5, 6]] 200 // [[0, 3],[],[5],[2, 1]] 300 - LCW a{{{1, 2}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {}, {5}, {2, 1}}}; + LCW a{{{1, 2}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {}, {5}, {2, 1}}}; FCW b{100, 200, 300}; LCW expected_a{{1, 2}, {7, 6, 5}, {5, 6}, {0, 3}, {}, {5}, {2, 1}}; @@ -220,7 +220,7 @@ TEST_F(ExplodeTest, NestedNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); auto always_valid = cudf::test::iterators::no_nulls(); - LCW a({{{1, 2}, {7, 6, 5}}, LCW::nested({{null}}), {{0, 3}, {5}, {2, 1}}}, valids); + LCW a({{{1, 2}, {7, 6, 5}}, {{null}}, {{0, 3}, {5}, {2, 1}}}, valids); FCW b({100, null, 300}, valids); LCW expected_a{{1, 2}, {7, 6, 5}, {0, 3}, {5}, {2, 1}}; @@ -251,8 +251,7 @@ TEST_F(ExplodeTest, NullsInNested) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a( - {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); + LCW a({{{{1, null}, valids}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}); FCW b({100, 200, 300}); LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; @@ -283,9 +282,7 @@ TEST_F(ExplodeTest, NullsInNestedDoubleExplode) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, - LCW::nested({{5, 6}}), - {{0, 3}, {5}, {{2, null}, valids}}}; + LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}; FCW b{100, 200, 300}; FCW expected_a({1, null, 7, 6, 5, 5, 6, 0, 3, 5, 2, null}, @@ -318,8 +315,7 @@ TEST_F(ExplodeTest, NestedStructs) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a( - {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); + LCW a({{{{1, null}, valids}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}); FCW b1({100, 200, 300}); cudf::test::strings_column_wrapper b2{"100", "200", "300"}; cudf::test::structs_column_wrapper b({b1, b2}); @@ -484,7 +480,7 @@ TEST_F(ExplodeTest, SlicedList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); LCW a({{{{1, 2}, valids}, {7, 6, 5}}, - LCW::nested({{5, 6}}), + {{5, 6}}, {{0, 3}, {5}, {{2, 1}, valids}}, {{8, 3}, {}, {{4, 3, 1, 2}, valids}}, {{2, 3, 4}, {9, 8}}}); @@ -819,7 +815,7 @@ TEST_F(ExplodeOuterTest, Nested) // [[5, 6]] 200 // [[0, 3],[],[5],[2, 1]] 300 - LCW a{{{1, 2}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {}, {5}, {2, 1}}}; + LCW a{{{1, 2}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {}, {5}, {2, 1}}}; FCW b{100, 200, 300}; LCW expected_a{{1, 2}, {7, 6, 5}, {5, 6}, {0, 3}, {}, {5}, {2, 1}}; @@ -850,7 +846,7 @@ TEST_F(ExplodeOuterTest, NestedNulls) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a({{{1, 2}, {7, 6, 5}}, LCW::nested({{null}}), {{0, 3}, {5}, {2, 1}}}, valids); + LCW a({{{1, 2}, {7, 6, 5}}, {{null}}, {{0, 3}, {5}, {2, 1}}}, valids); FCW b({100, 200, 300}); auto expected_valids = cudf::test::iterators::null_at(2); @@ -880,8 +876,7 @@ TEST_F(ExplodeOuterTest, NullsInNested) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a( - {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); + LCW a({{{{1, null}, valids}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}); FCW b({100, 200, 300}); LCW expected_a{{{1, null}, valids}, {7, 6, 5}, {5, 6}, {0, 3}, {5}, {{2, null}, valids}}; @@ -912,9 +907,7 @@ TEST_F(ExplodeOuterTest, NullsInNestedDoubleExplode) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, - LCW::nested({{5, 6}}), - {{0, 3}, {5}, {{2, null}, valids}}}; + LCW a{{{{1, null}, valids}, {}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}; FCW b{100, 200, 300}; FCW expected_a({1, null, null, 7, 6, 5, 5, 6, 0, 3, 5, 2, null}, @@ -949,8 +942,7 @@ TEST_F(ExplodeOuterTest, NestedStructs) auto valids = cudf::test::iterators::valids_at_multiples_of(2); - LCW a( - {{{{1, null}, valids}, {7, 6, 5}}, LCW::nested({{5, 6}}), {{0, 3}, {5}, {{2, null}, valids}}}); + LCW a({{{{1, null}, valids}, {7, 6, 5}}, {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}}); FCW b1({100, 200, 300}); cudf::test::strings_column_wrapper b2{"100", "200", "300"}; cudf::test::structs_column_wrapper b({b1, b2}); @@ -1117,7 +1109,7 @@ TEST_F(ExplodeOuterTest, SlicedList) auto valids = cudf::test::iterators::valids_at_multiples_of(2); LCW a({{{{1, null}, valids}, {7, 6, 5}}, - LCW::nested({{5, 6}}), + {{5, 6}}, {{0, 3}, {5}, {{2, null}, valids}}, {{8, 3}, {}, {{4, null, 1, null}, valids}}, {{2, 3, 4}, {9, 8}}}); diff --git a/cpp/tests/merge/merge_test.cpp b/cpp/tests/merge/merge_test.cpp index 60df928f86ec..a760a76cf015 100644 --- a/cpp/tests/merge/merge_test.cpp +++ b/cpp/tests/merge/merge_test.cpp @@ -875,25 +875,16 @@ TEST_F(MergeTest, Lists) TEST_F(MergeTest, NestedListsWithNulls) { - auto col1 = lcw{{lcw::nested({{1}}), lcw::nested({{3}}), lcw::nested({{5}}), lcw::nested({{7}})}, - null_at(3)}; - auto col2 = lcw{{lcw::nested({{2}}), lcw::nested({{4}}), lcw::nested({{6}}), lcw::nested({{8}})}, - null_at(3)}; + auto col1 = lcw{{{{1}}, {{3}}, {{5}}, {{7}}}, null_at(3)}; + auto col2 = lcw{{{{2}}, {{4}}, {{6}}, {{8}}}, null_at(3)}; auto tbl1 = cudf::table_view{{col1}}; auto tbl2 = cudf::table_view{{col2}}; auto result = cudf::merge({tbl1, tbl2}, {0}, {cudf::order::ASCENDING}, {cudf::null_order::AFTER}); - auto expected_col = lcw{{lcw::nested({{1}}), - lcw::nested({{2}}), - lcw::nested({{3}}), - lcw::nested({{4}}), - lcw::nested({{5}}), - lcw::nested({{6}}), - lcw::nested({{7}}), - lcw::nested({{8}})}, - nulls_at({6, 7})}; + auto expected_col = + lcw{{{{1}}, {{2}}, {{3}}, {{4}}, {{5}}, {{6}}, {{7}}, {{8}}}, nulls_at({6, 7})}; auto expected_tbl = cudf::table_view{{expected_col}}; CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected_tbl, *result); diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index c9d34d021610..fff3afb591f0 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -48,8 +48,8 @@ TEST_F(ListRankScanTest, DeepList) {{}}, {{}, {}, {}}, {{}, {}, {}}, - lcw::nested({{10}}), - lcw::nested({{10}}), + {{10}}, + {{10}}, {{13, 14}, {15}}, {{13, 14}, {16}}, {}, diff --git a/cpp/tests/reductions/reduction_tests.cpp b/cpp/tests/reductions/reduction_tests.cpp index d3926b068d2c..615fb47ebeb8 100644 --- a/cpp/tests/reductions/reduction_tests.cpp +++ b/cpp/tests/reductions/reduction_tests.cpp @@ -3280,8 +3280,7 @@ TEST_F(ListReductionTest, NestedListReductionNthElement) // test without nulls auto validity = std::vector{true, false, false, true, true}; auto nested_list = - LCW({{{}, {2, 3, 4}}, {}, {{5}, {6}, {7, 8}}, LCW::nested({{9, 10}}), {{11}, {12, 13}}}, - validity.begin()); + LCW({{{}, {2, 3, 4}}, {}, {{5}, {6}, {7, 8}}, {{9, 10}}, {{11}, {12, 13}}}, validity.begin()); this->reduction_test( nested_list, LCW{{}, {2, 3, 4}}, // expected_value, diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index 2ee8581a1df0..4df86b9d9b25 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -743,7 +743,7 @@ TYPED_TEST(Sort, WithListColumn) {{7, 8}, {}}, {{}, {}, {}}, {{}}, - lcw::nested({{10}}), + {{10}}, {}}; auto expect = cudf::test::fixed_width_column_wrapper{8, 6, 5, 3, 0, 1, 2, 4, 7}; @@ -785,7 +785,7 @@ TYPED_TEST(Sort, WithNullableListColumn) {{7, 8}, {}}, // 5 {{}, {}, {}}, // 6 {{}}, // 7 - lcw::nested({{10}}), // 8 + {{10}}, // 8 {}, // 9 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 10 {{1, 2}, {3}, {4, 5}, {{0, 7}, nulls_at({0})}}, // 11 @@ -814,8 +814,8 @@ TYPED_TEST(Sort, MoreLists) ] */ lcw col{ - {{{0}, nulls_at({0})}, {-21827}}, // 0 - lcw::nested({{{0, 0}, nulls_at({0, 1})}}) // 1 + {{{0}, nulls_at({0})}, {-21827}}, // 0 + {{{0, 0}, nulls_at({0, 1})}} // 1 }; cudf::test::fixed_width_column_wrapper expected{{0, 1}}; auto result = cudf::sorted_order(cudf::table_view({col})); @@ -925,7 +925,7 @@ TYPED_TEST(Sort, WithSlicedListColumn) {{7, 8}, {}}, // 4 {{}, {}, {}}, // 5 {{}}, // 6 - lcw::nested({{10}}), // 7 + {{10}}, // 7 {}, // 8 {{1, 2}, {3}, {4, 5}, {{0, 6, 0}, nulls_at({0, 2})}}, // 9 {{1, 2}, {3}, {4, 5}, {{0, 7}, nulls_at({0})}}, // diff --git a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp index ff793fb055ac..0bf20eafb6e7 100644 --- a/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/lists_column_wrapper_tests.cpp @@ -1030,7 +1030,7 @@ TYPED_TEST(ListColumnWrapperTestTyped, IncompleteHierarchies) { // { {null}, {{}}, {} } std::vector valids{false}; - LCW list{LCW::nested({{{}}}, valids.begin()), {{}}, {}}; + LCW list{{{{{}}}, valids.begin()}, {{}}, {}}; cudf::lists_column_view lcv(list); EXPECT_EQ(lcv.size(), 3); diff --git a/cpp/tests/utilities_tests/type_check_tests.cpp b/cpp/tests/utilities_tests/type_check_tests.cpp index ad0d717d0520..f8b3f9e0635e 100644 --- a/cpp/tests/utilities_tests/type_check_tests.cpp +++ b/cpp/tests/utilities_tests/type_check_tests.cpp @@ -47,10 +47,10 @@ TEST_F(ColumnTypeCheckTest, SameList) LCW lhs2{{1, 2, 3}}, rhs2{{4, 5}}; EXPECT_TRUE(cudf::have_same_types(lhs2, rhs2)); - LCW lhs3{{{1}, {2, 3}}}, rhs3{LCW::nested({{4, 5}})}; + LCW lhs3{{{1}, {2, 3}}}, rhs3{{{4, 5}}}; EXPECT_TRUE(cudf::have_same_types(lhs3, rhs3)); - LCW lhs4{{{1}, {}, {2, 3}}}, rhs4{LCW::nested({{4, 5}, {}})}; + LCW lhs4{{{1}, {}, {2, 3}}}, rhs4{{{4, 5}, {}}}; EXPECT_TRUE(cudf::have_same_types(lhs4, rhs4)); } @@ -74,7 +74,7 @@ TEST_F(ColumnTypeCheckTest, SameStruct) FCW lf1{1, 2, 3}, rf1{0, 1}; StringCW lf2{"a", "bb", ""}, rf2{"cc", "d"}; - LCW lf3({{1, 2}, {}, {4}}), rf3(LCW::nested({{1}, {2}})); + LCW lf3({{1, 2}, {}, {4}}), rf3({{1}, {2}}); DCW lf4{5, 5, 5}, rf4{9, 9}; SCW lhs{lf1, lf2, lf3, lf4}, rhs{rf1, rf2, rf3, rf4}; @@ -168,7 +168,7 @@ TEST_F(ColumnTypeCheckTest, DifferentLists) // Different nested level LCW_i lhs1{{1, 1, 2, 3}, {}, {42, 42}}; - LCW_i rhs1{{{8, 8, 8}, {9, 9}}, LCW_i::nested({{42, 42}})}; + LCW_i rhs1{{{8, 8, 8}, {9, 9}}, {{42, 42}}}; EXPECT_FALSE(cudf::have_same_types(lhs1, rhs1));