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
ARROW-9402: [C++] Rework portable wrappers for checked integer arithmetic #7784
Conversation
8e57e8c
to
478f663
Compare
4b145a6
to
1b646ee
Compare
I think I finally squashed the horrid Windows preprocessor macro issues (Windows headers define OPTIONAL, but you can't undef it blindly because other subsequent includes may require it...). |
@wesm You'll probably want to take a look at the codegen changes when you have some time. |
0ac10bb
to
7d5b6e3
Compare
Rebased. @wesm could you perhaps review this? |
Or perhaps @bkietz . |
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.
Some minor comments, this mostly looks good to me
template <typename T, typename Arg0, typename Arg1> | ||
enable_if_floating_point<T> Call(KernelContext*, Arg0 left, Arg1 right) { | ||
static_assert(std::is_same<T, Arg0>::value && std::is_same<T, Arg1>::value, ""); |
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.
What happens if we remove those template arguments?
template <typename T, typename Arg0, typename Arg1> | |
enable_if_floating_point<T> Call(KernelContext*, Arg0 left, Arg1 right) { | |
static_assert(std::is_same<T, Arg0>::value && std::is_same<T, Arg1>::value, ""); | |
template <typename T> | |
enable_if_floating_point<T> Call(KernelContext*, T left, T right) { |
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.
It doesn't compile, because Call
is invoked with explicit template arguments by the kernel execution machinery.
@@ -103,6 +103,16 @@ void CheckScalarUnary(std::string func_name, std::shared_ptr<Scalar> input, | |||
std::shared_ptr<Scalar> expected, | |||
const FunctionOptions* options = nullptr); | |||
|
|||
void CheckScalarBinary(std::string func_name, std::shared_ptr<Scalar> left_input, |
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.
👍
@@ -55,6 +55,8 @@ | |||
#include "parquet/schema.h" | |||
#include "parquet/statistics.h" | |||
#include "parquet/types.h" | |||
// Required after "arrow/util/int_util_internal.h" (for OPTIONAL) |
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.
// Required after "arrow/util/int_util_internal.h" (for OPTIONAL) | |
// Required after "arrow/util/int_util_internal.h" (for OPTIONAL) |
I'm not sure if clang-format will always recognize this comment as breaking this #include out of the above block. I suppose it's alphabetically always going to be lower in the sort, though
…etic Vendor relevant code from the portable-snippets library (~ public domain): https://github.com/nemequ/portable-snippets/tree/master/safe-math Also fix some bugs in checked arithmetic (null values had their value slots checked as well), add compute scaffolding for stateful binary scalar functions.
7d5b6e3
to
75afb88
Compare
I believe I addressed your comments @bkietz , so I'm going to merge now. |
…etic Vendor relevant code from the portable-snippets library (~ public domain): https://github.com/nemequ/portable-snippets/tree/master/safe-math Also fix some bugs in checked arithmetic (null values had their value slots checked). Add compute scaffolding for stateful binary scalar functions. Closes apache#7784 from pitrou/ARROW-9402-overflow-arith Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
…etic Vendor relevant code from the portable-snippets library (~ public domain): https://github.com/nemequ/portable-snippets/tree/master/safe-math Also fix some bugs in checked arithmetic (null values had their value slots checked). Add compute scaffolding for stateful binary scalar functions. Closes apache#7784 from pitrou/ARROW-9402-overflow-arith Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
…etic Vendor relevant code from the portable-snippets library (~ public domain): https://github.com/nemequ/portable-snippets/tree/master/safe-math Also fix some bugs in checked arithmetic (null values had their value slots checked). Add compute scaffolding for stateful binary scalar functions. Closes apache#7784 from pitrou/ARROW-9402-overflow-arith Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
…etic Vendor relevant code from the portable-snippets library (~ public domain): https://github.com/nemequ/portable-snippets/tree/master/safe-math Also fix some bugs in checked arithmetic (null values had their value slots checked). Add compute scaffolding for stateful binary scalar functions. Closes apache#7784 from pitrou/ARROW-9402-overflow-arith Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
Vendor relevant code from the portable-snippets library (~ public domain):
https://github.com/nemequ/portable-snippets/tree/master/safe-math
Also fix some bugs in checked arithmetic (null values had their value slots checked).
Add compute scaffolding for stateful binary scalar functions.