Class BatchElements.BatchConfig.Builder

java.lang.Object
org.apache.beam.sdk.transforms.BatchElements.BatchConfig.Builder
Enclosing class:
BatchElements.BatchConfig

public static final class BatchElements.BatchConfig.Builder extends Object
  • Method Details

    • withMinBatchSize

      public BatchElements.BatchConfig.Builder withMinBatchSize(int minBatchSize)
      Sets the minimum batch size.
      Parameters:
      minBatchSize - minimum number of elements per batch
    • withMaxBatchSize

      public BatchElements.BatchConfig.Builder withMaxBatchSize(int maxBatchSize)
      Sets the maximum batch size.
      Parameters:
      maxBatchSize - maximum number of elements per batch
    • withTargetBatchOverhead

      public BatchElements.BatchConfig.Builder withTargetBatchOverhead(double targetBatchOverhead)
      Sets the target batch overhead ratio.

      This represents the desired ratio:

      fixed_cost / total_time

      Lower values favor larger batches (higher throughput, higher latency).

      Parameters:
      targetBatchOverhead - value in (0, 1]
    • withTargetBatchDurationSecs

      public BatchElements.BatchConfig.Builder withTargetBatchDurationSecs(double targetBatchDurationSecs)
      Sets the target batch duration excluding fixed cost.

      This controls the desired time spent processing elements in a batch, ignoring fixed overhead.

      Parameters:
      targetBatchDurationSecs - target duration in seconds
    • withTargetBatchDurationSecsWithFixedCost

      public BatchElements.BatchConfig.Builder withTargetBatchDurationSecsWithFixedCost(double value)
      Sets the target batch duration including fixed cost.

      If set, this provides a stricter upper bound on total batch processing time.

      Parameters:
      value - target duration in seconds
    • withVariance

      public BatchElements.BatchConfig.Builder withVariance(double variance)
      Sets the allowed variance when selecting batch sizes.

      This introduces controlled randomness to avoid converging to a single batch size and improves robustness of estimation.

      Parameters:
      variance - relative deviation (e.g., 0.25 for ±25%)
    • build

      public BatchElements.BatchConfig build()