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


##########
examples/java/src/main/java/org/apache/beam/examples/complete/AutoComplete.java:
##########
@@ -527,11 +536,13 @@ public static void runAutocompletePipeline(Options 
options) throws IOException {
                   ParDo.of(
                       new DoFn<KV<String, List<CompletionCandidate>>, Long>() {
                         @ProcessElement
-                        public void process(ProcessContext c) {
-                          KV<String, List<CompletionCandidate>> elm = 
c.element();
+                        public void process(
+                            @Element KV<String, List<CompletionCandidate>> 
element,
+                            OutputReceiver<Long> receiver) {
+                          KV<String, List<CompletionCandidate>> elm = element;
                           Long listHash =
-                              c.element().getValue().stream().mapToLong(cc -> 
cc.hashCode()).sum();
-                          c.output(Long.valueOf(elm.getKey().hashCode()) + 
listHash);
+                              element.getValue().stream().mapToLong(cc -> 
cc.hashCode()).sum();
+                          
receiver.output(Long.valueOf(elm.getKey().hashCode()) + listHash);
                         }
                       }))

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The local variable `elm` is redundant. Renaming the `@Element` parameter to 
`elm` improves readability and avoids unnecessary variable assignment. 
Additionally, ensure the parameter is used consistently throughout the method 
body.
   
   ```java
                           public void process(
                               @Element KV<String, List<CompletionCandidate>> 
elm,
                               OutputReceiver<Long> receiver) {
                             Long listHash =
                                 elm.getValue().stream().mapToLong(cc -> 
cc.hashCode()).sum();
                             
receiver.output(Long.valueOf(elm.getKey().hashCode()) + listHash);
                           }
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/BigQueryTornadoes.java:
##########
@@ -79,10 +81,10 @@ public class BigQueryTornadoes {
    */
   static class ExtractTornadoesFn extends DoFn<TableRow, Integer> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<Integer> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
match the usage.
   
   ```suggestion
       public void processElement(@Element TableRow row, 
OutputReceiver<Integer> receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/FilterExamples.java:
##########
@@ -135,10 +138,10 @@ public void processElement(ProcessContext c) {
    */
   static class ExtractTempFn extends DoFn<TableRow, Double> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<Double> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
improve readability.
   
   ```suggestion
       public void processElement(@Element TableRow row, OutputReceiver<Double> 
receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/FilterExamples.java:
##########
@@ -87,8 +90,8 @@ public class FilterExamples {
    */
   static class ProjectionFn extends DoFn<TableRow, TableRow> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<TableRow> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
improve readability.
   
   ```suggestion
       public void processElement(@Element TableRow row, 
OutputReceiver<TableRow> receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/FilterExamples.java:
##########
@@ -119,12 +122,12 @@ public FilterSingleMonthDataFn(Integer monthFilter) {
     }
 
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<TableRow> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
improve readability.
   
   ```suggestion
       public void processElement(@Element TableRow row, 
OutputReceiver<TableRow> receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/KafkaStreaming.java:
##########
@@ -340,9 +343,9 @@ public PCollection<BadRecord> expand(PCollection<BadRecord> 
input) {
 
     static class LogErrorFn extends DoFn<BadRecord, BadRecord> {
       @ProcessElement
-      public void processElement(@Element BadRecord record, 
OutputReceiver<BadRecord> receiver) {
-        System.out.println(record);
-        receiver.output(record);
+      public void processElement(@Element BadRecord element, 
OutputReceiver<BadRecord> receiver) {
+        System.out.println(element);
+        receiver.output(element);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The parameter name was changed from the descriptive `record` to the generic 
`element`. Using descriptive names for the `@Element` parameter is preferred 
for readability, as noted in the best practices.
   
   ```suggestion
         public void processElement(@Element BadRecord record, 
OutputReceiver<BadRecord> receiver) {
           System.out.println(record);
           receiver.output(record);
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/MinimalBigQueryTornadoes.java:
##########
@@ -73,10 +75,10 @@ public class MinimalBigQueryTornadoes {
    */
   static class ExtractTornadoesFn extends DoFn<TableRow, Integer> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<Integer> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
match the usage.
   
   ```suggestion
       public void processElement(@Element TableRow row, 
OutputReceiver<Integer> receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/complete/datatokenization/utils/ErrorConverters.java:
##########
@@ -198,19 +203,21 @@ public static class FailedStringToTableRowFn
         DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
 
     @ProcessElement
-    public void processElement(ProcessContext context) {
-      FailsafeElement<String, String> failsafeElement = context.element();
+    public void processElement(
+        @Timestamp Instant timestamp,
+        @Element FailsafeElement<String, String> element,
+        OutputReceiver<TableRow> receiver) {
+      FailsafeElement<String, String> failsafeElement = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to 
`failsafeElement` to match the usage and improve clarity.
   
   ```suggestion
       public void processElement(
           @Timestamp Instant timestamp,
           @Element FailsafeElement<String, String> failsafeElement,
           OutputReceiver<TableRow> receiver) {
   ```



##########
examples/java/src/main/java/org/apache/beam/examples/cookbook/BigQueryStreamingTornadoes.java:
##########
@@ -85,10 +88,10 @@ public class BigQueryStreamingTornadoes {
    */
   static class ExtractTornadoesFn extends DoFn<TableRow, Integer> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      TableRow row = c.element();
+    public void processElement(@Element TableRow element, 
OutputReceiver<Integer> receiver) {
+      TableRow row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Redundant variable assignment. Rename the `@Element` parameter to `row` to 
match the usage and improve clarity.
   
   ```suggestion
       public void processElement(@Element TableRow row, 
OutputReceiver<Integer> receiver) {
   ```



##########
examples/java/iceberg/src/main/java/org/apache/beam/examples/iceberg/IcebergBatchWriteExample.java:
##########
@@ -74,9 +76,9 @@ private static Row flattenAnalyticsRow(Row row) {
 
   static class ExtractBrowserTransactionsFn extends DoFn<Row, KV<String, 
Long>> {
     @ProcessElement
-    public void processElement(ProcessContext c) {
-      Row row = c.element();
-      c.output(
+    public void processElement(@Element Row element, OutputReceiver<KV<String, 
Long>> receiver) {
+      Row row = element;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The local variable `row` is redundant as it simply copies the `@Element` 
parameter. It is better to rename the parameter to `row` and use it directly, 
as suggested in the `SKILL.md` best practices.
   
   ```suggestion
       public void processElement(@Element Row row, OutputReceiver<KV<String, 
Long>> receiver) {
   ```



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