pabloem commented on code in PR #25173:
URL: https://github.com/apache/beam/pull/25173#discussion_r1087318363


##########
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:
   this creates the same kind of per-batch grouping but no 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]

Reply via email to