public void flush() {
    switch (state) {
      case 0:
      case 1:
        while (!timeWindow.isEmpty()) {
          timeBuffer.push(timeWindow.pop());
          labelBuffer.push(false);
          valueWindow.pop();
        }
        break;
      case 2:
        boolean label = timeWindow.getSize() - missingStartIndex > minLength;
        for (int i = 0; i < missingStartIndex; i++) {
          timeBuffer.push(timeWindow.pop());
          labelBuffer.push(false);
          valueWindow.pop();
        }
        while (!timeWindow.isEmpty()) {
          timeBuffer.push(timeWindow.pop());
          labelBuffer.push(label);
          valueWindow.pop();
        }
        break;
      default:
        break;
    }
  }
Streaming anomaly detection for anomalies of data missing.
library-udf/src/main/java/org/apache/iotdb/library/anomaly/util/StreamMissDetector.java