Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid use of std::exclusive_scan in Parquet writer #13434

Merged
merged 6 commits into from
May 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp/src/io/parquet/writer_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1710,10 +1710,10 @@ auto convert_table_to_parquet_data(table_input_metadata& table_meta,
size_type const total_frags = [&]() {
if (frags_per_column.size() > 0) {
std::exclusive_scan(frags_per_column.data(),
frags_per_column.data() + num_columns + 1,
frags_per_column.data() + num_columns,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use frags_per_column.begin(), frags_per_column.end().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please avoid back_inserter if possible. So this should be better:

std::vector<size_type> frag_offsets(num_columns, 0);
...
std::exclusive_scan(frags_per_column.begin(), frags_per_column.end(), frag_offsets.begin(), 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much cleaner. thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, the canonical way is to reserve the final size and use back_inserter, so we never reallocate and never default-initialize elements. It is unfortunatelly also the most verbose option 🤷‍♂️
Not a request to apply this here, just an FYI (or maybe a FMI, if @ttnghia knows of a back_inserter drawback).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that. I wouldn't mind changing to that just so it's in my muscle memory :)

std::back_inserter(frag_offsets),
0);
return frag_offsets[num_columns];
return frag_offsets[num_columns - 1] + frags_per_column[num_columns - 1];
etseidl marked this conversation as resolved.
Show resolved Hide resolved
} else {
return 0;
}
Expand Down