@Override
  public void beforeDestroy() {
    switch (dataType) {
      case INT32:
        intSet.clear();
        break;
      case INT64:
        longSet.clear();
        break;
      case FLOAT:
        floatSet.clear();
        break;
      case DOUBLE:
        doubleSet.clear();
        break;
      case TEXT:
        stringSet.clear();
        break;
      case BOOLEAN:
        booleanSet.clear();
        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