public static long calculateTabletSizeInBytes(Tablet tablet) {
    long totalSizeInBytes = 0;

    if (tablet == null) {
      return totalSizeInBytes;
    }

    long[] timestamps = tablet.getTimestamps();
    Object[] tabletValues = tablet.getValues();

    // timestamps
    if (timestamps != null) {
      totalSizeInBytes += timestamps.length * 8L;
    }

    // values
    final List<IMeasurementSchema> timeseries = tablet.getSchemas();
    if (timeseries != null) {
      for (int column = 0; column < timeseries.size(); column++) {
        final IMeasurementSchema measurementSchema = timeseries.get(column);
        if (measurementSchema == null) {
          continue;
        }

        final TSDataType tsDataType = measurementSchema.getType();
        if (tsDataType == null) {
          continue;
        }

        if (tsDataType.isBinary()) {
          if (tabletValues == null || tabletValues.length <= column) {
            continue;
          }
          final Binary[] values = ((Binary[]) tabletValues[column]);
          if (values == null) {
            continue;
          }
          for (Binary value : values) {
            totalSizeInBytes += value == null ? 8 : value.ramBytesUsed();
          }
        } else {
          totalSizeInBytes += (long) tablet.getMaxRowNumber() * tsDataType.getDataTypeSize();
        }
      }
    }

    // bitMaps
    BitMap[] bitMaps = tablet.getBitMaps();
    if (bitMaps != null) {
      for (int i = 0; i < bitMaps.length; i++) {
        totalSizeInBytes += bitMaps[i] == null ? 0 : bitMaps[i].getSize();
      }
    }

    // estimate other dataStructures size
    totalSizeInBytes += 100;

    return totalSizeInBytes;
  }
Given a row of a tablet, calculate the row count and memory cost of the pipe tablet that will
be constructed according to config.

@return left is the row count of tablet, right is the memory cost of tablet in bytes
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/memory/PipeMemoryWeightUtil.java