code: private Duration getReadTimeout() {
          // Find the minimum expiration time among all SegmentAggregators.
          long maxTimeMillis = this.config.getMaxReadTimeout().toMillis();
          long minTimeMillis = this.config.getMinReadTimeout().toMillis();
          long timeMillis = maxTimeMillis;
          for (ProcessorCollection a : this.processors.values()) {
              if (a.mustFlush()) {
                  // We found a SegmentAggregator that needs to flush right away. No need to search anymore.
                  timeMillis = 0;
                  break;
              }
  
              timeMillis = MathHelpers.minMax(this.config.getFlushThresholdTime().minus(a.getElapsedSinceLastFlush()).toMillis(), minTimeMillis, timeMillis);
          }
  
          return Duration.ofMillis(timeMillis);
      }
docs: Calculates the amount of time that should be used as a timeout for WriterDataSource reads. The following rules
  are taken into consideration:
  * If at least one SegmentAggregator needs to flush right away, the timeout returned is 0.
  * The returned timeout is the amount of time until the first SegmentAggregator is due to flush.
  * The returned timeout (except in the first case) is bounded by WriterConfig.MinReadTimeout and WriterConfig.MaxReadTimeout.