@Test
  public void test2KAlias() throws Exception {
    ISchemaFile sf = SchemaFile.initSchemaFile("root.sg", TEST_SCHEMA_REGION_ID);
    ICachedMNode sgNode = nodeFactory.createDatabaseMNode(null, "mma").getAsMNode();
    // 5 devices, each for 200k measurements
    int factor2K = 2000;
    List<ICachedMNode> devs = new ArrayList<>();
    List<List> senList = new ArrayList<>();
    Map<String, String> aliasAns = new HashMap<>();

    try {
      for (int i = 0; i < 5; i++) {
        devs.add(nodeFactory.createDeviceMNode(sgNode, "d_" + i).getAsMNode());
        sgNode.addChild(devs.get(i));
      }

      for (ICachedMNode dev : devs) {
        List<ICachedMNode> sens = new ArrayList<>();
        for (int i = 0; i < factor2K; i++) {
          sens.add(getMeasurementNode(dev, "s_" + i, null));
          dev.addChild(sens.get(i));

          if (dev.getName().equals("d_0")) {
            aliasAns.put("s_" + i, "als_" + i);
          }
        }
        senList.add(sens);
      }

      Iterator<ICachedMNode> ite = getTreeBFT(sgNode);

      ICachedMNode curNode;
      while (ite.hasNext()) {
        curNode = ite.next();
        if (!curNode.isMeasurement()) {
          writeMNodeInTest(sf, curNode);
        }
      }
    } finally {
      sf.sync();
      sf.close();
    }

    sf = SchemaFile.loadSchemaFile("root.sg", TEST_SCHEMA_REGION_ID);
    try {
      ICachedMNode dev2 = devs.get(2);
      for (ICachedMNode child : dev2.getChildren().values()) {
        child.getAsMeasurementMNode().setAlias(aliasAns.get(child.getName()));
      }

      for (String name : aliasAns.keySet()) {
        moveToUpdateBuffer(dev2, name);
      }

      writeMNodeInTest(sf, dev2);
      sf.sync();
      sf.close();

      sf = SchemaFile.loadSchemaFile("root.sg", TEST_SCHEMA_REGION_ID);

      for (Map.Entry<String, String> entry : aliasAns.entrySet()) {
        Assert.assertEquals(entry.getKey(), sf.getChildNode(dev2, entry.getValue()).getName());
      }

      Iterator<ICachedMNode> children = sf.getChildren(dev2);
      int cnt = 0;
      while (children.hasNext()) {
        cnt++;
        children.next();
      }
      Assert.assertEquals(factor2K, cnt);

    } finally {
      sf.close();
    }
  }
related methods shall be merged further: {@linkplain SchemaFile#reEstimateSegSize}
,{@linkplain PageManager#reEstimateSegSize}
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/mtree/schemafile/SchemaFileTest.java