private void switchLoggingFile() throws IOException {
    try {
      ProgressIndex curProgressIndex =
          ReplicateProgressDataNodeManager.extractLocalSimpleProgressIndex(
              maxProgressIndexInCurrentFile);
      // PipeConsensus ensures that deleteDataNodes use recoverProgressIndex.
      if (!(curProgressIndex instanceof SimpleProgressIndex)) {
        throw new IOException("Invalid deletion progress index: " + curProgressIndex);
      }
      SimpleProgressIndex progressIndex = (SimpleProgressIndex) curProgressIndex;
      // Deletion file name format:
      // "_{lastFileMaxRebootTimes}_{lastFileMaxMemTableFlushOrderId}.deletion"
      this.logFile =
          new File(
              baseDirectory,
              String.format(
                  "_%d-%d%s",
                  progressIndex.getRebootTimes(),
                  progressIndex.getMemTableFlushOrderId(),
                  DeletionResourceManager.DELETION_FILE_SUFFIX));
      this.logStream = new FileOutputStream(logFile, true);
      this.logChannel = logStream.getChannel();
      // Create file && write magic string
      if (!logFile.exists() || logFile.length() == 0) {
        this.logChannel.write(
            ByteBuffer.wrap(
                DeletionResourceManager.MAGIC_VERSION_V1.getBytes(StandardCharsets.UTF_8)));
      }
      LOGGER.info(
          "Deletion persist-{}: switching to a new file, current writing: {}",
          dataRegionId,
          logFile);
    } finally {
      resetFileAttribute();
    }
  }
The core idea of this buffer is to write deletion to the Page cache and fsync them to disk when
certain conditions are met. This design does not decouple serialization and writing, but provides
an easier way to maintain and understand.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/persist/PageCacheDeletionBuffer.java