public void calculateGap() {
    long[] time = new long[window.size() - 1];
    for (int i = 0; i < time.length; i++) {
      time[i] = window.get(i + 1).getLeft() - window.get(i).getLeft();
    }
    gap = Util.mode(time);
  }
calculate standard timestamp gap in given window.
library-udf/src/main/java/org/apache/iotdb/library/series/util/ConsecutiveUtil.java