You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/11/11 18:33:31 UTC

[GitHub] [arrow] pitrou opened a new pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

pitrou opened a new pull request #8642:
URL: https://github.com/apache/arrow/pull/8642


   Implement all flavours of binary-to-binary casting, except for fixed-size binary.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #8642:
URL: https://github.com/apache/arrow/pull/8642#discussion_r521577222



##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_string.cc
##########
@@ -92,12 +93,74 @@ struct Utf8Validator {
 };
 
 template <typename I, typename O>
-struct BinaryToStringSameWidthCastFunctor {
+constexpr bool has_smaller_width() {
+  return sizeof(typename I::offset_type) < sizeof(typename O::offset_type);
+}
+
+template <typename I, typename O>
+constexpr bool has_same_width() {
+  return sizeof(typename I::offset_type) == sizeof(typename O::offset_type);
+}
+
+// Cast same-width offsets (no-op)
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_same_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {}
+
+// Upcast offsets
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {

Review comment:
       ```suggestion
   template <typename I, typename O>
   void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>() || has_smaller_width<O, I>(), KernelContext*> ctx,
                                  const ArrayData& input, ArrayData* output) {
     if (has_smaller_width<I, O>()) {
       //
     } else {
       //
     }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz commented on a change in pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
bkietz commented on a change in pull request #8642:
URL: https://github.com/apache/arrow/pull/8642#discussion_r521583351



##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_string.cc
##########
@@ -92,12 +93,74 @@ struct Utf8Validator {
 };
 
 template <typename I, typename O>
-struct BinaryToStringSameWidthCastFunctor {
+constexpr bool has_smaller_width() {
+  return sizeof(typename I::offset_type) < sizeof(typename O::offset_type);
+}
+
+template <typename I, typename O>
+constexpr bool has_same_width() {
+  return sizeof(typename I::offset_type) == sizeof(typename O::offset_type);
+}
+
+// Cast same-width offsets (no-op)
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_same_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {}
+
+// Upcast offsets
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {

Review comment:
       If constexpr can be emulated using `std::conditional<has_smaller_width<I, O>(), NarrowerImpl, WiderImpl>::template Exec<I, O>(ctx, input, output)`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on a change in pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8642:
URL: https://github.com/apache/arrow/pull/8642#discussion_r521584030



##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_string.cc
##########
@@ -92,12 +93,74 @@ struct Utf8Validator {
 };
 
 template <typename I, typename O>
-struct BinaryToStringSameWidthCastFunctor {
+constexpr bool has_smaller_width() {
+  return sizeof(typename I::offset_type) < sizeof(typename O::offset_type);
+}
+
+template <typename I, typename O>
+constexpr bool has_same_width() {
+  return sizeof(typename I::offset_type) == sizeof(typename O::offset_type);
+}
+
+// Cast same-width offsets (no-op)
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_same_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {}
+
+// Upcast offsets
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {

Review comment:
       Horror.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on a change in pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8642:
URL: https://github.com/apache/arrow/pull/8642#discussion_r521577628



##########
File path: cpp/src/arrow/compute/kernels/scalar_cast_string.cc
##########
@@ -92,12 +93,74 @@ struct Utf8Validator {
 };
 
 template <typename I, typename O>
-struct BinaryToStringSameWidthCastFunctor {
+constexpr bool has_smaller_width() {
+  return sizeof(typename I::offset_type) < sizeof(typename O::offset_type);
+}
+
+template <typename I, typename O>
+constexpr bool has_same_width() {
+  return sizeof(typename I::offset_type) == sizeof(typename O::offset_type);
+}
+
+// Cast same-width offsets (no-op)
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_same_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {}
+
+// Upcast offsets
+template <typename I, typename O>
+void CastBinaryToBinaryOffsets(enable_if_t<has_smaller_width<I, O>(), KernelContext*> ctx,
+                               const ArrayData& input, ArrayData* output) {

Review comment:
       Lack of `constexpr if` risks producing compile errors.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] bkietz closed pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
bkietz closed pull request #8642:
URL: https://github.com/apache/arrow/pull/8642


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #8642: ARROW-6071: [C++] Generic binary-to-binary casts

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8642:
URL: https://github.com/apache/arrow/pull/8642#issuecomment-725595691


   https://issues.apache.org/jira/browse/ARROW-6071


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org