@Override
  public void writeMNode(ICachedMNode node) throws MetadataException, IOException {
    long curSegAddr = getNodeAddress(node);

    if (node.isDatabase()) {
      isEntity = node.isDevice();
      setNodeAddress(node, lastSGAddr);
    } else {
      if (curSegAddr < 0L) {
        if (node.isDevice() && node.getAsDeviceMNode().isUseTemplate()) {
          throw new MetadataException(
              String.format(
                  "Adding or updating children of device using template [%s] is NOT allowed.",
                  node.getFullPath()));
        }

        // now only 32 bits page index is allowed
        throw new MetadataException(
            String.format(
                "Cannot flush any node with negative address [%s] except for DatabaseNode.",
                node.getFullPath()));
      }
    }
    pageManager.writeMNode(node);
    updateHeaderBuffer();
  }
This class is mainly aimed to manage space all over the file.

<p>This class is meant to open a .pst(Persistent mTree) file, and maintains the header of the
file. It Loads or writes a page length bytes at once, with an 32 bits int to index a page inside
a file. Use SlottedFile to manipulate segment(sp) inside a page(an array of bytes).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/SchemaFile.java