@Override
  public void delete(ICachedMNode node) throws IOException, MetadataException {
    pagePool.cacheGuardian();
    SchemaPageContext cxt = new SchemaPageContext();
    // node is the record deleted from its segment
    entrantLock(node.getParent(), cxt);
    try {
      // remove corresponding record
      long recSegAddr = getNodeAddress(node.getParent());
      recSegAddr = getTargetSegmentAddress(recSegAddr, node.getName(), cxt);
      ISchemaPage tarPage = getPageInstance(getPageIndex(recSegAddr), cxt);
      cxt.markDirty(tarPage);
      tarPage.getAsSegmentedPage().removeRecord(getSegIndex(recSegAddr), node.getName());

      // remove segments belongs to node
      if (!node.isMeasurement() && getNodeAddress(node) > 0) {
        // node with maliciously modified address may result in orphan pages
        long delSegAddr = getNodeAddress(node);
        tarPage = getPageInstance(getPageIndex(delSegAddr), cxt);

        if (tarPage.getAsSegmentedPage() != null) {
          // TODO: may produce fractured page
          cxt.markDirty(tarPage);
          tarPage.getAsSegmentedPage().deleteSegment(getSegIndex(delSegAddr));
          if (tarPage.getAsSegmentedPage().validSegments() == 0) {
            tarPage.getAsSegmentedPage().purgeSegments();
          }
          cxt.indexBuckets.sortIntoBucket(tarPage, (short) -1);
        }

        if (tarPage.getAsInternalPage() != null) {
          // If the deleted one points to an Internal (root of BTree),
          //  there are two BTrees to handle:
          //  one mapping node names to record buffers,
          //  and another mapping aliases to names. <br>
          // All of those are turned into SegmentedPage.
          Deque<Integer> cascadePages =
              new ArrayDeque<>(tarPage.getAsInternalPage().getAllRecords());
          cascadePages.add(tarPage.getPageIndex());

          if (tarPage.getSubIndex() >= 0) {
            cascadePages.add(tarPage.getSubIndex());
          }

          while (!cascadePages.isEmpty()) {
            tarPage = getPageInstance(cascadePages.poll(), cxt);
            if (tarPage.getAsSegmentedPage() != null) {
              tarPage.getAsSegmentedPage().purgeSegments();
              cxt.markDirty(tarPage);
              cxt.indexBuckets.sortIntoBucket(tarPage, (short) -1);
              continue;
            }

            if (tarPage.getAsInternalPage() != null) {
              cascadePages.addAll(tarPage.getAsInternalPage().getAllRecords());
            }

            tarPage =
                ISchemaPage.initSegmentedPage(
                    ByteBuffer.allocate(SchemaFileConfig.PAGE_LENGTH),
                    tarPage.getPageIndex(),
                    tarPage.getRefCnt(),
                    tarPage.getLock());
            replacePageInCache(tarPage, cxt);
          }
        }
      }
      flushDirtyPages(cxt);
    } finally {
      releaseLocks(cxt);
      pagePool.releaseReferent(cxt);
    }
  }
Insert an index entry into an internal page. Cascade insert or internal split conducted if
necessary.

@param treeTraceIndex position of page index which had been traced
@param key key of the entry
@param ptr pointer of the entry
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/pagemgr/BTreePageManager.java