public List<String> updateAsDifferenceAndGetIntersection(Set<String> targetMeasurementSet) {
    List<String> removedMeasurements = new ArrayList<>();

    List<String> updatedMeasurements = new ArrayList<>();
    List<TSDataType> updatedDataTypes = new ArrayList<>();
    List<TSEncoding> updatedEncodings = this.encodings == null ? null : new ArrayList<>();
    List<CompressionType> updatedCompressors = this.compressors == null ? null : new ArrayList<>();

    for (int i = 0; i < this.measurements.size(); i++) {
      if (targetMeasurementSet.contains(this.measurements.get(i))) {
        removedMeasurements.add(this.measurements.get(i));
        continue;
      }
      updatedMeasurements.add(this.measurements.get(i));
      updatedDataTypes.add(this.dataTypes.get(i));
      if (this.encodings != null) {
        updatedEncodings.add(this.encodings.get(i));
      }
      if (this.compressors != null) {
        updatedCompressors.add(this.compressors.get(i));
      }
    }

    this.measurements = updatedMeasurements;
    this.dataTypes = updatedDataTypes;
    this.encodings = updatedEncodings;
    this.compressors = updatedCompressors;

    return removedMeasurements;
  }
Updates this to be the difference of set between this and targetMeasurementSet. Returns the
intersection.

@param targetMeasurementSet The set to compare with measurement set of this.
@return A list of elements representing the intersection between measurement set of this and
    the targetMeasurementSet.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/template/alter/TemplateExtendInfo.java