Skip to content

Commit

Permalink
Minor code refactor for sorted_order (#8326)
Browse files Browse the repository at this point in the history
the fast-path for single column sort will not use any sorted_indices, this PR just move the sorted_indices behind the single column sort code block

Authors:
  - Bobby Wang (https://github.com/wbo4958)

Approvers:
  - Mark Harris (https://github.com/harrism)
  - Nghia Truong (https://github.com/ttnghia)

URL: #8326
  • Loading branch information
wbo4958 authored Jun 3, 2021
1 parent c2ec012 commit f24c6b4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cpp/src/sort/sort_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ std::unique_ptr<column> sorted_order(table_view input,
"Mismatch between number of columns and null_precedence size.");
}

std::unique_ptr<column> sorted_indices = cudf::make_numeric_column(
data_type(type_to_id<size_type>()), input.num_rows(), mask_state::UNALLOCATED, stream, mr);
mutable_column_view mutable_indices_view = sorted_indices->mutable_view();
thrust::sequence(rmm::exec_policy(stream),
mutable_indices_view.begin<size_type>(),
mutable_indices_view.end<size_type>(),
0);

// fast-path for single column sort
if (input.num_columns() == 1 and not cudf::is_nested(input.column(0).type())) {
auto const single_col = input.column(0);
Expand All @@ -124,6 +116,14 @@ std::unique_ptr<column> sorted_order(table_view input,
: sorted_order<false>(single_col, col_order, null_prec, stream, mr);
}

std::unique_ptr<column> sorted_indices = cudf::make_numeric_column(
data_type(type_to_id<size_type>()), input.num_rows(), mask_state::UNALLOCATED, stream, mr);
mutable_column_view mutable_indices_view = sorted_indices->mutable_view();
thrust::sequence(rmm::exec_policy(stream),
mutable_indices_view.begin<size_type>(),
mutable_indices_view.end<size_type>(),
0);

auto flattened = structs::detail::flatten_nested_columns(input, column_order, null_precedence);
auto& input_flattened = std::get<0>(flattened);
auto device_table = table_device_view::create(input_flattened, stream);
Expand Down

0 comments on commit f24c6b4

Please sign in to comment.