gemini-code-assist[bot] commented on code in PR #37770:
URL: https://github.com/apache/beam/pull/37770#discussion_r2904568216
##########
sdks/java/io/jdbc/src/test/java/org/apache/beam/sdk/io/jdbc/JdbcIOIT.java:
##########
@@ -308,7 +308,8 @@ private static class GenerateRecordsStream extends
PTransform<PBegin, PCollectio
private final long numRecords;
private final long numPerPeriod;
- public GenerateRecordsStream(long numRecords, long numPerPeriod, Duration
periodLength) {
+ public GenerateRecordsStream(
+ long numRecords, long numPerPeriod, @SuppressWarnings("unused")
Duration periodLength) {
Review Comment:

The `periodLength` parameter is suppressed as unused, but it appears it
should be used for throttling inside the `expand` method of
`GenerateRecordsStream`. The `Thread.sleep` call currently uses a hardcoded
value of `1000`.
Instead of suppressing the warning, `periodLength` should be stored as a
field and used. This would fix a potential bug in the test and make the code
more maintainable.
For example, you could change the class to:
```java
private static class GenerateRecordsStream extends PTransform<PBegin,
PCollection<KV<Integer, String>>> {
private final long numRecords;
private final long numPerPeriod;
private final Duration periodLength;
public GenerateRecordsStream(long numRecords, long numPerPeriod, Duration
periodLength) {
this.numRecords = numRecords;
this.numPerPeriod = numPerPeriod;
this.periodLength = periodLength;
}
@Override
public PCollection<KV<Integer, String>> expand(PBegin input) {
return input
// ...
.apply(
"Throttling",
ParDo.of(
new DoFn<KV<Integer, String>, KV<Integer, String>>() {
@ProcessElement
public void processElement(...) throws
InterruptedException {
if (c.element().getKey() % numPerPeriod == 0) {
Thread.sleep(periodLength.getMillis());
}
r.output(element);
}
}));
}
}
```
--
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]