private ISchemaTree autoCreateSchema() throws IllegalPathException {
    final List<PartialPath> deviceList = new ArrayList<>();
    final List<String[]> measurementList = new ArrayList<>();
    final List<TSDataType[]> dataTypeList = new ArrayList<>();
    final List<TSEncoding[]> encodingsList = new ArrayList<>();
    final List<CompressionType[]> compressionTypesList = new ArrayList<>();
    final List<Boolean> isAlignedList = new ArrayList<>();

    for (final Map.Entry<IDeviceID, Set<MeasurementSchema>> entry :
        schemaCache.getDevice2TimeSeries().entrySet()) {
      final int measurementSize = entry.getValue().size();
      final String[] measurements = new String[measurementSize];
      final TSDataType[] tsDataTypes = new TSDataType[measurementSize];
      final TSEncoding[] encodings = new TSEncoding[measurementSize];
      final CompressionType[] compressionTypes = new CompressionType[measurementSize];

      int index = 0;
      for (final MeasurementSchema measurementSchema : entry.getValue()) {
        measurements[index] = measurementSchema.getMeasurementName();
        tsDataTypes[index] = measurementSchema.getType();
        encodings[index] = measurementSchema.getEncodingType();
        compressionTypes[index++] = measurementSchema.getCompressor();
      }

      deviceList.add(new PartialPath(entry.getKey()));
      measurementList.add(measurements);
      dataTypeList.add(tsDataTypes);
      encodingsList.add(encodings);
      compressionTypesList.add(compressionTypes);
      isAlignedList.add(schemaCache.getDeviceIsAligned(entry.getKey()));
    }

    return SchemaValidator.validate(
        loadTsFileAnalyzer.schemaFetcher,
        deviceList,
        measurementList,
        dataTypeList,
        encodingsList,
        compressionTypesList,
        isAlignedList,
        loadTsFileAnalyzer.context);
  }
This can only be invoked after all timeseries in the current tsfile have been processed.
Otherwise, the isAligned status may be wrong.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java