@SuppressWarnings("squid:S3776") // high Cognitive Complexity
  private long[] checkAlignedMemCostAndAddToTspInfoForRow(
      IDeviceID deviceId,
      String[] measurements,
      TSDataType[] dataTypes,
      Object[] values,
      TsTableColumnCategory[] columnCategories)
      throws WriteProcessException {
    // Memory of increased PrimitiveArray and TEXT values, e.g., add a long[128], add 128*8
    long memTableIncrement = 0L;
    long textDataIncrement = 0L;
    long chunkMetadataIncrement = 0L;

    IWritableMemChunk memChunk =
        workMemTable.getWritableMemChunk(deviceId, AlignedPath.VECTOR_PLACEHOLDER);
    if (memChunk == null) {
      // For new device of this mem table
      // ChunkMetadataIncrement
      chunkMetadataIncrement +=
          ChunkMetadata.calculateRamSize(AlignedPath.VECTOR_PLACEHOLDER, TSDataType.VECTOR)
              * dataTypes.length;
      memTableIncrement += AlignedTVList.alignedTvListArrayMemCost(dataTypes, columnCategories);
    } else {
      // For existed device of this mem table
      AlignedWritableMemChunk alignedMemChunk = (AlignedWritableMemChunk) memChunk;
      List<TSDataType> dataTypesInTVList = new ArrayList<>();
      for (int i = 0; i < dataTypes.length; i++) {
        // Skip failed Measurements
        if (dataTypes[i] == null
            || measurements[i] == null
            || (columnCategories != null && columnCategories[i] != TsTableColumnCategory.FIELD)) {
          continue;
        }

        // add arrays for new columns
        if (!alignedMemChunk.containsMeasurement(measurements[i])) {
          int currentArrayNum =
              alignedMemChunk.alignedListSize() / PrimitiveArrayManager.ARRAY_SIZE
                  + (alignedMemChunk.alignedListSize() % PrimitiveArrayManager.ARRAY_SIZE > 0
                      ? 1
                      : 0);
          memTableIncrement += currentArrayNum * AlignedTVList.valueListArrayMemCost(dataTypes[i]);
          dataTypesInTVList.add(dataTypes[i]);
        }
      }
      // this insertion will result in a new array
      if ((alignedMemChunk.alignedListSize() % PrimitiveArrayManager.ARRAY_SIZE) == 0) {
        dataTypesInTVList.addAll(alignedMemChunk.getWorkingTVList().getTsDataTypes());
        memTableIncrement += alignedMemChunk.getWorkingTVList().alignedTvListArrayMemCost();
      }
    }

    for (int i = 0; i < dataTypes.length; i++) {
      // TEXT data mem size
      if (dataTypes[i] != null && dataTypes[i].isBinary() && values[i] != null) {
        textDataIncrement += MemUtils.getBinarySize((Binary) values[i]);
      }
    }
    updateMemoryInfo(memTableIncrement, chunkMetadataIncrement, textDataIncrement);
    return new long[] {memTableIncrement, textDataIncrement, chunkMetadataIncrement};
  }
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