@Override
  public void transform(Row row, PointCollector collector) throws Exception {
    // pool sampling
    int x;
    if (this.num < this.k) {
      x = this.num;
    } else {
      x = random.nextInt(num + 1);
    }
    if (x < this.k) {
      Object v = Util.getValueAsObject(row);
      Long t = row.getTime();
      this.samples[x] = Pair.of(t, v);
    }
    this.num++;
  }
This function samples data by pool sampling.
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSample.java