private long preAllocateSegment(short size, SchemaPageContext cxt)
      throws IOException, MetadataException {
    ISegmentedPage page = getMinApplSegmentedPageInMem(size, cxt);
    short sparePrev = page.getSpareSize();
    long res = SchemaFile.getGlobalIndex(page.getPageIndex(), page.allocNewSegment(size));
    if (sparePrev < page.getSpareSize()) {
      // a compaction trigger by allocNewSegment had increased spare size
      cxt.indexBuckets.sortIntoBucket(page, (short) -1);
    }
    return res;
  }
Any page returned will be pinned/referred by the cxt. *
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/pagemgr/PageManager.java