@Override
  public long transplantSegment(ISegmentedPage srcPage, short segId, short newSegSize)
      throws MetadataException {
    if (!isCapableForSegSize(newSegSize)) {
      throw new SchemaPageOverflowException(pageIndex);
    }
    if (maxAppendableSegmentSize() < newSegSize) {
      compactSegments();
    }

    ByteBuffer newBuf = ByteBuffer.allocate(newSegSize);
    srcPage.extendsSegmentTo(newBuf, segId);

    newBuf.clear();
    this.pageBuffer.clear();
    this.pageBuffer.position(spareOffset);
    this.pageBuffer.put(newBuf);

    this.pageBuffer.position(spareOffset);
    this.pageBuffer.limit(spareOffset + newSegSize);
    ISegment<ByteBuffer, ICachedMNode> newSeg =
        WrappedSegment.loadAsSegment(this.pageBuffer.slice());

    // registerNewSegment will modify page status considering the new segment
    return SchemaFile.getGlobalIndex(pageIndex, registerNewSegment(newSeg));
  }
Implementing marking deletion will not modify {@linkplain #memberNum} nor truncate {@linkplain
#segOffsetLst}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/SegmentedPage.java