public void insertRows(InsertRowsNode insertRowsNode, long[] infoForMetrics)
      throws WriteProcessException {

    ensureMemTable(infoForMetrics);

    long[] memIncrements;

    long memControlStartTime = System.nanoTime();
    if (insertRowsNode.isMixingAlignment()) {
      List<InsertRowNode> alignedList = new ArrayList<>();
      List<InsertRowNode> nonAlignedList = new ArrayList<>();
      for (InsertRowNode insertRowNode : insertRowsNode.getInsertRowNodeList()) {
        if (insertRowNode.isAligned()) {
          alignedList.add(insertRowNode);
        } else {
          nonAlignedList.add(insertRowNode);
        }
      }
      long[] alignedMemIncrements = checkAlignedMemCostAndAddToTspInfoForRows(alignedList);
      long[] nonAlignedMemIncrements = checkMemCostAndAddToTspInfoForRows(nonAlignedList);
      memIncrements = new long[3];
      for (int i = 0; i < 3; i++) {
        memIncrements[i] = alignedMemIncrements[i] + nonAlignedMemIncrements[i];
      }
    } else {
      if (insertRowsNode.isAligned()) {
        memIncrements =
            checkAlignedMemCostAndAddToTspInfoForRows(insertRowsNode.getInsertRowNodeList());
      } else {
        memIncrements = checkMemCostAndAddToTspInfoForRows(insertRowsNode.getInsertRowNodeList());
      }
    }
    // recordScheduleMemoryBlockCost
    infoForMetrics[1] += System.nanoTime() - memControlStartTime;

    long startTime = System.nanoTime();
    WALFlushListener walFlushListener;
    try {
      walFlushListener = walNode.log(workMemTable.getMemTableId(), insertRowsNode);
      if (walFlushListener.waitForResult() == AbstractResultListener.Status.FAILURE) {
        throw walFlushListener.getCause();
      }
    } catch (Exception e) {
      rollbackMemoryInfo(memIncrements);
      logger.warn("Exception during wal flush", e);
      if (e instanceof IoTDBRuntimeException) {
        throw new WriteProcessException(
            e.getMessage(), ((IoTDBRuntimeException) e).getErrorCode(), true);
      } else {
        throw new WriteProcessException(
            String.format(
                "%s: %s write WAL failed: %s",
                dataRegionName, tsFileResource.getTsFile().getAbsolutePath(), e.getMessage()),
            e);
      }
    } finally {
      // recordScheduleWalCost
      infoForMetrics[2] += System.nanoTime() - startTime;
    }

    startTime = System.nanoTime();

    PipeDataNodeAgent.runtime().assignSimpleProgressIndexIfNeeded(insertRowsNode);
    if (!insertRowsNode.isGeneratedByPipe()) {
      workMemTable.markAsNotGeneratedByPipe();
    }
    PipeInsertionDataNodeListener.getInstance()
        .listenToInsertNode(
            dataRegionInfo.getDataRegion().getDataRegionId(),
            dataRegionInfo.getDataRegion().getDatabaseName(),
            walFlushListener.getWalEntryHandler(),
            insertRowsNode,
            tsFileResource);

    int pointInserted = 0;
    for (InsertRowNode insertRowNode : insertRowsNode.getInsertRowNodeList()) {
      if (insertRowNode.isAligned()) {
        pointInserted += workMemTable.insertAlignedRow(insertRowNode);
      } else {
        pointInserted += workMemTable.insert(insertRowNode);
      }
      // update start time of this memtable
      tsFileResource.updateStartTime(insertRowNode.getDeviceID(), insertRowNode.getTime());
      // for sequence tsfile, we update the endTime only when the file is prepared to be closed.
      // for unsequence tsfile, we have to update the endTime for each insertion.
      if (!sequence) {
        tsFileResource.updateEndTime(insertRowNode.getDeviceID(), insertRowNode.getTime());
      }
    }

    tsFileResource.updateProgressIndex(insertRowsNode.getProgressIndex());
    // recordScheduleMemTableCost
    infoForMetrics[3] += System.nanoTime() - startTime;
    // update memtable point inserted count
    infoForMetrics[4] += pointInserted;
  }
Insert data in an InsertRowNode into the workingMemtable.

@param insertRowNode physical plan of insertion
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java