-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-39419: [C++][Parquet] Style: Using arrow::Buffer data_as api rather than reinterpret_cast #39420
Conversation
|
@github-actions crossbow submit -g cpp |
Revision: f769b1c Submitted crossbow builds: ursacomputing/crossbow @ actions-53d0242ebe |
cc @felipecrv would you mind take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@@ -2007,7 +2001,7 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl<ByteArrayType>, | |||
// space for binary data. | |||
RETURN_NOT_OK(helper.Prepare()); | |||
|
|||
auto dict_values = reinterpret_cast<const ByteArray*>(dictionary_->data()); | |||
const auto* dict_values = dictionary_->data_as<ByteArray>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to specify const
and *
explicitly here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, const auto* v = ...
is equal to auto dict_values = ..
. It's just a style problem
Let me update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like auto*
because it communicates the assignment is just a pointer assignment and not some expensive copy/move operation. And it's creates a good symmetry with auto&
that requires the &
otherwise it becomes a copy.
Updated: I just change Will wait some days to see if other like this style, glad to change it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Including the const auto*
and all.
Will merge it before Friday if no negative comments |
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 01deb94. There were 4 benchmark results indicating a performance regression:
The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them. |
… rather than reinterpret_cast (apache#39420) ### Rationale for this change This patch using `{mutable}_data_as<T>()` api to replace `interpret_cast<{const} T*>`. It's just a style fixing. ### What changes are included in this PR? Just api replacement for `::arrow::Buffer` * `reinterpret_cast<T*>` -> `mutable_data_as<T>()` * `reinterpret_cast<const T*>` -> `data_as<T>()` Also, for `auto {variable_name} = reinterpret_cast<{mutable} T*>( ... )`, I changed it to: 1. `const auto*` for `data_as<T>()`. 2. `auto*` for `mutable_data_as<T>()` This didn't change the syntax, but make it more readable. ### Are these changes tested? No need ### Are there any user-facing changes? no * Closes: apache#39419 * Authored-by: mwish <[email protected]> Signed-off-by: mwish <[email protected]>
… rather than reinterpret_cast (apache#39420) ### Rationale for this change This patch using `{mutable}_data_as<T>()` api to replace `interpret_cast<{const} T*>`. It's just a style fixing. ### What changes are included in this PR? Just api replacement for `::arrow::Buffer` * `reinterpret_cast<T*>` -> `mutable_data_as<T>()` * `reinterpret_cast<const T*>` -> `data_as<T>()` Also, for `auto {variable_name} = reinterpret_cast<{mutable} T*>( ... )`, I changed it to: 1. `const auto*` for `data_as<T>()`. 2. `auto*` for `mutable_data_as<T>()` This didn't change the syntax, but make it more readable. ### Are these changes tested? No need ### Are there any user-facing changes? no * Closes: apache#39419 * Authored-by: mwish <[email protected]> Signed-off-by: mwish <[email protected]>
… rather than reinterpret_cast (apache#39420) ### Rationale for this change This patch using `{mutable}_data_as<T>()` api to replace `interpret_cast<{const} T*>`. It's just a style fixing. ### What changes are included in this PR? Just api replacement for `::arrow::Buffer` * `reinterpret_cast<T*>` -> `mutable_data_as<T>()` * `reinterpret_cast<const T*>` -> `data_as<T>()` Also, for `auto {variable_name} = reinterpret_cast<{mutable} T*>( ... )`, I changed it to: 1. `const auto*` for `data_as<T>()`. 2. `auto*` for `mutable_data_as<T>()` This didn't change the syntax, but make it more readable. ### Are these changes tested? No need ### Are there any user-facing changes? no * Closes: apache#39419 * Authored-by: mwish <[email protected]> Signed-off-by: mwish <[email protected]>
Rationale for this change
This patch using
{mutable}_data_as<T>()
api to replaceinterpret_cast<{const} T*>
. It's just a style fixing.What changes are included in this PR?
Just api replacement for
::arrow::Buffer
reinterpret_cast<T*>
->mutable_data_as<T>()
reinterpret_cast<const T*>
->data_as<T>()
Also, for
auto {variable_name} = reinterpret_cast<{mutable} T*>( ... )
, I changed it to:const auto*
fordata_as<T>()
.auto*
formutable_data_as<T>()
This didn't change the syntax, but make it more readable.
Are these changes tested?
No need
Are there any user-facing changes?
no