ibzib commented on a change in pull request #13745:
URL: https://github.com/apache/beam/pull/13745#discussion_r556773137
##########
File path:
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java
##########
@@ -397,40 +397,54 @@ public Long extractOutput(Long accum) {
* <p>Note: null values are ignored when mixed with non-null values.
* (https://issues.apache.org/jira/browse/BEAM-10379)
*/
- static class BitAnd<T extends Number> extends CombineFn<T, Long, Long> {
- // Indicate if input only contains null value.
- private boolean isEmpty = true;
+ static class BitAnd<T extends Number> extends CombineFn<T, BitAnd.Accum,
Long> {
+ static class Accum {
+ /** True if no inputs have been seen yet. */
+ boolean isEmpty = true;
+ /** True if any null inputs have been seen. */
+ boolean isNull = false;
+ /** The bitwise-and of the inputs seen so far. */
+ long bitAnd = -1L;
+ }
@Override
- public Long createAccumulator() {
- return -1L;
+ public Accum createAccumulator() {
+ return new Accum();
}
@Override
- public Long addInput(Long accum, T input) {
- if (input != null) {
- this.isEmpty = false;
- return accum & input.longValue();
- } else {
- return null;
+ public Accum addInput(Accum accum, T input) {
+ if (input == null) {
Review comment:
It's not strictly necessary, but I added it for clarity.
----------------------------------------------------------------
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:
[email protected]