@SuppressWarnings("java:S1181")
  public void scanTsFile(File tsFile) {
    try (TsFileSequenceReader r = new TsFileSequenceReader(tsFile.getAbsolutePath())) {
      this.reader = r;
      boolean shouldScan = onFileOpen(tsFile);
      if (!shouldScan) {
        return;
      }
      // start reading data points in sequence
      while ((marker = reader.readMarker()) != MetaMarker.SEPARATOR) {
        switch (marker) {
          case MetaMarker.ONLY_ONE_PAGE_CHUNK_HEADER:
            currChunkOnePage = true;
            currDeviceAligned = false;
            isTimeChunk = false;
            onChunk(this::onNonAlignedPage);
            break;
          case MetaMarker.CHUNK_HEADER:
            currChunkOnePage = false;
            currDeviceAligned = false;
            isTimeChunk = false;
            onChunk(this::onNonAlignedPage);
            break;
          case MetaMarker.ONLY_ONE_PAGE_TIME_CHUNK_HEADER:
            currChunkOnePage = true;
            currDeviceAligned = true;
            isTimeChunk = true;
            onChunk(this::onTimePage);
            break;
          case MetaMarker.TIME_CHUNK_HEADER:
            currChunkOnePage = false;
            currDeviceAligned = true;
            isTimeChunk = true;
            onChunk(this::onTimePage);
            break;
          case MetaMarker.ONLY_ONE_PAGE_VALUE_CHUNK_HEADER:
            currChunkOnePage = true;
            currDeviceAligned = true;
            isTimeChunk = false;
            onChunk(this::onValuePage);
            break;
          case MetaMarker.VALUE_CHUNK_HEADER:
            currChunkOnePage = false;
            currDeviceAligned = true;
            isTimeChunk = false;
            onChunk(this::onValuePage);
            break;
          case MetaMarker.CHUNK_GROUP_HEADER:
            onChunkGroup();
            break;
          case MetaMarker.OPERATION_INDEX_RANGE:
            reader.readPlanIndex();
            break;
          default:
            MetaMarker.handleUnexpectedMarker(marker);
        }
      }

      onFileEnd();
    } catch (Throwable e) {
      onException(e);
    }
  }
@return true if the file should be scanned
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/utils/TsFileSequenceScan.java