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 2021/12/30 10:48:14 UTC

[GitHub] [arrow] edponce opened a new pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

edponce opened a new pull request #12052:
URL: https://github.com/apache/arrow/pull/12052


   Reduces the number of bitwise classes/structs used in util/bit_block_counter.h by removing the bool specialization because C++ guarantees `(bool)(a & b) == (a && b)` for bool types. A bool specialization is added for bitwise negation because `~(bool)(a)` will always return true, so need to explicitly use `!a`.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] pitrou commented on a change in pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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



##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -48,43 +48,33 @@ inline uint64_t ShiftWord(uint64_t current, uint64_t next, int64_t shift) {
 // These templates are here to help with unit tests
 
 template <typename T>
-struct BitBlockAnd {
-  static T Call(T left, T right) { return left & right; }
-};
+inline T BitNot(T x) {
+  return ~x;
+}
 
 template <>
-struct BitBlockAnd<bool> {
-  static bool Call(bool left, bool right) { return left && right; }
-};
+inline bool BitNot(bool x) {
+  return !x;
+}
 
 template <typename T>
-struct BitBlockAndNot {
-  static T Call(T left, T right) { return left & ~right; }
+struct BitBlockAnd {

Review comment:
       I see, thanks.




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] pitrou commented on a change in pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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



##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -48,43 +48,33 @@ inline uint64_t ShiftWord(uint64_t current, uint64_t next, int64_t shift) {
 // These templates are here to help with unit tests
 
 template <typename T>
-struct BitBlockAnd {
-  static T Call(T left, T right) { return left & right; }
-};
+inline T BitNot(T x) {
+  return ~x;
+}
 
 template <>
-struct BitBlockAnd<bool> {
-  static bool Call(bool left, bool right) { return left && right; }
-};
+inline bool BitNot(bool x) {
+  return !x;
+}
 
 template <typename T>
-struct BitBlockAndNot {
-  static T Call(T left, T right) { return left & ~right; }
+struct BitBlockAnd {

Review comment:
       Since we're using a plain function for `BitNot`, can we do the same for this one too (and the other functors)?




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] github-actions[bot] commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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


   Revision: d4c3286fc95a0b3ea92264354ef7480b98020e3c
   
   Submitted crossbow builds: [ursacomputing/crossbow @ actions-1355](https://github.com/ursacomputing/crossbow/branches/all?query=actions-1355)
   
   |Task|Status|
   |----|------|
   |debian-bullseye-amd64|[![Github Actions](https://github.com/ursacomputing/crossbow/workflows/Crossbow/badge.svg?branch=actions-1355-github-debian-bullseye-amd64)](https://github.com/ursacomputing/crossbow/actions?query=branch:actions-1355-github-debian-bullseye-amd64)|


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] edponce commented on a change in pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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



##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -48,43 +48,33 @@ inline uint64_t ShiftWord(uint64_t current, uint64_t next, int64_t shift) {
 // These templates are here to help with unit tests
 
 template <typename T>
-struct BitBlockAnd {
-  static T Call(T left, T right) { return left & right; }
-};
+inline T BitNot(T x) {
+  return ~x;
+}
 
 template <>
-struct BitBlockAnd<bool> {
-  static bool Call(bool left, bool right) { return left && right; }
-};
+inline bool BitNot(bool x) {
+  return !x;
+}
 
 template <typename T>
-struct BitBlockAndNot {
-  static T Call(T left, T right) { return left & ~right; }
+struct BitBlockAnd {

Review comment:
       `BitNot` was not an existing operator, I added it because negation is the only bitwise operation where C++ behaves different between bool and integral types, so I specialized it as a helper function.
   `~(bool)x` always returns true.




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] kou commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
kou commented on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003459624


   @github-actions crossbow submit debian-bullseye-amd64


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] ursabot edited a comment on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003172542


   Benchmark runs are scheduled for baseline = f1f291f7ca291b2b991b58be3c0e33434bb3cc69 and contender = b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5. b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/8d36854fdb60447aa8db40cedb643322...4990c04dfe9144d5a9dccf6fbedffe0a/)
   [Failed :arrow_down:0.45% :arrow_up:0.0%] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/c88ec59a28874d7ba157ab265ad1f01a...db14c01084d3406d9cc23940b47b8340/)
   [Failed] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/e59971c0b4d54615b18b1db615ac9445...f3741610897143de8083893b1431cd35/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] ursabot commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
ursabot commented on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003172542


   Benchmark runs are scheduled for baseline = f1f291f7ca291b2b991b58be3c0e33434bb3cc69 and contender = b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5. b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Scheduled] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/8d36854fdb60447aa8db40cedb643322...4990c04dfe9144d5a9dccf6fbedffe0a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/c88ec59a28874d7ba157ab265ad1f01a...db14c01084d3406d9cc23940b47b8340/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/e59971c0b4d54615b18b1db615ac9445...f3741610897143de8083893b1431cd35/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] ursabot edited a comment on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003172542


   Benchmark runs are scheduled for baseline = f1f291f7ca291b2b991b58be3c0e33434bb3cc69 and contender = b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5. b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/8d36854fdb60447aa8db40cedb643322...4990c04dfe9144d5a9dccf6fbedffe0a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/c88ec59a28874d7ba157ab265ad1f01a...db14c01084d3406d9cc23940b47b8340/)
   [Failed] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/e59971c0b4d54615b18b1db615ac9445...f3741610897143de8083893b1431cd35/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] github-actions[bot] commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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






-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] edponce commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
edponce commented on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003146968


   The driver for this PR was the[ large number of operators defined in the `between` PR.](https://github.com/apache/arrow/pull/11882/files#diff-fd2cb2745dc0cc2a84f7cd46cba410ef26f48abaf80e0fe3cc6c8657ab42a743R101-R230)


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] pitrou commented on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003147722


   Now you need to fix CI issues :-)


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] edponce commented on a change in pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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



##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -48,43 +48,33 @@ inline uint64_t ShiftWord(uint64_t current, uint64_t next, int64_t shift) {
 // These templates are here to help with unit tests
 
 template <typename T>
-struct BitBlockAnd {
-  static T Call(T left, T right) { return left & right; }
-};
+inline T BitNot(T x) {
+  return ~x;
+}
 
 template <>
-struct BitBlockAnd<bool> {
-  static bool Call(bool left, bool right) { return left && right; }
-};
+inline bool BitNot(bool x) {
+  return !x;
+}
 
 template <typename T>
-struct BitBlockAndNot {
-  static T Call(T left, T right) { return left & ~right; }
+struct BitBlockAnd {

Review comment:
       Can't change the `BitBlockXXX` into functions because these are passed [template parameters (Operators)](https://github.com/apache/arrow/blob/master/cpp/src/arrow/util/bit_block_counter.h#L289) and the [templetized function invokes `Op::Call(...)`](https://github.com/apache/arrow/blob/master/cpp/src/arrow/util/bit_block_counter.h#L308).




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] edponce commented on a change in pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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



##########
File path: cpp/src/arrow/util/bit_block_counter.h
##########
@@ -48,43 +48,33 @@ inline uint64_t ShiftWord(uint64_t current, uint64_t next, int64_t shift) {
 // These templates are here to help with unit tests
 
 template <typename T>
-struct BitBlockAnd {
-  static T Call(T left, T right) { return left & right; }
-};
+inline T BitNot(T x) {
+  return ~x;
+}
 
 template <>
-struct BitBlockAnd<bool> {
-  static bool Call(bool left, bool right) { return left && right; }
-};
+inline bool BitNot(bool x) {
+  return !x;
+}
 
 template <typename T>
-struct BitBlockAndNot {
-  static T Call(T left, T right) { return left & ~right; }
+struct BitBlockAnd {

Review comment:
       `BitNot` was not an existing operator, I added it because negation is the only bitwise operation where C++ behaves different between bool and integral types, so I specialized it as a helper function.
   `~(bool)x != !(bool)x`, the former always returns true.




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] pitrou closed pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

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


   


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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



[GitHub] [arrow] ursabot edited a comment on pull request #12052: ARROW-15220: [C++] Remove bool specializations of bit block counter operations

Posted by GitBox <gi...@apache.org>.
ursabot edited a comment on pull request #12052:
URL: https://github.com/apache/arrow/pull/12052#issuecomment-1003172542


   Benchmark runs are scheduled for baseline = f1f291f7ca291b2b991b58be3c0e33434bb3cc69 and contender = b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5. b719baa0c2ac09bebc4fc45d16e2a18598fc2ef5 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Finished :arrow_down:0.0% :arrow_up:0.0%] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/8d36854fdb60447aa8db40cedb643322...4990c04dfe9144d5a9dccf6fbedffe0a/)
   [Scheduled] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/c88ec59a28874d7ba157ab265ad1f01a...db14c01084d3406d9cc23940b47b8340/)
   [Scheduled] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/e59971c0b4d54615b18b1db615ac9445...f3741610897143de8083893b1431cd35/)
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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