gemini-code-assist[bot] commented on code in PR #38315:
URL: https://github.com/apache/beam/pull/38315#discussion_r3189203070
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValues.java:
##########
@@ -503,6 +566,7 @@ private abstract static class SimpleWindowedValue<T>
implements WindowedValue<T>
private final @Nullable Long currentRecordOffset;
private final CausedByDrain causedByDrain;
private final @Nullable Context context;
+ private final ValueKind valueKind;
Review Comment:

The addition of the `valueKind` field to `SimpleWindowedValue` requires
updating the `equals` and `hashCode` methods to include this new field. Since
`SimpleWindowedValue` is a base class for several `WindowedValue`
implementations, failing to update these methods (or the static
`WindowedValues.equals` method they might delegate to) will lead to incorrect
equality checks, which can cause subtle bugs in transforms like `GroupByKey`.
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/ValueKindUtil.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.values;
+
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.Elements;
+
+/** Utility class for converting between {@link ValueKind} and {@link
Elements.ValueKind.Enum}. */
+public class ValueKindUtil {
Review Comment:

This utility class should be marked as `final` and include a private
constructor to prevent instantiation, as it only contains static methods.
```java
public final class ValueKindUtil {
private ValueKindUtil() {}
```
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValues.java:
##########
@@ -163,6 +165,13 @@ public Builder<T> setOpenTelemetryContext(@Nullable
Context openTelemetryContext
return this;
}
+ @Override
+ public Builder<T> setValueKind(ValueKind valueKind) {
+ checkStateNotNull(valueKind, "ValueKind is null");
+ this.valueKind = valueKind;
Review Comment:

For parameter validation in setters, `checkNotNull` (throwing
`NullPointerException`) is more idiomatic in Java and consistent with the usage
in the `SimpleWindowedValue` constructor at line 605. `checkStateNotNull`
typically throws `IllegalStateException`, which is less common for argument
validation.
```suggestion
this.valueKind = checkNotNull(valueKind, "ValueKind is null");
```
--
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]