private void updateAlignedMemCost(
      TSDataType[] dataTypes,
      IDeviceID deviceId,
      String[] measurementIds,
      int start,
      int end,
      long[] memIncrements,
      Object[] columns,
      TsTableColumnCategory[] columnCategories,
      boolean noFailure,
      TSStatus[] results) {
    int incomingPointNum;
    if (noFailure) {
      incomingPointNum = end - start;
    } else {
      incomingPointNum = end - start;
      for (TSStatus result : results) {
        if (result != null && result.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
          incomingPointNum--;
        }
      }
    }

    int measurementColumnNum = 0;
    if (columnCategories == null) {
      measurementColumnNum = dataTypes.length;
    } else {
      for (TsTableColumnCategory columnCategory : columnCategories) {
        if (columnCategory == TsTableColumnCategory.FIELD) {
          measurementColumnNum++;
        }
      }
    }

    // memIncrements = [memTable, text, chunk metadata] respectively
    IWritableMemChunk memChunk =
        workMemTable.getWritableMemChunk(deviceId, AlignedPath.VECTOR_PLACEHOLDER);
    if (memChunk == null) {
      // new devices introduce new ChunkMetadata
      // ChunkMetadata memory Increment
      memIncrements[2] +=
          measurementColumnNum
              * ChunkMetadata.calculateRamSize(AlignedPath.VECTOR_PLACEHOLDER, TSDataType.VECTOR);
      // TVList memory

      int numArraysToAdd =
          incomingPointNum / PrimitiveArrayManager.ARRAY_SIZE
              + (incomingPointNum % PrimitiveArrayManager.ARRAY_SIZE > 0 ? 1 : 0);
      memIncrements[0] +=
          numArraysToAdd * AlignedTVList.alignedTvListArrayMemCost(dataTypes, columnCategories);
    } else {
      AlignedWritableMemChunk alignedMemChunk = (AlignedWritableMemChunk) memChunk;
      List<TSDataType> dataTypesInTVList = new ArrayList<>();
      int currentPointNum = alignedMemChunk.alignedListSize();
      int newPointNum = currentPointNum + incomingPointNum;
      for (int i = 0; i < dataTypes.length; i++) {
        TSDataType dataType = dataTypes[i];
        String measurement = measurementIds[i];
        Object column = columns[i];
        if (dataType == null
            || column == null
            || measurement == null
            || (columnCategories != null && columnCategories[i] != TsTableColumnCategory.FIELD)) {
          continue;
        }

        if (!alignedMemChunk.containsMeasurement(measurementIds[i])) {
          // add a new column in the TVList, the new column should be as long as existing ones
          memIncrements[0] +=
              (currentPointNum / PrimitiveArrayManager.ARRAY_SIZE + 1)
                  * AlignedTVList.valueListArrayMemCost(dataType);
          dataTypesInTVList.add(dataType);
        }
      }

      // calculate how many new arrays will be added after this insertion
      int currentArrayCnt =
          currentPointNum / PrimitiveArrayManager.ARRAY_SIZE
              + (currentPointNum % PrimitiveArrayManager.ARRAY_SIZE > 0 ? 1 : 0);
      int newArrayCnt =
          newPointNum / PrimitiveArrayManager.ARRAY_SIZE
              + (newPointNum % PrimitiveArrayManager.ARRAY_SIZE > 0 ? 1 : 0);
      long acquireArray = newArrayCnt - currentArrayCnt;

      if (acquireArray != 0) {
        // memory of extending the TVList
        dataTypesInTVList.addAll(alignedMemChunk.getWorkingTVList().getTsDataTypes());
        memIncrements[0] +=
            acquireArray * alignedMemChunk.getWorkingTVList().alignedTvListArrayMemCost();
      }
    }

    // flexible-length data size
    for (int i = 0; i < dataTypes.length; i++) {
      TSDataType dataType = dataTypes[i];
      String measurement = measurementIds[i];
      Object column = columns[i];
      if (dataType == null
          || column == null
          || measurement == null
          || (columnCategories != null && columnCategories[i] != TsTableColumnCategory.FIELD)) {
        continue;
      }

      if (dataType.isBinary()) {
        Binary[] binColumn = (Binary[]) columns[i];
        memIncrements[1] += MemUtils.getBinaryColumnSize(binColumn, start, end, results);
      }
    }
  }
Insert batch data of insertTabletPlan into the workingMemtable. The rows to be inserted are in
the range [start, end). Null value in each column values will be replaced by the subsequent
non-null value, e.g., {1, null, 3, null, 5} will be {1, 3, 5, null, 5}

@param insertTabletNode insert a tablet of a device
@param rangeList start and end index list of rows to be inserted in insertTabletPlan
@param results result array
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java