public static SchemaFile loadSnapshot(File snapshotDir, String sgName, int schemaRegionId)
      throws IOException, MetadataException {
    File snapshot = SystemFileFactory.INSTANCE.getFile(snapshotDir, SchemaConstant.PBTREE_SNAPSHOT);
    if (!snapshot.exists()) {
      throw new SchemaFileNotExists(snapshot.getPath());
    }
    File schemaFile =
        SystemFileFactory.INSTANCE.getFile(
            getDirPath(sgName, schemaRegionId), SchemaConstant.PBTREE_FILE_NAME);
    Files.deleteIfExists(schemaFile.toPath());

    if (!IoTDBDescriptor.getInstance()
        .getConfig()
        .getSchemaRegionConsensusProtocolClass()
        .equals(ConsensusFactory.RATIS_CONSENSUS)) {
      // schemaFileLog disabled with RATIS consensus
      File schemaLogFile =
          SystemFileFactory.INSTANCE.getFile(
              getDirPath(sgName, schemaRegionId), SchemaConstant.PBTREE_LOG_FILE_NAME);
      Files.deleteIfExists(schemaLogFile.toPath());
    }

    Files.copy(snapshot.toPath(), schemaFile.toPath());
    return new SchemaFile(sgName, schemaRegionId, false, Long.MAX_VALUE, false);
  }
TODO: shall merge with PageManager#reEstimateSegSize
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/SchemaFile.java