@Override
  public void terminate(PointCollector pc) throws Exception {
    int i = 0;
    switch (dataType) {
      case INT32:
        MutableIntIterator intIterator = intSet.intIterator();
        while (intIterator.hasNext()) {
          pc.putInt(i, intIterator.next());
          i++;
        }
        break;
      case INT64:
        MutableLongIterator longIterator = longSet.longIterator();
        while (longIterator.hasNext()) {
          pc.putLong(i, longIterator.next());
          i++;
        }
        break;
      case FLOAT:
        MutableFloatIterator floatIterator = floatSet.floatIterator();
        while (floatIterator.hasNext()) {
          pc.putFloat(i, floatIterator.next());
          i++;
        }
        break;
      case DOUBLE:
        MutableDoubleIterator doubleIterator = doubleSet.doubleIterator();
        while (doubleIterator.hasNext()) {
          pc.putDouble(i, doubleIterator.next());
          i++;
        }
        break;
      case TEXT:
        for (String s : stringSet) {
          pc.putString(i, s);
          i++;
        }
        break;
      case BOOLEAN:
        MutableBooleanIterator booleanIterator = booleanSet.booleanIterator();
        while (booleanIterator.hasNext()) {
          pc.putBoolean(i, booleanIterator.next());
          i++;
        }
        break;
      case BLOB:
      case STRING:
      case TIMESTAMP:
      case DATE:
      default:
        break;
    }
  }
This function counts number of distinct values of input series.
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFDistinct.java