@Override
  public Function<List<List<T>>, List<List<T>>> finisher() {
    return lists -> {
      if (!buffer.isEmpty()) {
        final int totalOut = estimateTotalOut();
        if (totalOut > lists.size()) {
          dumpCurrent(lists);
        }
      }
      return lists;
    };
  }
this class is copied and modified from <a
href="https://github.com/ggalmazor/lt_downsampling_java8">...</a> project
library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/SlidingCollector.java