public List<byte[]> collectUpdatedEntries() throws IOException, SchemaFileLogCorruptedException {
    if (inputStream == null || inputStream.getChannel().size() == 0) {
      return Collections.emptyList();
    }

    // TODO: better performance if not scan from head to tail

    List<byte[]> colBuffers = new ArrayList<>();
    byte[] tempBytes = new byte[SchemaFileConfig.PAGE_LENGTH];
    while (inputStream.available() > 0) {
      inputStream.read(tempBytes, 0, 1);

      if (tempBytes[0] == SchemaFileConfig.SF_COMMIT_MARK) {
        throw new SchemaFileLogCorruptedException(
            logFile.getAbsolutePath(), "COMMIT_MARK without PREPARE_MARK");
      }

      // handle prepare mark
      if (tempBytes[0] == SchemaFileConfig.SF_PREPARE_MARK) {

        // nothing after then, restore as what logged
        if (inputStream.available() < 1) {
          return colBuffers;
        }

        // remove what is collected if commit mark followed, throw exception otherwise
        inputStream.read(tempBytes, 0, 1);
        if (tempBytes[0] == SchemaFileConfig.SF_COMMIT_MARK) {
          colBuffers.clear();
        } else {
          throw new SchemaFileLogCorruptedException(
              logFile.getAbsolutePath(),
              "an extraneous byte rather than " + "COMMIT_MARK after PREPARE_MARK");
        }

        // no bytes after commit mark, safe to exit
        if (inputStream.read(tempBytes, 0, 1) < 0) {
          return Collections.emptyList();
        }
      }

      // corrupted within one entry
      if (inputStream.read(tempBytes, 1, tempBytes.length - 1) < tempBytes.length - 2) {
        throw new SchemaFileLogCorruptedException(logFile.getAbsolutePath(), "incomplete entry.");
      }

      colBuffers.add(tempBytes);
      tempBytes = new byte[SchemaFileConfig.PAGE_LENGTH];
    }

    throw new SchemaFileLogCorruptedException(
        logFile.getAbsolutePath(), "not ended by COMMIT_MARK nor PREPARE_MARK.");
  }
Load bytes from SchemaFileLog while assuring integrity of entries and marks, leaving semantic
correctness of entry bytes unchecked.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/log/SchemaFileLogReader.java