Skip to content

Commit

Permalink
List<struct> test, with null rows and slicing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mythrocks committed May 4, 2022
1 parent b996471 commit c911019
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions cpp/tests/lists/apply_boolean_mask_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,48 +149,55 @@ TYPED_TEST(ApplyBooleanMaskTypedTest, StructInput)
using T = TypeParam;
using fwcw = fwcw<T>;

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);
}
{
// 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);
}
Expand Down

0 comments on commit c911019

Please sign in to comment.