tejasiyer-dev commented on code in PR #41468:
URL: https://github.com/apache/beam/pull/41468#discussion_r4627889328


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/BundleLifter.java:
##########
@@ -149,33 +409,116 @@ private BundleLifter(
     if (threshold <= 0) {
       throw new IllegalArgumentException("Threshold must be a positive 
integer");
     }
+    if (maxBufferedBytes < threshold) {
+      throw new IllegalArgumentException(
+          "maxBufferedBytes must be at least the threshold, so a key can reach 
the threshold");
+    }
+    if (maxLiftedKeys <= 0) {
+      throw new IllegalArgumentException("maxLiftedKeys must be positive");
+    }
 
     this.smallBatchTag = smallBatchTag;
     this.largeBatchTag = largeBatchTag;
     this.threshold = threshold;
+    this.maxBufferedBytes = maxBufferedBytes;
+    this.maxLiftedKeys = maxLiftedKeys;
     this.elementSizer = elementSizer;
+    this.keyFn = keyFn;
   }
 
+  /** Routes by element count: each element counts as one toward the 
threshold. */
   public static <T> BundleLifter<T> of(
-      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, int threshold) {
-    return new BundleLifter<>(smallBatchTag, largeBatchTag, threshold);
+      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, long threshold) {

Review Comment:
   Renamed to elementCountThreshold.



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/BundleLifter.java:
##########
@@ -149,33 +409,116 @@ private BundleLifter(
     if (threshold <= 0) {
       throw new IllegalArgumentException("Threshold must be a positive 
integer");
     }
+    if (maxBufferedBytes < threshold) {
+      throw new IllegalArgumentException(
+          "maxBufferedBytes must be at least the threshold, so a key can reach 
the threshold");
+    }
+    if (maxLiftedKeys <= 0) {
+      throw new IllegalArgumentException("maxLiftedKeys must be positive");
+    }
 
     this.smallBatchTag = smallBatchTag;
     this.largeBatchTag = largeBatchTag;
     this.threshold = threshold;
+    this.maxBufferedBytes = maxBufferedBytes;
+    this.maxLiftedKeys = maxLiftedKeys;
     this.elementSizer = elementSizer;
+    this.keyFn = keyFn;
   }
 
+  /** Routes by element count: each element counts as one toward the 
threshold. */
   public static <T> BundleLifter<T> of(
-      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, int threshold) {
-    return new BundleLifter<>(smallBatchTag, largeBatchTag, threshold);
+      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, long threshold) {
+    return of(smallBatchTag, largeBatchTag, threshold, x -> 1);
   }
 
+  /** Routes by the sizes returned by {@code elementSizer}. */
   public static <T> BundleLifter<T> of(
       TupleTag<T> smallBatchTag,
       TupleTag<T> largeBatchTag,
-      int threshold,
+      long threshold,
       SerializableFunction<T, Integer> elementSizer) {
-    return new BundleLifter<>(smallBatchTag, largeBatchTag, threshold, 
elementSizer);
+    return new BundleLifter<>(
+        smallBatchTag,
+        largeBatchTag,
+        threshold,
+        defaultMaxBufferedBytes(threshold),
+        Integer.MAX_VALUE,
+        elementSizer,
+        null);
+  }
+
+  /** Routes by each element's encoded size under {@code coder}. */
+  public static <T> BundleLifter<T> of(
+      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, long threshold, 
Coder<T> coder) {

Review Comment:
   Done.



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/BundleLifter.java:
##########
@@ -149,33 +409,116 @@ private BundleLifter(
     if (threshold <= 0) {
       throw new IllegalArgumentException("Threshold must be a positive 
integer");
     }
+    if (maxBufferedBytes < threshold) {
+      throw new IllegalArgumentException(
+          "maxBufferedBytes must be at least the threshold, so a key can reach 
the threshold");
+    }
+    if (maxLiftedKeys <= 0) {
+      throw new IllegalArgumentException("maxLiftedKeys must be positive");
+    }
 
     this.smallBatchTag = smallBatchTag;
     this.largeBatchTag = largeBatchTag;
     this.threshold = threshold;
+    this.maxBufferedBytes = maxBufferedBytes;
+    this.maxLiftedKeys = maxLiftedKeys;
     this.elementSizer = elementSizer;
+    this.keyFn = keyFn;
   }
 
+  /** Routes by element count: each element counts as one toward the 
threshold. */
   public static <T> BundleLifter<T> of(
-      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, int threshold) {
-    return new BundleLifter<>(smallBatchTag, largeBatchTag, threshold);
+      TupleTag<T> smallBatchTag, TupleTag<T> largeBatchTag, long threshold) {
+    return of(smallBatchTag, largeBatchTag, threshold, x -> 1);
   }
 
+  /** Routes by the sizes returned by {@code elementSizer}. */
   public static <T> BundleLifter<T> of(
       TupleTag<T> smallBatchTag,
       TupleTag<T> largeBatchTag,
-      int threshold,
+      long threshold,

Review Comment:
   Done.



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