gemini-code-assist[bot] commented on code in PR #37851:
URL: https://github.com/apache/beam/pull/37851#discussion_r2966346843


##########
runners/core-java/src/main/java/org/apache/beam/runners/core/SimpleDoFnRunner.java:
##########
@@ -1286,6 +1310,18 @@ public <T> void outputWindowedValue(
           .output();
     }
 
+    @Override
+    public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
+      checkTimestamp(this.timestamp, windowedValue.getTimestamp());
+      SimpleDoFnRunner.this.outputWindowedValue(mainOutputTag, windowedValue);
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's code duplication between this method and the generic 
`outputWindowedValue` method that follows. You can avoid this by refactoring 
this method to call the generic version with `mainOutputTag`.
   
   ```java
       public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
         outputWindowedValue(mainOutputTag, windowedValue);
       }
   ```



##########
runners/core-java/src/main/java/org/apache/beam/runners/core/OutputAndTimeBoundedSplittableProcessElementInvoker.java:
##########
@@ -477,6 +477,26 @@ public <T> void outputWindowedValue(
               element.causedByDrain()));
     }
 
+    @Override
+    public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
+      noteOutput();
+      if (watermarkEstimator instanceof TimestampObservingWatermarkEstimator) {
+        ((TimestampObservingWatermarkEstimator) watermarkEstimator)
+            .observeTimestamp(windowedValue.getTimestamp());
+      }
+      outputReceiver.output(mainOutputTag, windowedValue);
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's code duplication between this method and the generic 
`outputWindowedValue` method that follows. You can avoid this by refactoring 
this method to call the generic version with `mainOutputTag`.
   
   ```java
       public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
         outputWindowedValue(mainOutputTag, windowedValue);
       }
   ```



##########
runners/core-java/src/main/java/org/apache/beam/runners/core/SimpleDoFnRunner.java:
##########
@@ -443,6 +443,18 @@ public <T> void output(TupleTag<T> tag, T output) {
       SimpleDoFnRunner.this.outputWindowedValue(tag, elem.withValue(output));
     }
 
+    @Override
+    public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
+      checkTimestamp(elem.getTimestamp(), windowedValue.getTimestamp());
+      SimpleDoFnRunner.this.outputWindowedValue(mainOutputTag, windowedValue);
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's code duplication between this method and the generic 
`outputWindowedValue` method that follows. You can avoid this by refactoring 
this method to call the generic version with `mainOutputTag`.
   
   ```java
       public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
         outputWindowedValue(mainOutputTag, windowedValue);
       }
   ```



##########
runners/core-java/src/main/java/org/apache/beam/runners/core/SimpleDoFnRunner.java:
##########
@@ -1027,6 +1039,18 @@ public <T> void outputWindowedValue(
           .output();
     }
 
+    @Override
+    public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
+      checkTimestamp(timestamp(), windowedValue.getTimestamp());
+      SimpleDoFnRunner.this.outputWindowedValue(mainOutputTag, windowedValue);
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's code duplication between this method and the generic 
`outputWindowedValue` method that follows. You can avoid this by refactoring 
this method to call the generic version with `mainOutputTag`.
   
   ```java
       public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
         outputWindowedValue(mainOutputTag, windowedValue);
       }
   ```



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnTester.java:
##########
@@ -649,6 +649,38 @@ public <T> void outputWithTimestamp(TupleTag<T> tag, T 
output, Instant timestamp
                   CausedByDrain.NORMAL));
     }
 
+    @Override
+    public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
+      for (BoundedWindow w : windowedValue.getWindows()) {
+        getMutableOutput(mainOutputTag)
+            .add(
+                ValueInSingleWindow.of(
+                    windowedValue.getValue(),
+                    windowedValue.getTimestamp(),
+                    w,
+                    windowedValue.getPaneInfo(),
+                    windowedValue.getRecordId(),
+                    windowedValue.getRecordOffset(),
+                    windowedValue.causedByDrain()));
+      }
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's code duplication between this method and the generic 
`outputWindowedValue` method that follows. You can avoid this by refactoring 
this method to call the generic version with `mainOutputTag`.
   
   ```java
       public void outputWindowedValue(WindowedValue<OutputT> windowedValue) {
         outputWindowedValue(mainOutputTag, windowedValue);
       }
   ```



##########
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/MetadataPropagationTest.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.transforms;
+
+import org.apache.beam.sdk.testing.NeedsRunner;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.values.CausedByDrain;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.WindowedValues;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+public class MetadataPropagationTest {
+  private static final Integer[] EMPTY = new Integer[] {};
+  private static final Integer[] DATA = new Integer[] {1, 2, 3, 4, 5};
+  private static final Integer[] REPEATED_DATA = new Integer[] {1, 1, 2, 2, 3, 
3, 4, 4, 5, 5};

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   These static fields `EMPTY`, `DATA`, and `REPEATED_DATA` are not used in 
this class and can be removed to improve code 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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to