private void insertIndexEntryEntrance(
      ISchemaPage curPage, ISchemaPage splPage, String sk, SchemaPageContext cxt)
      throws MetadataException, IOException {
    if (cxt.treeTrace[0] < 1) {
      // To make parent pointer valid after the btree established, curPage need to be transformed
      //  into an InternalPage. Since NOW page CANNOT transform in place, a substitute InternalPage
      //  inherits index from curPage initiated.
      ISegmentedPage trsPage = getMinApplSegmentedPageInMem(SchemaFileConfig.SEG_MAX_SIZ, cxt);
      trsPage.transplantSegment(
          curPage.getAsSegmentedPage(), (short) 0, SchemaFileConfig.SEG_MAX_SIZ);

      // repPage inherits lock and referent from curPage, which is always locked by entrant.
      ISchemaPage repPage =
          ISchemaPage.initInternalPage(
              ByteBuffer.allocate(SchemaFileConfig.PAGE_LENGTH),
              curPage.getPageIndex(),
              trsPage.getPageIndex(),
              curPage.getRefCnt(),
              curPage.getLock());

      // link right child of the initiated InternalPage
      if (0 > repPage.getAsInternalPage().insertRecord(sk, splPage.getPageIndex())) {
        throw new ColossalRecordException(sk);
      }

      // setNextSegment of root as the left-most leaf
      repPage
          .getAsInternalPage()
          .setNextSegAddress(getGlobalIndex(trsPage.getPageIndex(), (short) 0));

      // mark the left-most child for interleaved flush, given the write operation is ordered
      cxt.invokeLastLeaf(trsPage);
      replacePageInCache(repPage, cxt);
    } else {
      // if the write starts from non-left-most leaf, it shall be recorded as well
      cxt.invokeLastLeaf(curPage);
      insertIndexEntryRecursiveUpwards(cxt.treeTrace[0], sk, splPage.getPageIndex(), cxt);
    }
  }
Entrance to deal with main index structure of records.

@param curPage original page occurred overflow.
@param splPage new page for original page to split.
@param sk least key of splPage.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/pagemgr/BTreePageManager.java