private void initFileHeader() throws IOException, MetadataException {
    if (channel.size() == 0) {
      // new pbtree file
      lastPageIndex = 0;
      ReadWriteIOUtils.write(lastPageIndex, headerContent);
      ReadWriteIOUtils.write(dataTTL, headerContent);
      ReadWriteIOUtils.write(isEntity, headerContent);
      ReadWriteIOUtils.write(sgNodeTemplateIdWithState, headerContent);
      ReadWriteIOUtils.write(SchemaFileConfig.SCHEMA_FILE_VERSION, headerContent);
      lastSGAddr = 0L;
      pageManager = new BTreePageManager(channel, pmtFile, -1, logPath);
    } else {
      channel.read(headerContent);
      headerContent.clear();
      lastPageIndex = ReadWriteIOUtils.readInt(headerContent);
      dataTTL = ReadWriteIOUtils.readLong(headerContent);
      isEntity = ReadWriteIOUtils.readBool(headerContent);
      sgNodeTemplateIdWithState = ReadWriteIOUtils.readInt(headerContent);
      lastSGAddr = ReadWriteIOUtils.readLong(headerContent);

      if (ReadWriteIOUtils.readInt(headerContent) != SchemaFileConfig.SCHEMA_FILE_VERSION) {
        channel.close();
        throw new MetadataException("SchemaFile with wrong version, please check or upgrade.");
      }

      pageManager = new BTreePageManager(channel, pmtFile, lastPageIndex, logPath);
    }
  }
This method initiate file header buffer, with an empty file if meant to init. <br>

<p><b>File Header Structure:</b>

<ul>
  <li>1 int (4 bytes): last page index {@link #lastPageIndex}
  <li>var length: root(SG) node info
      <ul>
        <li><s>a. var length string (less than 200 bytes): path to root(SG) node</s>
        <li>a. 1 long (8 bytes): dataTTL {@link #dataTTL}
        <li>b. 1 bool (1 byte): isEntityStorageGroup {@link #isEntity}
        <li>c. 1 int (4 bytes): hash code of template name {@link #sgNodeTemplateIdWithState}
        <li>d. 1 long (8 bytes): last segment address of database {@link #lastSGAddr}
        <li>e. 1 int (4 bytes): version of pbtree file {@linkplain
            SchemaFileConfig#SCHEMA_FILE_VERSION}
      </ul>
</ul>

... (Expected to extend for optimization) ...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/SchemaFile.java