From c9110190abf400fe5710eec10dc1ac602299350e Mon Sep 17 00:00:00 2001 From: MithunR Date: Wed, 4 May 2022 13:46:39 -0700 Subject: [PATCH] List test, with null rows and slicing. --- cpp/tests/lists/apply_boolean_mask_test.cpp | 43 ++++++++++++--------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/cpp/tests/lists/apply_boolean_mask_test.cpp b/cpp/tests/lists/apply_boolean_mask_test.cpp index 9450614dc11..a5b036210ba 100644 --- a/cpp/tests/lists/apply_boolean_mask_test.cpp +++ b/cpp/tests/lists/apply_boolean_mask_test.cpp @@ -149,29 +149,34 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, StructInput) using T = TypeParam; using fwcw = fwcw; - auto const input = [] { - auto child_num = fwcw{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto child_str = strings{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; - return cudf::make_lists_column(7, + auto constexpr num_input_rows = 7; + auto const input = [] { + auto child_num = fwcw{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + auto child_str = strings{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; + auto const null_mask_begin = null_at(5); + auto const null_mask_end = null_mask_begin + num_input_rows; + return cudf::make_lists_column(num_input_rows, offsets{0, 2, 3, 6, 6, 8, 8, 10}.release(), structs_column_wrapper{{child_num, child_str}}.release(), - 0, - {}); + 1, + detail::make_null_mask(null_mask_begin, null_mask_end)); }(); { // Unsliced. // The input should now look as follows: (String child dropped for brevity.) - // Input: { [0,1], [2], [3,4,5], [], [6,7], [], [8,9] } + // Input: {[0, 1], [2], [3, 4, 5], [], [6, 7], [], [8, 9]} auto const filter = filter_t{{1, 1}, {0}, {0, 1, 0}, {}, {1, 0}, {}, {0, 1}}; auto const result = apply_boolean_mask(lists_column_view{*input}, lists_column_view{filter}); auto const expected = [] { - auto child_num = fwcw{0, 1, 4, 6, 9}; - auto child_str = strings{"0", "1", "4", "6", "9"}; - return cudf::make_lists_column(7, + auto child_num = fwcw{0, 1, 4, 6, 9}; + auto child_str = strings{"0", "1", "4", "6", "9"}; + auto const null_mask_begin = null_at(5); + auto const null_mask_end = null_mask_begin + num_input_rows; + return cudf::make_lists_column(num_input_rows, offsets{0, 2, 2, 3, 3, 4, 4, 5}.release(), structs_column_wrapper{{child_num, child_str}}.release(), - 0, - {}); + 1, + detail::make_null_mask(null_mask_begin, null_mask_end)); }(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, *expected); } @@ -179,18 +184,20 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, StructInput) // Sliced. Remove the first row. auto const sliced_input = cudf::slice(*input, {1, input->size()}).front(); // The input should now look as follows: (String child dropped for brevity.) - // Input: { [2], [3,4,5], [], [6,7], [], [8,9] } + // Input: {[2], [3, 4, 5], [], [6, 7], [], [8, 9]} auto const filter = filter_t{{0}, {0, 1, 0}, {}, {1, 0}, {}, {0, 1}}; auto const result = apply_boolean_mask(lists_column_view{sliced_input}, lists_column_view{filter}); auto const expected = [] { - auto child_num = fwcw{4, 6, 9}; - auto child_str = strings{"4", "6", "9"}; - return cudf::make_lists_column(6, + auto child_num = fwcw{4, 6, 9}; + auto child_str = strings{"4", "6", "9"}; + auto const null_mask_begin = null_at(4); + auto const null_mask_end = null_mask_begin + num_input_rows; + return cudf::make_lists_column(num_input_rows - 1, offsets{0, 0, 1, 1, 2, 2, 3}.release(), structs_column_wrapper{{child_num, child_str}}.release(), - 0, - {}); + 1, + detail::make_null_mask(null_mask_begin, null_mask_end)); }(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, *expected); }