gemini-code-assist[bot] commented on code in PR #37036:
URL: https://github.com/apache/beam/pull/37036#discussion_r2600623583
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/FlinkStreamingTransformTranslators.java:
##########
@@ -183,33 +192,131 @@ public static String
getCurrentTransformName(FlinkStreamingTranslationContext co
return context.getCurrentTransform().getFullName();
}
+ /** Returns the parallelism to use for source operators. */
+ private static int getSourceParallelism(FlinkStreamingTranslationContext
context) {
+ int maxParallelism = context.getExecutionEnvironment().getMaxParallelism();
+ return maxParallelism > 0 ? maxParallelism :
context.getExecutionEnvironment().getParallelism();
+ }
+
//
--------------------------------------------------------------------------------------------
// Transformation Implementations
//
--------------------------------------------------------------------------------------------
+ /** Common translation logic for unbounded sources. */
+ @SuppressWarnings("unchecked")
+ private static <T> void translateUnboundedSource(
+ UnboundedSource<T, ?> rawSource,
+ String transformName,
+ FlinkStreamingTranslationContext context) {
+
+ PCollection<T> output =
+ (PCollection<T>)
+
Iterables.getOnlyElement(context.getCurrentTransform().getOutputs().values());
Review Comment:

This logic to retrieve the single output `PCollection` is duplicated in
`translateBoundedSource` (line 273). To improve maintainability and reduce code
duplication, consider extracting this into a private static helper method
within this class.
For example:
```java
@SuppressWarnings("unchecked")
private static <T> PCollection<T>
getOnlyOutput(FlinkStreamingTranslationContext context) {
return (PCollection<T>)
Iterables.getOnlyElement(context.getCurrentTransform().getOutputs().values());
}
```
You could then call `getOnlyOutput(context)` in both
`translateUnboundedSource` and `translateBoundedSource`.
--
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]