@Override
  @SuppressWarnings("javabugs:S6466")
  public void transform(RowWindow rowWindow, PointCollector collector) throws Exception {
    if (rowWindow.windowSize() < window) { // skip too short series
      return;
    }
    DoubleArrayList a = new DoubleArrayList();
    int n = rowWindow.windowSize();
    long time = rowWindow.getRow(0).getTime();
    for (int i = 0; i < n; i++) {
      Row row = rowWindow.getRow(i);
      a.add(Util.getValueAsDouble(row, 0));
    }
    int m = a.size();
    double[][] dp = new double[m + 1][m + 1];
    for (int i = 1; i <= m; i++) {
      dp[i][i] = 0;
      if (i < m) {
        dp[i][i + 1] = Math.pow(Math.abs(a.get(i - 1) - a.get(i)), 2);
      }
    }
    for (int len = 3; len <= m; len++) {
      for (int i = 1, j = len; j <= m; j++) {
        dp[i][j] =
            Math.pow(Math.abs(a.get(0) - a.get(j - 1)), 2)
                + Math.min(Math.min(dp[i + 1][j], dp[i][j - 1]), dp[i + 1][j - 1]);
      }
    }
    if (dp[1][m] <= threshold) {
      collector.putDouble(time, dp[1][m]);
    }
  }
This function finds symmetric patterns in a series according to DTW distance.
library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFPtnSym.java