public long check(String filename, boolean fastFinish)
      throws IOException, TsFileStatisticsMistakesException, TsFileTimeseriesMetadataException {
    LOGGER.info("file path: {}", filename);
    TsFileSelfCheckToolReader reader = new TsFileSelfCheckToolReader(filename);
    Map<Long, Pair<Path, TimeseriesMetadata>> timeseriesMetadataMap = null;
    long res = -1;
    try {
      timeseriesMetadataMap = getTimeseriesMetadataMapWithReader(reader);
      res = reader.selfCheckWithInfo(filename, fastFinish, timeseriesMetadataMap);
    } catch (TsFileStatisticsMistakesException e) {
      throw e;
    } catch (Exception e) {
      LOGGER.error("Error occurred while getting all TimeseriesMetadata with offset in TsFile.");
      throw new TsFileTimeseriesMetadataException(
          "Error occurred while getting all TimeseriesMetadata with offset in TsFile.");
    } finally {
      reader.close();
    }
    return res;
  }
@param filename The path of TsFile.
@param fastFinish If true, the method will only check the format of head (Magic String TsFile,
    Version Number) and tail (Magic String TsFile) of TsFile.
@return There are four return values of the check method. The return value is 0, which means
    that the TsFile self check is error-free. The return value is -1, which means that TsFile
    has inconsistencies in Statistics. There will be two specific exceptions, one is that the
    Statistics of TimeSeriesMetadata is inconsistent with the Statistics of the aggregated
    statistics of ChunkMetadata. The other is that the Statistics of ChunkMetadata is
    inconsistent with the Statistics of Page aggregation statistics in the Chunk indexed by it.
    The return value is -2, which means that the TsFile version is not compatible. The return
    value is -3, which means that the TsFile file does not exist in the given path.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/TsFileSelfCheckTool.java