Skip to content

Commit

Permalink
Fix depth comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
ttnghia committed Mar 24, 2023
1 parent 422f93c commit 70abc3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cpp/include/cudf/table/experimental/row_operators.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class device_row_comparator {
}

if (lcol.num_child_columns() == 0) {
return cuda::std::pair(weak_ordering::EQUIVALENT, depth);
return cuda::std::pair(weak_ordering::EQUIVALENT, std::numeric_limits<int>::max());
}

// Non-empty structs have been modified to only have 1 child when using this.
Expand Down
5 changes: 1 addition & 4 deletions cpp/src/table/row_operators.cu
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,9 @@ auto decompose_structs(table_view table,
// lists column.
// In such cases, the last column of the current branch will be `Struct<List,...>` and
// it will be modified to empty struct type `Struct<>` later on.
// In addition, the new cut out branch will be set to have the same depth as the
// current branch instead of higher depth. By this way, we can avoid the new branch
// to be ignored in `device_row_comparator` when the current branch has zero child.
if (child_idx > 0 ||
(child_idx == 0 && c->children[0]->type().id() == type_id::LIST)) {
verticalized_col_depths.push_back(child_idx == 0 ? depth : depth + 1);
verticalized_col_depths.push_back(depth + 1);
branch = &flattened.emplace_back();
}
recursive_child(c->children[child_idx].get(), branch, depth + 1);
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/sort/sort_nested_types_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_F(NestedStructTest, StructsHaveListsNoNulls)
}

{
auto const expected_order = int32s_col{2, 0, 3, 4, 1, 5, 6};
auto const expected_order = int32s_col{2, 0, 3, 4, 6, 5, 1};
auto const order =
cudf::stable_sorted_order(cudf::table_view{{input}}, {cudf::order::DESCENDING});
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_order, order->view());
Expand All @@ -115,7 +115,7 @@ TEST_F(NestedStructTest, StructsHaveListsWithNulls)
}

{
auto const expected_order = int32s_col{3, 0, 4, 5, 1, 6, 7, 2};
auto const expected_order = int32s_col{3, 0, 4, 5, 7, 6, 1, 2};
auto const order =
cudf::stable_sorted_order(cudf::table_view{{input}}, {cudf::order::DESCENDING});
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_order, order->view());
Expand Down

0 comments on commit 70abc3c

Please sign in to comment.