You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/24 20:43:58 UTC

[GitHub] [beam] Imfuyuwei commented on a change in pull request #12079: [BEAM-9890] Support BIT_AND aggregation function in Beam SQL

Imfuyuwei commented on a change in pull request #12079:
URL: https://github.com/apache/beam/pull/12079#discussion_r445160365



##########
File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -383,4 +392,30 @@ public Long extractOutput(Long accum) {
       return accum;
     }
   }
+
+  static class BitAnd<T extends Number> extends CombineFn<T, Long, Long> {
+    @Override
+    public Long createAccumulator() {
+      return -1L;

Review comment:
       Because -1L is represented as 64 bits of 1 in binary while 1L only has one 1 at the least significant bit. 
   
   In order to do bit_and operation, I think the initial bit mask should consists of only 1s, so I use -1L.




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