lukecwik commented on code in PR #22953:
URL: https://github.com/apache/beam/pull/22953#discussion_r1036510196


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java:
##########
@@ -117,6 +117,11 @@
    */
   @AutoValue
   public abstract static class BatchingParams<InputT> implements Serializable {
+    public static <InputT> BatchingParams<InputT> createDefault() {

Review Comment:
   ```suggestion
       private static <InputT> BatchingParams<InputT> createDefault() {
   ```



##########
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/GroupIntoBatchesTest.java:
##########
@@ -155,90 +151,68 @@ public void testInGlobalWindowBatchSizeByteSize() {
     PAssert.that("Incorrect batch size in one or more elements", collection)
         .satisfies(
             new SerializableFunction<Iterable<KV<String, Iterable<String>>>, 
Void>() {
-
-              private boolean checkBatchSizes(Iterable<KV<String, 
Iterable<String>>> listToCheck) {
-                for (KV<String, Iterable<String>> element : listToCheck) {
-                  long byteSize = 0;
-                  for (String str : element.getValue()) {
-                    if (byteSize >= BATCH_SIZE_BYTES) {
-                      // We already reached the batch size, so extra elements 
are not expected.
-                      return false;
-                    }
-                    try {
-                      byteSize += 
StringUtf8Coder.of().getEncodedElementByteSize(str);
-                    } catch (Exception e) {
-                      throw new RuntimeException(e);
-                    }
-                  }
-                }
-                return true;
-              }
-
               @Override
               public Void apply(Iterable<KV<String, Iterable<String>>> input) {
-                assertTrue(checkBatchSizes(input));
+                assertTrue(checkBatchByteSizes(input));
                 return null;
               }
             });
     PAssert.thatSingleton("Incorrect collection size", 
collection.apply("Count", Count.globally()))
-        .isEqualTo(3L);
+        .isEqualTo(4L);
     pipeline.run();
   }
 
   @Test
   @Category({
     ValidatesRunner.class,
     NeedsRunner.class,
+    UsesTestStream.class,
     UsesTimersInParDo.class,
     UsesStatefulParDo.class,
     UsesOnWindowExpiration.class
   })
   public void testInGlobalWindowBatchSizeByteSizeFn() {
+    SerializableFunction<String, Long> getElementByteSizeFn =
+        s -> {
+          try {
+            return 2 * StringUtf8Coder.of().getEncodedElementByteSize(s);
+          } catch (Exception e) {
+            throw new RuntimeException(e);
+          }
+        };
+
+    // to ensure ordered processing
+    TestStream.Builder<KV<String, String>> streamBuilder =
+        TestStream.create(KvCoder.of(StringUtf8Coder.of(), 
StringUtf8Coder.of()))
+            .advanceWatermarkTo(Instant.EPOCH);

Review Comment:
   ```suggestion
           TestStream.create(KvCoder.of(StringUtf8Coder.of(), 
StringUtf8Coder.of()));
   ```



-- 
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