Abacn commented on code in PR #25173:
URL: https://github.com/apache/beam/pull/25173#discussion_r1087325840
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java:
##########
@@ -1716,31 +1714,10 @@ static <T> PCollection<Iterable<T>> batchElements(
.apply(Values.create());
} else {
iterables =
- input.apply(
- ParDo.of(
- new DoFn<T, Iterable<T>>() {
- @Nullable List<T> outputList;
-
- @ProcessElement
- public void process(ProcessContext c) {
- if (outputList == null) {
- outputList = new ArrayList<>();
- }
- outputList.add(c.element());
- if (outputList.size() > batchSize) {
- c.output(outputList);
- outputList = null;
- }
- }
-
- @FinishBundle
- public void finish(FinishBundleContext c) {
- if (outputList != null && outputList.size() > 0) {
- c.output(outputList, Instant.now(),
GlobalWindow.INSTANCE);
- }
- outputList = null;
- }
- }));
+ input
+ .apply(WithKeys.<String, T>of(""))
+ .apply(GroupIntoBatches.<String,
T>ofSize(batchSize).withShardedKey())
Review Comment:
thanks for the detailed explanation. I am wondering what is the performance
impact of changing it to GroupIntoBatches. Should we preserve the current
implementation (a DoFn) used for batch, and use GroupIntoBatches in streaming
with/without autosharding?
--
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]