Class BytesThroughputEstimator<T>

java.lang.Object
org.apache.beam.sdk.io.gcp.spanner.changestreams.estimator.BytesThroughputEstimator<T>
All Implemented Interfaces:
Serializable, ThroughputEstimator<T>

public class BytesThroughputEstimator<T> extends Object implements ThroughputEstimator<T>
An estimator to provide an estimate on the throughput of the outputted elements.

This estimator will keep track of the bytes of reported records within a sliding window. The window consists of the configured number of seconds and each record's bytes will fall into exactly one given second bucket. When more than window size seconds have passed from the current time, the bytes reported for the seconds that fall of the window will not be considered anymore. The bytes of the records will be estimated using the configured Coder.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    BytesThroughputEstimator(int windowSizeSeconds, SizeEstimator<T> sizeEstimator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    get()
    Returns the estimated throughput bytes for now.
    double
    getFrom(com.google.cloud.Timestamp time)
    Returns the estimated throughput bytes for a specified time.
    void
    update(com.google.cloud.Timestamp timeOfRecords, T element)
    Updates the estimator with the bytes of records.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BytesThroughputEstimator

      public BytesThroughputEstimator(int windowSizeSeconds, SizeEstimator<T> sizeEstimator)
  • Method Details

    • update

      public void update(com.google.cloud.Timestamp timeOfRecords, T element)
      Updates the estimator with the bytes of records.
      Specified by:
      update in interface ThroughputEstimator<T>
      Parameters:
      timeOfRecords - the committed timestamp of the records
      element - the element to estimate the byte size of
    • get

      public double get()
      Returns the estimated throughput bytes for now.
      Specified by:
      get in interface ThroughputEstimator<T>
    • getFrom

      public double getFrom(com.google.cloud.Timestamp time)
      Returns the estimated throughput bytes for a specified time.
      Specified by:
      getFrom in interface ThroughputEstimator<T>
      Parameters:
      time - the specified timestamp to check throughput