@Override
  public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
      throws Exception {
    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
    long newPeriod = Util.parseTime(parameters.getString("every"), parameters);
    String aggregator = parameters.getStringOrDefault("aggr", "mean").toLowerCase();
    String interpolator = parameters.getStringOrDefault("interp", "nan").toLowerCase();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    long startTime = -1;
    long endTime = -1;
    if (parameters.hasAttribute(START_PARAM)) {
      startTime = format.parse(parameters.getString(START_PARAM)).getTime();
    }
    if (parameters.hasAttribute("end")) {
      endTime = format.parse(parameters.getString("end")).getTime();
    }
    resampler = new Resampler(newPeriod, aggregator, interpolator, startTime, endTime);
  }
This function does upsample or downsample of input series.
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java